I am trying to sort the NSMutablArray values by Aa-Zz format in iPhone app. I have used the below code in my project.
for (id key in [dictionary allKeys])
{
id value = [dictionary valueForKey:key];
[duplicateArray addObject:value];
[value release];
value =nil;
NSSortDescriptor *sortdis = [[[NSSortDescriptor alloc] initWithKey:@"Name" ascending:YES] autorelease];
NSArray *discriptor = [NSArray arrayWithObjects:sortdis,nil];
mutableArray = [[duplicateArray sortedArrayUsingDescriptors:discriptor]retain];
}
NSLog(@"mutableArray : %@", mutableArray);
[mutableArray sortUsingSelector:@selector(caseInsensitiveCompare:)];
The app getting crash with this error log: [__NSArrayI sortUsingSelector:]: unrecognized selector sent to instance.
But, i have searched and found the reason for the crash. My mutableArray values are like this,
(
{
Id = 00001;
Name = "ABCD";
},
{
Id = 00002;
Name = "BCDE";
},
{
Id = 00003;
Name = "ZXYS";
},
{
Id = 00004;
Name = "abcd";
},
{
Id = 00009;
Name = "bcde";
},
)
I want to sort this array valuse like ABCD, abcd, BCDE, bcde, ZXYs.
Can anyone please help to solve this.
Gopinath. Please use this updated code in your project.
I hope it will help you. Thanks.