【发布时间】:2010-07-05 21:44:15
【问题描述】:
我正在尝试使用最新版本的 XCode 制作一个简单的 Cocoa 应用程序。在界面生成器中,我添加了 NSTextField 和 NSButton。当我按下按钮时,我希望它清除文本字段中的任何内容。
我创建了一个名为 AppController.h 的新类。这是内容:
#import <Foundation/Foundation.h>
@interface AppController : NSObject {
IBOutlet id textView;
}
- (IBAction) clearText: sender;
@end
AppController.m 看起来像这样:
#import "AppController.h"
@implementation AppController
- (IBAction) clearText: sender
{
[textView setString: @" "];
}
@end
我将按钮连接到 clearText 并将文本框连接到 textView。
程序编译并运行。但是当我按下按钮时,什么也没有发生。这是为什么呢?
【问题讨论】:
-
您使用的是哪个版本的 XCode?span>
-
我正在使用我今天下载的最新版本。版本 3.2.3。
-
Future-duping What's wrong with this Cocoa code?,因为这个较新的问题似乎有更集中的答案。
标签: cocoa