I have a custom object like:
I have an NSMutableArray (storeArray) array containing Store objects:
store1 = [[Store alloc] init]; store1.name = @"Walmart"; store1.address = @"walmart address here.."; store2 = [[Store alloc] init]; store2.name = @"Target"; store2.address = @"Target address here.."; store3 = [[Store alloc] init]; store3.name = @"Apple Store"; store3.address = @"Apple store address here.."; //add stores to array storeArray = [[NSMutableArray alloc] init]; [storeArray addObject:store1]; [storeArray addObject:store2]; [storeArray addObject:store3];
My question is, how can I sort the array by store name? I know that I can sort the array in alphabetical order using this line:
[nameOfArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]
How can I apply this to the store name of my Store class?
Andrew Davis
source share