<null>
来源:互联网 发布:淘宝看访客来源 编辑:程序博客网 时间:2024/05/18 03:54
在网络开发过程中,我们会对返回的值进行处理,
得到(null)以及 < null>的返回值。
由于要根据返回值进行判断,做出必要反应,因此必须知道返回值所代表的具体字符,在得到(null)后利用isEqual:和@“”,NULL,@“(null)”,nil,Nil比较后均得不到正确结果,弄得不知所措了。
最后试了一下“==”,成功了。费尽周折之后才明白原来要这样用:
[NSNull null] 输出结果就是<null> if([serUserInfo.userEmail isEqual:[NSNull null]]) { serUserInfo.userEmail = @"未绑定"; }//在处理网络返回的数据的时候#import "NSMutableDictionary+JudgeNull.h"@implementation NSMutableDictionary (JudgeNull)/** * 处理网络返回字典中value为<null> 的情况 * @param dictionary 网络返回的字典 */+ (NSMutableDictionary *) dictionaryWithDictionaryJudgeNull:(NSDictionary *)dictionary { NSMutableDictionary * muDic = [NSMutableDictionary dictionaryWithDictionary:dictionary]; for (NSString *key in [muDic allKeys]) { if ([muDic objectForKey:key] == [NSNull null]) { [muDic removeObjectForKey:key]; } } return muDic;}@end//注意::在处理网络返回的数据的时候经常会出现 <null>的情况,所以在写网络请求的时候,要考虑到这个地方出现的bug
1 0
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- wampserver的apache服务无法启动
- iReport 报表、子报表、主从报表、合计、实例解析
- Launch4j 使用,对java项目的操作打包exe
- css 制作三角形/平行四边形
- iOS -实例变量
- <null>
- iOS之设置tableView背景图片/让UITableView自动滑动(定位)到某一行cell
- jquery仿新浪微博名片提示
- Software update notification template (软件更新通知模板)
- Android屏幕适配(1)
- Log4j2简单使用
- 软件工程(C编码实践篇)
- Linux多线程实践(4) --线程特定数据
- Hibernate_should be mapped with insert="false" update="false"的解决方法