私は初めてのココア/ Objective-Cアプリケーションを開発中ですので、明らかに間違っていることがあれば私にご負担ください。私はアプリケーションを別のNSTextField(この場合はラベル)にウィンドウ上のNSTextFieldにあるものをコピーダウンするように設定しました。ユーザーがテキストボックスに何も入力していない場合は、警告が表示されますが、警告は表示されません。私のコードに何が問題なのですか?NSAlertボックスが表示されない
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
}
また、(スキーム命名のような)ココアUI要素によって使用される方法のいずれかのガイドがありますか?私は、GUIプログラミングの.NETスタイルを使用しています。 @end
、ココアの命名/コーディングガイドラインdeveloper.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/ –