views:

17

answers:

1

When creating an NSFetchedResultsController instance, there is this sectionNameKeyPath: argument, which most peoeple seem to set to nil. Now lets say I have Employees in the table view and I want that they're sectioned by their street address streetName. Every Employee is associated with an StreetAddress Property. So I would put an @"address.streetName" key path in there?

But then, how does the NSFetchedResultsController actually split that into sections? I mean... how does it know if the sections must be of type A, B, C, D, E, ... and so forth, or A, Ag, Ay, B, Bf, Bx, ... (you get the idea), or even something like 1, 2, 3, ... or even more crazy, something like X0, X1, X2, X3 ... there are thousands of variations. Does it have some intelligent logic to figure that out automatically?

+1  A: 

No, it does not know to section them by just one letter, it would section them by uniquing the address.streetName property. If you want it sectioned only by the first letter then you can store a derived value of that first letter in the object.

This has the additional advantage of cleaning up things like lower case or extended versions of that character.

Marcus S. Zarra