对NSSet进行排序:
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
[[testSet.questions allObjects] sortedArrayUsingDescriptors:descriptor]; // warning
然后系统警告:
Incompatible pointer types sending 'NSSortDescriptor *__strong' to parameter of type 'NSArray *
sortedArrayUsingDescriptors 后能跟的参数类型为NSArray类型。可以传多个NSSortDescriptor.
你的代码中,只需要稍改一下就可以了
[[testSet.questions allObjects] sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];