Q:

IOS is it possible to get data of field of NSFetchedResultsController without casting

I have the following code:
if ([[frc objectAtIndexPath:indexPath] isKindOfClass:[Author class]])
    return ((Author *)[frc objectAtIndexPath:indexPath]).name;

return ((Location *)[frc objectAtIndexPath:indexPath]).name;

frc - NSFetchedResultsController.
How can I get data of identical field of objects Author and Location? Class must not know about the existence of Author and Location.
I also tried to do so:
id <NSFetchedResultsSectionInfo> sectionInfo = m_arts.sections[indexPath.section];
id object = sectionInfo.objects[indexPath.row];
NSLog(@"%@", object[@"name"]); // Crash!!!

A:

One approach would be to make Location and Author subclasses of NamedObject like this:
@interface NamedObject : NSObject
@property (strong) NSString *name;
@end

@interface Author : NamedObject
// ...
@end

@interface Location : NamedObject
// ...
@end

and then something like:
NamedObject *object = (NamedObject *) sectionInfo.objects[indexPath.row];
NSLog (@"%@", object.name);

to access the name property.

