如何将对象已存在的对象插入NSMutableArray列表中 [英] How to insert object already existing objects in NSMutableArray list

查看:68
本文介绍了如何将对象已存在的对象插入NSMutableArray列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将对象插入主列表时遇到问题.

I am getting a problem, while inserting an object into the main List.

[editContactList addObject:editcontacts];
[editObject.contactList insertObject:editContactList atIndex:0];//error as mutating method sent to immutable object
[editcontacts release];

推荐答案

如果遇到该特定错误,则实际上没有NSMutableArray;您有一个NSArray.这是一成不变的. (请注意,简单地将NSArray强制转换为NSMutableArray并没有任何作用,数组本身必须是可变数组的实例,在实例变量中很少见,尤其是那些可以公开访问的实例变量.)

If you get that particular error, you don't actually have an NSMutableArray; you have an NSArray. Which is immutable. (Note that simply casting an NSArray to NSMutableArray does nothing, the array itself needs to be an instance of a mutable array, rarely seen with instance variables, especially those made accessible publicly.)

编辑:我们将需要更多信息;这些变量的定义方式,初始化方式等.

We're going to need some more information; how are these variables defined, how are they initialized, etc.

这篇关于如何将对象已存在的对象插入NSMutableArray列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆