码迷,mamicode.com
首页 > 其他好文 > 详细

dictionaryWithObjectsAndKeys

时间:2015-09-08 20:02:43      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

NSDictionary    dictionaryWithObjectsAndKeys

   NSDictionary *parmDic = [NSDictionary dictionaryWithObjectsAndKeys:self.objClass.appId,@"appId",
                                self.objClass.cityCd,@"cityCd",
                                self.objClass.channelID,@"channelId",
                                1,@"currentPage",
                                1,@"pageSize",nil];
    
    NSDictionary *parmDic = [NSDictionary dictionaryWithObjectsAndKeys:@"SZ100",@"appId",
                                    @"苏州",@"cityCd",@"123",@"modelCd",
                                    1,@"channelId",
                                    1,@"currentPage",
                                    1,@"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"];

  

 

dictionaryWithObjectsAndKeys

标签:

原文地址:http://www.cnblogs.com/developer-qin/p/4792696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!