在下面的代码中,removeObject工作正常,但addObject不起作用。有什么问题?
[randomizedList addObject:sourceList[index]];
randomizedList在执行NSArray > NAObject >isa Class 0x0
之前和之后是相同的:$msgemail
答案 0 :(得分:3)
此处的问题是randomizedList
未分配。
NSMutableArray *sourceList = self.questions;
NSMutableArray *randomizedList = [[NSMutableArray alloc] init];
for (NSInteger i = sourceList.count; i > 0; i--) {
//other things
[randomizedList addObject:sourceList[index]];
[sourceList removeObject:sourceList[index]];
}