我正在尝试NSMutableArray
使用以下结构对 a 进行排序:
(
{
Code = "390954-150";
Size = "35";
},
{
Code = 790540MSO;
Size = "30";
}
)
我正在尝试根据 Code 值进行排序,NSMutableArray
称为arrayProduct
:
//Sort array by Code
NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Code" ascending:YES];
[arrayProduct sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];
//
但是上面的代码抛出了以下异常:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object'