【发布时间】:2014-09-07 03:30:35
【问题描述】:
在我的项目中,我正在使用 UILabel 和 NSArray,我正在以 NSString 的形式从数组中传递一个参数,我已经使用断点检查了方法的调用,该参数正确地传递了参数,但在尝试使用接收到的参数(在 NSString 的 from 中),但 UILabel 显示 NULL 值。这是代码:
- (void)updateMenuLabel:(NSString *)passedObject {
NSString *str=[NSString stringWithFormat:@"%@", passedObject];
lbl_selectitem.text=str;
}
【问题讨论】:
-
IB连接不正确?顺便说一句,
stringWithFormat行是多余的。 -
用IBOutlet连接,去掉多余的线试了下还是NULL
-
确保 lbl_selectitem 不为零(使用 NSLog(@"%@",lbl_selectitem) 记录它)。
-
如果标签中出现 NULL 字样,则
passedObject变量为nil。
标签: ios iphone objective-c nsstring uilabel