
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元素使用的方法指南(如命名方案)?我使用.NET风格的GUI编程.
@结束
if(_textBox1.stringValue!= @“”)
您正在比较指针相等性,因此该表达式始终返回true,因为字符串常量@“”永远不会与文本字段的字符串对象相同.
进行此比较的正确方法是:
if(![_ textBox1.stringValue isEqualToString:@“”])
甚至更好:
if(_textBox1.stringValue.length> 0)
总结以上是内存溢出为你收集整理的objective-c – NSAlert框未显示全部内容,希望文章能够帮你解决objective-c – NSAlert框未显示所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)