针对NS阵列的简单问题。我将对象存储在NSMuteable数组中。 [obj1,obj2,obj3]
如果选择了一个对象,我希望将其放在数组的前面。即如果选择Obj3,则:
[obj3,obj1,obj2]
下面的是可以使用还是重复obj3?此外,这是否可以使其线程安全?
[myMutableArray insertObject:obj3 atIndex:0];
假设您需要保持其他元素的顺序,则需要删除并插入有问题的对象:
NSMutableArray *array = ... // array with objects
NSInteger index = ... // index of object to move to the front
id obj = array[index];
[array removeObjectAtIndex:index];
[array insertObject:obj atIndex:0];
上一篇:不能踏入.NET Framework的源与VS2008 SP1Framework、NET
下一篇:Visual Studio中/ SOAP - “添加服务引用”VS“添加Web服务引用”Studio、Visual、SOAP、Web