加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – 使用NSDictionary的EXC_BAD_ACCESS

发布时间:2020-12-14 19:32:47 所属栏目:百科 来源:网络整理
导读:我正在尝试根据它们在NSArray中的位置将数组中的对象添加到NSDictionary中,但是一旦分配了NSDictionary,应用程序就会崩溃.有什么想法吗? NSString *venue_title = [venues objectAtIndex:[actionSheet tag]];NSString *venue_address = [venues_full_addres
我正在尝试根据它们在NSArray中的位置将数组中的对象添加到NSDictionary中,但是一旦分配了NSDictionary,应用程序就会崩溃.有什么想法吗?

NSString *venue_title = [venues objectAtIndex:[actionSheet tag]];
NSString *venue_address = [venues_full_address objectAtIndex:[actionSheet tag]];
NSString *venue_lat = [venues_lat objectAtIndex:[actionSheet tag]];
NSString *venue_lng = [venues_lng objectAtIndex:[actionSheet tag]];        
NSLog(@"%@,%@,%@",venue_title,venue_address,venue_lat,venue_lng);        
NSDictionary *venue_details_dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:venue_title,venue_lng,nil] forKeys:[NSArray arrayWithObjects:@"name",@"address",@"lat","lng",nil]];

我在NSLog对象时看到所有正确的值,但NSDictionary使应用程序崩溃并出现EXC_BAD_ACCESS错误.我启用了NSZombies,但是当它像经常显示的那样崩溃时没有显示任何内容.关于这里发生了什么的任何想法?提前致谢!

解决方法

NSDictionary *venue_details_dict = [[NSDictionary alloc] initWithObjects:
     [NSArray arrayWithObjects:venue_title,nil]
   forKeys:
     [NSArray arrayWithObjects:@"name",nil]];

你忘记了“lng”上的@.繁荣.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读