Committing changes to sync against 0.9

This commit is contained in:
Blake Watters
2011-03-19 20:59:54 -04:00
parent c495073497
commit a94456a01e
6 changed files with 29 additions and 3 deletions

View File

@@ -15,8 +15,8 @@
#pragma mark -
#pragma mark NSManagedObject helper methods
// TODO: The managedObjectContext should be settable at the class level to ease coupling with
// singleton object manager
// TODO: The object store should be settable at the class level to ease coupling with
// shared object manager
+ (NSManagedObjectContext*)managedObjectContext {
return [[[RKObjectManager sharedManager] objectStore] managedObjectContext];
}

View File

@@ -12,6 +12,7 @@
* map to a given request URL.
*/
@protocol RKManagedObjectCache
@required
/**
* Must return an array containing NSFetchRequests for use in retrieving locally

View File

@@ -31,7 +31,7 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
/*
* This returns an appropriate managed object context for this object store.
* Because of the intrecacies of how CoreData works across threads it returns
* Because of the intrecacies of how Core Data works across threads it returns
* a different NSManagedObjectContext for each thread.
*/
@property (nonatomic, readonly) NSManagedObjectContext* managedObjectContext;
@@ -71,5 +71,12 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
*/
- (RKManagedObject*)findOrCreateInstanceOfManagedObject:(Class)class withPrimaryKeyValue:(id)primaryKeyValue;
/**
* Returns an array of objects that the 'live' at the specified resource path. Usage of this
* method requires that you have provided an implementation of the managed object cache
*
* See managedObjectCache above
*/
- (NSArray*)objectsForResourcePath:(NSString*)resourcePath;
@end

View File

@@ -241,4 +241,15 @@ static NSString* const kRKManagedObjectContextKey = @"RKManagedObjectContext";
return object;
}
- (NSArray*)objectsForResourcePath:(NSString *)resourcePath {
NSArray* cachedObjects = nil;
if (self.managedObjectCache) {
NSArray* cacheFetchRequests = [self.managedObjectCache fetchRequestsForResourcePath:resourcePath];
cachedObjects = [RKManagedObject objectsWithFetchRequests:cacheFetchRequests];
}
return cachedObjects;
}
@end

View File

@@ -130,6 +130,9 @@ static const NSString* kRKModelMapperMappingFormatParserKey = @"RKMappingFormatP
if (keyPath) {
object = [object valueForKeyPath:keyPath];
}
// TODO: Calling into mapObjectFromDictionary here causes registration lookup even if class is populated
// TODO: need mapInstanceOfClass: fromDictionary:
if ([object isKindOfClass:[NSDictionary class]]) {
return [self mapObjectFromDictionary:(NSDictionary*)object];
} else if ([object isKindOfClass:[NSArray class]]) {
@@ -193,6 +196,8 @@ static const NSString* kRKModelMapperMappingFormatParserKey = @"RKMappingFormatP
}
// TODO: Can I make this support keyPath??
// Lookup an object type using the element to class mappings and map its attributes
// Expects an object of the form {"registered_type": {"attribute1": "value", "attribute2": "value"}
- (NSObject<RKObjectMappable>*)mapObjectFromDictionary:(NSDictionary*)dictionary {
NSString* elementName = [[dictionary allKeys] objectAtIndex:0];
Class class = [_elementToClassMappings objectForKey:elementName];

View File

@@ -1879,6 +1879,7 @@
GCC_PREFIX_HEADER = Code/Support/RestKit_Prefix.pch;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
SDKROOT = iphoneos;
@@ -1896,6 +1897,7 @@
GCC_PREFIX_HEADER = Code/Support/RestKit_Prefix.pch;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
SDKROOT = iphoneos;