Skip to content

Instantly share code, notes, and snippets.

View yasirmturk's full-sized avatar
💻
the smart engineer

Yasir Türk yasirmturk

💻
the smart engineer
View GitHub Profile
@yasirmturk
yasirmturk / gist:1408335
Created November 30, 2011 07:27
A generic core data function that can query given entity with the given condition & return sorted results
/*
* A generic function that can query that given entity with the given condition and return sorted results.
*/
-(NSArray *)queryDBForEntity:(NSString *)entityName predicate:(NSPredicate *)predicate sortByField:(NSString *)sortField
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:[self managedObjectContext]];
[request setEntity:entity];
if(sortField != nil)