I need to fetch a particular managed entity where value is xxx.
my managed object is
Subscriptions : NSManagedObject{
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSNumber * category;
@property (nonatomic, retain) NSNumber * frequency;
@property (nonatomic, retain) NSNumber * alertType;
}
I need to fetch only the one entities where name is “xxx”.
(There will be only one entities where name is xxx.)
I also need to fetch all entities where category is 1.
How can I do this using NSFetchRequest. I know how to use NSFetchedResultsController to fetch all entity values for an entity, but I want to fetch only one where name is xxx.
Suppose you have a
NSManagedObjectContext *context, then:The result array will contain all returned results and will be of type
Subscriptions. If the predicate matches only one item there will be only one result, if matches none, the array would be initialized, but itscountproperty would be 0. You may take a look at NSPredicate Class Reference and how you use it withCoreData.