Allen
Allen

Reputation: 3771

Getting section names

I'm trying to get section names of a fetched result.

NSArray *testArray = [self.fetchedResultsController sections];
for (NSString *string in testArray){
    NSLog(@"%@", string);
}

Like this, I'm getting the memory locations for the pointers. How would I be able to print out the actual section names?

Upvotes: 0

Views: 53

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726539

The items in sections are not NSStrings, they are objects conforming to the NSFetchedResultsSectionInfo protocol. The protocol defines a name property, so you need to do this:

NSArray *testArray = [self.fetchedResultsController sections];
for (id <NSFetchedResultsSectionInfo> ri in testArray){
    NSLog(@"%@", ri.name);
}

Upvotes: 2

Related Questions