我是 iOS 新手。我有一个警告信息,我无法解决它:) 我有以下代码:
NSSortDescriptor *sortDescriptorFirst = [NSSortDescriptor sortDescriptorWithKey:@"test" ascending:YES];
NSSortDescriptor *descriptor=[NSArray arrayWithObjects:sortDescriptorFirst,nil];
NSArray *sortedArray =[sections sortedArrayUsingDescriptors:@[descriptor]];
在第 2 行我有一个警告:
Incompatible pointer types initializing NSSortDescriptor with an expression of NSArray
如何解决?
最佳答案
你已经在第一行创建了 NSSortDescriptor,所以你不需要第二行:
NSSortDescriptor *sortDescriptorFirst = [NSSortDescriptor sortDescriptorWithKey:@"test" ascending:YES];
NSArray *sortedArray =[sections sortedArrayUsingDescriptors:@[sortDescriptorFirst]];
关于ios - 将 NSArray 转换为 NSSortDescriptor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20144591/