just ME
just ME

Reputation: 1827

convert NSArray into NSSortDescriptor

I am new to iOS. I have a warning message and I can t solve it:) I have the following code:

NSSortDescriptor *sortDescriptorFirst = [NSSortDescriptor sortDescriptorWithKey:@"test" ascending:YES];
NSSortDescriptor *descriptor=[NSArray arrayWithObjects:sortDescriptorFirst,nil];
NSArray *sortedArray =[sections sortedArrayUsingDescriptors:@[descriptor]];

At line 2 I have a warning:

Incompatible pointer types initializing NSSortDescriptor with an expression of NSArray

How to solve this?

Upvotes: 0

Views: 97

Answers (1)

Vladimir
Vladimir

Reputation: 170859

You already create NSSortDescriptor in 1st line, so you don't need 2nd one:

NSSortDescriptor *sortDescriptorFirst = [NSSortDescriptor sortDescriptorWithKey:@"test" ascending:YES];
NSArray *sortedArray =[sections sortedArrayUsingDescriptors:@[sortDescriptorFirst]];

Upvotes: 2

Related Questions