Crash iOS with Core Data

when I execute this line of code in iOS 8.3 this line crashes:

NSArray *results = [self executeFetchRequest:request inContext:context];

here is the entire function which fails:

+ (id) executeFetchRequestAndReturnFirstObject:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context
{
    [request setFetchLimit:1];

    NSArray *results = [self executeFetchRequest:request inContext:context];
    if ([results count] == 0)
    {
        return nil;
    }
    return [results objectAtIndex:0];
}

the above function is called by:

+ (id)findFirstByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context
{
    NSFetchRequest *request = [self requestFirstByAttribute:attribute withValue:searchValue inContext:context];
    [request setPropertiesToFetch:[NSArray arrayWithObject:attribute]];

    return [self executeFetchRequestAndReturnFirstObject:request inContext:context];
}

It is worth noting that I am very new to iOS programming so please go easy on me, the question may not be the best and there may not be much backing code but this is due to my lack of knowledge in iOS. My android questions are generally much better than this :P If I am able to add any more detail, I will add more as I can, the crash log is below

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Bad fetch request (NSManagedObjectResultType not compatible with contents of propertiesToFetch)' *First throw call stack: ( 0 CoreFoundation 0x0000000111d7dc65

exceptionPreprocess + 165 1 libobjc.A.dylib

0x0000000110fafbb7 objc_exception_throw + 45 2 CoreData

0x00000001112ecb6e -[NSSQLGenerator newSQLStatementForRequest:ignoreInheritance:countOnly:nestingLevel:] + 1646 3 CoreData 0x00000001112d8dc4 -[NSSQLAdapter _statementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 244 4 CoreData 0x00000001111f0e0c -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 316 5 CoreData 0x00000001111f0a86 -[NSSQLCore newRowsForFetchPlan:] + 118 6 CoreData 0x00000001111f033c -[NSSQLCore objectsForFetchRequest:inContext:] + 524 7 CoreData 0x00000001111efdbb -[NSSQLCore executeRequest:withContext:error:] + 299 8 CoreData 0x00000001112caa6c __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 3356 9 CoreData

0x00000001112d3c30 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 192 10 libdispatch.dylib 0x0000000114e29614 _dispatch_client_callout + 8 11 libdispatch.dylib 0x0000000114e0f002 _dispatch_barrier_sync_f_invoke + 365 12 CoreData 0x00000001112c5245 _perform + 197 13 CoreData

0x00000001111efa58 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 504 14 CoreData

0x00000001111ee2ca -[NSManagedObjectContext executeFetchRequest:error:] + 586 15 HawkExpress

0x000000010e52438e +[NSManagedObject(MagicalRecord) executeFetchRequest:inContext:] + 62 16 HawkExpress

0x000000010e52446e +[NSManagedObject(MagicalRecord) executeFetchRequestAndReturnFirstObject:inContext:] + 78 17 HawkExpress 0x000000010e5261fc +[NSManagedObject(MagicalRecord) findFirstByAttribute:withValue:inContext:] + 140 18 HawkExpress

0x000000010e526274 +[NSManagedObject(MagicalRecord) findFirstByAttribute:withValue:] + 100 19 HawkExpress

0x000000010e52aa54 +[FavouritesManager doesFavouriteExist:] + 84 20 HawkExpress 0x000000010e4de4a7 -[BookCabViewController tableView:cellForRowAtIndexPath:] + 2087 21 UIKit 0x00000001124b9a28 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508 22 UIKit 0x0000000112498248 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2853 23 UIKit 0x00000001124ae8a9 -[UITableView layoutSubviews] + 210 24 UIKit

+ 23 32 CoreFoundation 0x0000000111cb0c00 __CFRunLoopDoObservers + 368 33 CoreFoundation 0x0000000111ca6a33 __CFRunLoopRun + 1123 34 CoreFoundation

0x0000000111ca6366 CFRunLoopRunSpecific + 470 35 GraphicsServices

0x0000000114a34a3e GSEventRunModal + 161 36 UIKit

0x00000001123b8900 UIApplicationMain + 1282 37 HawkExpress

0x000000010e4baa23 main + 99 38 libdyld.dylib

0x0000000114e5d145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

You need to check if the NSArray results is nil before you can do a count.

if (array != nil) {
    NSUInteger count = [array count]; // May be 0 if the object has been deleted.
    //
}
else {
    // Deal with error.
}

See https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html