I tried your code. Here is the working code.
Code:
NSArray *a= [course.students allObjects];
NSSortDescriptor *d = [[NSSortDescriptor alloc] initWithKey:@"name"
ascending:YES];
a = [a sortedArrayUsingDescriptors:[NSArray arrayWithObject:d]];
[d release];
I believe the issue with your code is that it doesn't get the names of the students. NSArray *a seems to be holding an array of student objects.
Here is the output when I do
NSLog(@"Students' names are: %@", [a componentsJoinedByString:@", "]);
Code:
2010-07-10 18:31:38.572 PickEm[7715:20b] Students' names are: <Student: 0xf5a120> (entity: Student; id: 0xf59f60 <x-coredata://E4C16B60-53CA-46C2-990E-0AF6151DAA34/Student/p2> ; data: {
course = 0xf3a7e0 <x-coredata://E4C16B60-53CA-46C2-990E-0AF6151DAA34/Course/p1>;
name = Billy;
weight = 2;
}), <Student: 0xf5a1a0> (entity: Student; id: 0xf4d520 <x-coredata://E4C16B60-53CA-46C2-990E-0AF6151DAA34/Student/p4> ; data: {
course = 0xf3a7e0 <x-coredata://E4C16B60-53CA-46C2-990E-0AF6151DAA34/Course/p1>;
name = George;
weight = 2;
For now, all I need to do is the tableView:cellForRowAtIndexPath: method and set the cell.textLabel.text to the names of the students.