<分区>
标签 ios iphone objective-c null
<分区>
我应该在哪里使用 nil 以及其他的 Null Nil 现在我想将 nil val 分配给一个字符串 nsstring=nil;
最佳答案
获取nil
和null
的不同请引用Objective-C: What's the difference between NULL, nil and @""?
如果你想将nil
或null
分配给NSString
,你应该写
NSString *myStr = @""; // it empty/nil/null
您可以通过以下方式检查字符串是否为空
if([myStr length] == 0) // or if([myStr isEqual:[NSNull class]])
{
// empty string;
}
else
{
// not empty string;
}
关于ios - 应该使用 nil 和 Nil 以及 ios 中的 Null 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21043539/
相关文章:
iphone - 从 NSObject 类调用 ViewController 方法
iphone - 使用 00 :00:00 as time 获取今天的 NSDate
ios - 如何测试 Json 响应是否包含错误或正确的 json
ios - 键盘存在时如何使 UITextField 向上移动?
ios - 应用程序给出 SIGBART 并声称打开特定 View 时数组索引不存在,然后崩溃
objective-c - 用于解析 html 的正则表达式;
ios - 从库中选择视频时,uiimagepickercontroller didfinishpickingmediawithinfo NOT CALLED