【发布时间】:2023-03-19 00:35:01
【问题描述】:
我知道,一旦你在编码方面变得更好,你就会知道什么是变量,并且这里可能会出现 null 并且可能不会出现。在达到这种心态的过程中,是否有任何方法可以使您声称为 null 的变量陷入困境并验证它确实为 null,或者您只是使用了错误的代码?
例子:
-(IBAction) startMotion: (id)sender {
NSLog(@"Forward or back button is being pressed.");
UIButton * buttonName = (UIButton *) sender;
NSLog(@"Button Name: %@", buttonName.currentTitle);
}
按钮名称:(null) 是显示在控制台中的内容
谢谢
【问题讨论】:
-
这是...目标C?您可能应该将您的目标语言添加到标签中,以便最了解该语言的人可以帮助您。
标签: objective-c variables casting null