Declared in NSManagedObject+ActiveRecord.h
NSManagedObject+ActiveRecord.m

Overview

Provides extensions to NSManagedObject implementing a low-ceremony querying interface.

Tasks

  • + entity

    The NSEntityDescription for the Subclass defaults to the subclass className, may be overridden

  • + fetchRequest

    Returns an initialized NSFetchRequest for the entity, with no predicate

  • + objectsWithFetchRequest:

    Fetches all objects from the persistent store identified by the fetchRequest

  • + countOfObjectsWithFetchRequest:

    Retrieves the number of objects that would be retrieved by the fetchRequest, if executed

  • + objectsWithFetchRequests:

    Fetches all objects from the persistent store via a set of fetch requests and returns all results in a single array.

  • + objectWithFetchRequest:

    Fetches the first object identified by the fetch request. A limit of one will be applied to the fetch request before dispatching.

  • + objectsWithPredicate:

    Fetches all objects from the persistent store by constructing a fetch request and applying the predicate supplied. A short-cut for doing filtered searches on the objects of this class under management.

  • + objectWithPredicate:

    Fetches the first object matching a predicate from the persistent store. A fetch request will be constructed for you and a fetch limit of 1 will be applied.

  • + allObjects

    Fetches all managed objects of this class from the persistent store as an array

  • + count:

    Returns a count of all managed objects of this class in the persistent store. On error, will populate the error argument

  • + count

    Returns a count of all managed objects of this class in the persistent store. Deprecated use the error form above

  • + object

    Creates a new managed object and inserts it into the managedObjectContext.

  • – isNew

    Returns YES when an object has not been saved to the managed object context yet

  • + findByPrimaryKey:

    Finds the instance of the receiver’s entity with the given value for the primary key attribute in the managed object context for the current thread.

  • + findByPrimaryKey:inContext:

    Finds the instance of the receiver’s entity with the given value for the primary key attribute in the given managed object context.

Class Methods

allObjects

Fetches all managed objects of this class from the persistent store as an array

+ (NSArray *)allObjects

Declared In

NSManagedObject+ActiveRecord.h

count

Returns a count of all managed objects of this class in the persistent store. Deprecated use the error form above

+ (NSUInteger)count

Discussion

@deprecated

Declared In

NSManagedObject+ActiveRecord.h

count:

Returns a count of all managed objects of this class in the persistent store. On error, will populate the error argument

+ (NSUInteger)count:(NSError **)error

Declared In

NSManagedObject+ActiveRecord.h

countOfObjectsWithFetchRequest:

Retrieves the number of objects that would be retrieved by the fetchRequest, if executed

+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest *)fetchRequest

Declared In

NSManagedObject+ActiveRecord.h

entity

The NSEntityDescription for the Subclass defaults to the subclass className, may be overridden

+ (NSEntityDescription *)entity

Declared In

NSManagedObject+ActiveRecord.h

fetchRequest

Returns an initialized NSFetchRequest for the entity, with no predicate

+ (NSFetchRequest *)fetchRequest

Declared In

NSManagedObject+ActiveRecord.h

findByPrimaryKey:

Finds the instance of the receiver’s entity with the given value for the primary key attribute in the managed object context for the current thread.

+ (id)findByPrimaryKey:(id)primaryKeyValue

Parameters

primaryKeyValue

The value for the receiving entity’s primary key attribute.

Return Value

The object with the primary key attribute equal to the given value or nil.

Declared In

NSManagedObject+ActiveRecord.h

findByPrimaryKey:inContext:

Finds the instance of the receiver’s entity with the given value for the primary key attribute in the given managed object context.

+ (id)findByPrimaryKey:(id)primaryKeyValue inContext:(NSManagedObjectContext *)context

Parameters

primaryKeyValue

The value for the receiving entity’s primary key attribute.

context

The managed object context to find the instance in.

Return Value

The object with the primary key attribute equal to the given value or nil.

Declared In

NSManagedObject+ActiveRecord.h

object

Creates a new managed object and inserts it into the managedObjectContext.

+ (id)object

Declared In

NSManagedObject+ActiveRecord.h

objectWithFetchRequest:

Fetches the first object identified by the fetch request. A limit of one will be applied to the fetch request before dispatching.

+ (id)objectWithFetchRequest:(NSFetchRequest *)fetchRequest

Declared In

NSManagedObject+ActiveRecord.h

objectWithPredicate:

Fetches the first object matching a predicate from the persistent store. A fetch request will be constructed for you and a fetch limit of 1 will be applied.

+ (id)objectWithPredicate:(NSPredicate *)predicate

Declared In

NSManagedObject+ActiveRecord.h

objectsWithFetchRequest:

Fetches all objects from the persistent store identified by the fetchRequest

+ (NSArray *)objectsWithFetchRequest:(NSFetchRequest *)fetchRequest

Declared In

NSManagedObject+ActiveRecord.h

objectsWithFetchRequests:

Fetches all objects from the persistent store via a set of fetch requests and returns all results in a single array.

+ (NSArray *)objectsWithFetchRequests:(NSArray *)fetchRequests

Declared In

NSManagedObject+ActiveRecord.h

objectsWithPredicate:

Fetches all objects from the persistent store by constructing a fetch request and applying the predicate supplied. A short-cut for doing filtered searches on the objects of this class under management.

+ (NSArray *)objectsWithPredicate:(NSPredicate *)predicate

Declared In

NSManagedObject+ActiveRecord.h

Instance Methods

isNew

Returns YES when an object has not been saved to the managed object context yet

- (BOOL)isNew

Declared In

NSManagedObject+ActiveRecord.h