私は初めてのcocoa/Objective-Cアプリケーションに取り組んでいるので、明らかに間違ったことをしている場合はご容赦ください。ウィンドウのNSTextFieldにあるものを別のNSTextField(この場合はラベル)にコピーするようにアプリケーションを設定しました。ユーザーがテキストボックスに何も入力していない場合は、アラートが表示されますが、表示されません。私のコードの何が問題になっていますか?
AppDelegate.m:
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize textBox1 = _textBox1;
@synthesize label1 = _label1;
- (void)dealloc
{
[super dealloc];
}
-(IBAction)setLabelTxt: (id)sender{
if(_textBox1.stringValue != @"")
[_label1 setStringValue: _textBox1.stringValue];
else{
NSAlert* msgBox = [[[NSAlert alloc] init] autorelease];
[msgBox setMessageText: @"You must have text in the text box."];
[msgBox addButtonWithTitle: @"OK"];
[msgBox runModal];
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
}
また、Cocoa UI要素(命名スキームなど)で使用されるメソッドのガイドはありますか?私はGUIプログラミングの.NETスタイルを使用しています。@終わり