草庐IT

removeObjectAtIndex

全部标签

ios - 尝试对 UITableView 中的单元格重新排序时获取 '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'

我正在使用AFNetworking获取UITableView单元格中的JSON数据。我已将数组声明为NSMutableArray,但我仍然收到-[__NSCFArrayremoveObjectAtIndex:]:mutatingmethodsenttoimmutableobject错误,每当我试图重新排序单元格。这是我用于重新排序的逻辑--(void)tableView:(UITableView*)tableViewmoveRowAtIndexPath:(NSIndexPath*)fromIndexPathtoIndexPath:(NSIndexPath*)toIndexPath{NS

ios - NSMutableArray removeObjectAtIndex 导致意外的 SIGABRT

我看过很多帖子,其中介绍了从数组中正确删除对象的各种方法,但我不确定哪种方法最适合我的实例。我正在从一个plist中加载一个字典,这个字典包含许多数组,这些数组包含另一个字典。所以我有3个存储设备设置,1个用于保存整个字典,另一个用于数组,最后一个字典用于保存数组中的对象:标题:NSMutableDictionary*questionsDictionary;NSMutableArray*questionsArray;NSDictionary*currentQuestion;@property(nonatomic,retain)NSMutableDictionary*questionsD

iphone - 将 bool 属性保存到 iOS 中的文件。

我想将bool属性保存到我的文件中,我认为这样做很野蛮。我必须检查我的属性,然后将字符串添加到NSMutableArray。我可以检查属性名称、状态/值然后保存到文件吗?或者我应该为此使用XML文件?但仍然为了有效使用,我应该获得属性名称和状态/值。你能给我一些建议吗?-(void)saveSettings{NSString*path=[[NSBundlemainBundle]pathForResource:@"settings"ofType:@""];if(music){[correctSettingArrayremoveObjectAtIndex:0];[correctSettin

objective-c - removeObjectAtIndex 导致 "message sent to deallocated instance"

我正在将一些代码转换为ARC。该代码在NSMutableArray中搜索元素,然后查找、删除并返回该元素。问题是元素在“removeObjectAtIndex”后立即被释放:-(UIView*)viewWithTag:(int)tag{UIView*view=nil;for(inti=0;i当我运行它时,我得到了***-[UIViewrespondsToSelector:]:messagesenttodeallocatedinstance0x87882f0在第二条日志语句处。在ARC之前,我小心地在调用removeObjectAtIndex:之前保留对象,然后自动释放它。我如何告诉AR

iphone - NSMutableArray removeObjectAtIndex

从我的NSMutableArray中删除时出现以下错误-[__NSArrayIremoveObjectAtIndex:]:unrecognizedselectorsenttoinstance0x1cdced102011-07-1300:33:14.333MassText[1726:707]***Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'-[__NSArrayIremoveObjectAtIndex:]:unrecognizedselectorsenttoinstance0x1cdce

ios - iOS 中 NSmutableArrays 的 NSMuatableArray 的 RemoveObjectAtIndex 崩溃

我正在使用NSMutableArray并尝试从NSMutableArray中删除对象然后它崩溃了[[self.sectionsArrayobjectAtIndex:indexPath.section]removeObjectAtIndex:indexPath.row];.h就像NSMutableArray*sectionsArray;@property(nonatomic,retain)NSMutableArray*sectionsArray;.mislike:@synthesizesectionsArray;#pragmamark-TableViewDelegate-(void)ta

ios - NSMutableArray 如何更改您使用 removeObjectAtIndex 的对象索引?

在使用NSMutableArray时,我可以addObject:然后使用removeObjectAtIndex:0删除前面的对象。来自文档:Tofillthegap,allelementsbeyondindexaremovedbysubtracting1fromtheirindex.这意味着,索引2处的对象变为1,3变为2,等等。这是否意味着每个对象都移动到索引1,或者“索引”值更新为索引1而0位置只是空。我意识到后者听起来多么愚蠢,但那一行给我的印象是这就是正在发生的事情。 最佳答案 在大多数数组实现中,NSMutableArra