0
我在排序一個可變數組。對於分選我用:如何避免iPhone中的「NSInternalInconsistencyException」?
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"pubDate" ascending:NO];
[recent sortUsingDescriptors:[NSArray arrayWithObjects:descriptor, nil]];
recent1 = [recent sortedArrayUsingDescriptors:descriptor];
[descriptor release];
我收到此錯誤:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object'
線
recent1 = [recent sortedArrayUsingDescriptors:descriptor];
顯示警告
- 「過客 'sortedarrayusingdescritors' 的參數1來自不同的目標c類型「和
在我的代碼,既recent
和recent1
「不同於目標C型分配」 是NSMutable
陣列。我哪裏出錯了?