dictionaryWithObjectsAndKeys

时间:2022-06-19 08:24:02

NSDictionary    dictionaryWithObjectsAndKeys

   NSDictionary *parmDic = [NSDictionary dictionaryWithObjectsAndKeys:self.objClass.appId,@"appId",
self.objClass.cityCd,@"cityCd",
self.objClass.channelID,@"channelId",
,@"currentPage",
,@"pageSize",nil]; NSDictionary *parmDic = [NSDictionary dictionaryWithObjectsAndKeys:@"SZ100",@"appId",
@"苏州",@"cityCd",@"",@"modelCd",
,@"channelId",
,@"currentPage",
,@"pageSize",nil];

网络传参,走到这一步就挂了,报

EXC_BAD_ACCESS ,90%的错误来源在于对一个已经释放的对象进行release操作。

于是改成下面那样也不行,继续查,才知道是

dictionaryWithObjectsAndKeys方法在遇到nil对象时,会以为是最终的结束标志。

见,

http://www.cocoachina.com/bbs/read.php?tid-124307.html

最后就改成这样,才通过:

    NSMutableDictionary* parmDic = [NSMutableDictionary dictionary];
[parmDic setValue:self.objClass.appId forKey:@"appId"];
[parmDic setValue:self.objClass.cityCd forKey:@"cityCd"];
[parmDic setValue:self.objClass.modelCd forKey:@"modelCd"];
[parmDic setValue:self.objClass.channelID forKey:@"channelID"];
[parmDic setValue:@(self.page) forKey:@"currentPage"];
[parmDic setValue:@(self.pageSize) forKey:@"pageSize"];