Integrated primaryKey extension to NSEntityDescription and refactored cache strategy

classes to eliminate issues with duplicated objects. closes #611, #612, #613, #618

* NSEntityDescription is now aware of the primaryKeyAttribute. Can be configured via
Interface Builder within Xcode or programatically.
* Added findByPrimaryKey: interface to the Core Data extensions.
* Relaxed dependencies on RKManagedObjectMapping across the system now that primaryKey is
available without a reference to the mapping.
This commit is contained in:
Blake Watters
2012-03-22 16:31:39 -04:00
parent 1b324ccc80
commit a545c3942b
32 changed files with 650 additions and 271 deletions

View File

@@ -22,7 +22,8 @@
@end
/**
Extensions for NSManage
Provides extensions to NSManagedObject implementing a low-ceremony querying
interface.
*/
@interface NSManagedObject (ActiveRecord)
@@ -102,6 +103,25 @@
*/
- (BOOL)isNew;
/**
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.
@param primaryKeyValue The value for the receiving entity's primary key attribute.
@return The object with the primary key attribute equal to the given value or nil.
*/
+ (id)findByPrimaryKey:(id)primaryKeyValue;
/**
Finds the instance of the receiver's entity with the given value for the primary key attribute in
the given managed object context.
@param primaryKeyValue The value for the receiving entity's primary key attribute.
@param context The managed object context to find the instance in.
@return The object with the primary key attribute equal to the given value or nil.
*/
+ (id)findByPrimaryKey:(id)primaryKeyValue inContext:(NSManagedObjectContext *)context;
////////////////////////////////////////////////////////////////////////////////////////////////////
+ (NSManagedObjectContext*)currentContext;