Ensure the stars for all pointers belong to the variable rather than the type. Refs #614

This commit is contained in:
Jawwad Ahmad
2012-06-04 22:47:30 -04:00
parent eaa5484b01
commit abb46c382c
191 changed files with 3678 additions and 3628 deletions

View File

@@ -31,59 +31,59 @@
* The NSEntityDescription for the Subclass
* defaults to the subclass className, may be overridden
*/
+ (NSEntityDescription*)entity;
+ (NSEntityDescription *)entity;
/**
* Returns an initialized NSFetchRequest for the entity, with no predicate
*/
+ (NSFetchRequest*)fetchRequest;
+ (NSFetchRequest *)fetchRequest;
/**
* Fetches all objects from the persistent store identified by the fetchRequest
*/
+ (NSArray*)objectsWithFetchRequest:(NSFetchRequest*)fetchRequest;
+ (NSArray *)objectsWithFetchRequest:(NSFetchRequest *)fetchRequest;
/**
* Retrieves the number of objects that would be retrieved by the fetchRequest,
* if executed
*/
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest*)fetchRequest;
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest *)fetchRequest;
/**
* 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;
+ (NSArray *)objectsWithFetchRequests:(NSArray *)fetchRequests;
/**
* 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;
+ (id)objectWithFetchRequest:(NSFetchRequest *)fetchRequest;
/**
* 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;
+ (NSArray *)objectsWithPredicate:(NSPredicate *)predicate;
/**
* 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;
+ (id)objectWithPredicate:(NSPredicate *)predicate;
/**
* Fetches all managed objects of this class from the persistent store as an array
*/
+ (NSArray*)allObjects;
+ (NSArray *)allObjects;
/**
* 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;
+ (NSUInteger)count:(NSError **)error;
/**
* Returns a count of all managed objects of this class in the persistent store. Deprecated
@@ -124,7 +124,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
+ (NSManagedObjectContext*)currentContext;
+ (NSManagedObjectContext *)currentContext;
+ (void)handleErrors:(NSError *)error;

View File

@@ -54,13 +54,13 @@ RK_FIX_CATEGORY_BUG(NSManagedObject_ActiveRecord)
#pragma mark - RKManagedObject methods
+ (NSEntityDescription*)entity
+ (NSEntityDescription *)entity
{
NSString* className = [NSString stringWithCString:class_getName([self class]) encoding:NSASCIIStringEncoding];
NSString *className = [NSString stringWithCString:class_getName([self class]) encoding:NSASCIIStringEncoding];
return [NSEntityDescription entityForName:className inManagedObjectContext:[NSManagedObjectContext contextForCurrentThread]];
}
+ (NSFetchRequest*)fetchRequest
+ (NSFetchRequest *)fetchRequest
{
NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init] autorelease];
NSEntityDescription *entity = [self entity];
@@ -68,19 +68,19 @@ RK_FIX_CATEGORY_BUG(NSManagedObject_ActiveRecord)
return fetchRequest;
}
+ (NSArray*)objectsWithFetchRequest:(NSFetchRequest*)fetchRequest
+ (NSArray *)objectsWithFetchRequest:(NSFetchRequest *)fetchRequest
{
NSError* error = nil;
NSArray* objects = [[NSManagedObjectContext contextForCurrentThread] executeFetchRequest:fetchRequest error:&error];
NSError *error = nil;
NSArray *objects = [[NSManagedObjectContext contextForCurrentThread] executeFetchRequest:fetchRequest error:&error];
if (objects == nil) {
RKLogError(@"Error: %@", [error localizedDescription]);
}
return objects;
}
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest*)fetchRequest
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest *)fetchRequest
{
NSError* error = nil;
NSError *error = nil;
NSUInteger objectCount = [[NSManagedObjectContext contextForCurrentThread] countForFetchRequest:fetchRequest error:&error];
if (objectCount == NSNotFound) {
RKLogError(@"Error: %@", [error localizedDescription]);
@@ -88,21 +88,21 @@ RK_FIX_CATEGORY_BUG(NSManagedObject_ActiveRecord)
return objectCount;
}
+ (NSArray*)objectsWithFetchRequests:(NSArray*)fetchRequests
+ (NSArray *)objectsWithFetchRequests:(NSArray *)fetchRequests
{
NSMutableArray* mutableObjectArray = [[NSMutableArray alloc] init];
for (NSFetchRequest* fetchRequest in fetchRequests) {
NSMutableArray *mutableObjectArray = [[NSMutableArray alloc] init];
for (NSFetchRequest *fetchRequest in fetchRequests) {
[mutableObjectArray addObjectsFromArray:[self objectsWithFetchRequest:fetchRequest]];
}
NSArray* objects = [NSArray arrayWithArray:mutableObjectArray];
NSArray *objects = [NSArray arrayWithArray:mutableObjectArray];
[mutableObjectArray release];
return objects;
}
+ (id)objectWithFetchRequest:(NSFetchRequest*)fetchRequest
+ (id)objectWithFetchRequest:(NSFetchRequest *)fetchRequest
{
[fetchRequest setFetchLimit:1];
NSArray* objects = [self objectsWithFetchRequest:fetchRequest];
NSArray *objects = [self objectsWithFetchRequest:fetchRequest];
if ([objects count] == 0) {
return nil;
} else {
@@ -110,28 +110,28 @@ RK_FIX_CATEGORY_BUG(NSManagedObject_ActiveRecord)
}
}
+ (NSArray*)objectsWithPredicate:(NSPredicate*)predicate
+ (NSArray *)objectsWithPredicate:(NSPredicate *)predicate
{
NSFetchRequest* fetchRequest = [self fetchRequest];
NSFetchRequest *fetchRequest = [self fetchRequest];
[fetchRequest setPredicate:predicate];
return [self objectsWithFetchRequest:fetchRequest];
}
+ (id)objectWithPredicate:(NSPredicate*)predicate
+ (id)objectWithPredicate:(NSPredicate *)predicate
{
NSFetchRequest* fetchRequest = [self fetchRequest];
NSFetchRequest *fetchRequest = [self fetchRequest];
[fetchRequest setPredicate:predicate];
return [self objectWithFetchRequest:fetchRequest];
}
+ (NSArray*)allObjects
+ (NSArray *)allObjects
{
return [self objectsWithPredicate:nil];
}
+ (NSUInteger)count:(NSError**)error
+ (NSUInteger)count:(NSError **)error
{
NSFetchRequest* fetchRequest = [self fetchRequest];
NSFetchRequest *fetchRequest = [self fetchRequest];
return [[NSManagedObjectContext contextForCurrentThread] countForFetchRequest:fetchRequest error:error];
}
@@ -171,7 +171,7 @@ RK_FIX_CATEGORY_BUG(NSManagedObject_ActiveRecord)
#pragma mark - MagicalRecord Ported Methods
+ (NSManagedObjectContext*)currentContext;
+ (NSManagedObjectContext *)currentContext;
{
return [NSManagedObjectContext contextForCurrentThread];
}

View File

@@ -29,8 +29,8 @@
*/
@interface RKManagedObjectLoader : RKObjectLoader {
RKManagedObjectStore *_objectStore;
NSManagedObjectID* _targetObjectID;
NSMutableSet* _managedObjectKeyPaths;
NSManagedObjectID *_targetObjectID;
NSMutableSet *_managedObjectKeyPaths;
BOOL _deleteObjectOnFailure;
}
@@ -39,7 +39,7 @@
@see RKManagedObjectStore
*/
@property (nonatomic, retain) RKManagedObjectStore* objectStore;
@property (nonatomic, retain) RKManagedObjectStore *objectStore;
+ (id)loaderWithURL:(RKURL *)URL mappingProvider:(RKObjectMappingProvider *)mappingProvider objectStore:(RKManagedObjectStore *)objectStore;
- (id)initWithURL:(RKURL *)URL mappingProvider:(RKObjectMappingProvider *)mappingProvider objectStore:(RKManagedObjectStore *)objectStore;

View File

@@ -82,7 +82,7 @@
#pragma mark - RKObjectMapperDelegate methods
- (void)objectMapper:(RKObjectMapper*)objectMapper didMapFromObject:(id)sourceObject toObject:(id)destinationObject atKeyPath:(NSString*)keyPath usingMapping:(RKObjectMapping*)objectMapping
- (void)objectMapper:(RKObjectMapper *)objectMapper didMapFromObject:(id)sourceObject toObject:(id)destinationObject atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMapping *)objectMapping
{
if ([destinationObject isKindOfClass:[NSManagedObject class]]) {
[_managedObjectKeyPaths addObject:keyPath];
@@ -101,7 +101,7 @@
return _targetObject;
}
- (void)setTargetObject:(NSObject*)targetObject
- (void)setTargetObject:(NSObject *)targetObject
{
[_targetObject release];
_targetObject = nil;
@@ -119,9 +119,9 @@
// right before send to avoid sequencing issues where the target object is
// set before the managed object store.
if (self.targetObject && [self.targetObject isKindOfClass:[NSManagedObject class]]) {
_deleteObjectOnFailure = [(NSManagedObject*)self.targetObject isNew];
_deleteObjectOnFailure = [(NSManagedObject *)self.targetObject isNew];
[self.objectStore save:nil];
_targetObjectID = [[(NSManagedObject*)self.targetObject objectID] retain];
_targetObjectID = [[(NSManagedObject *)self.targetObject objectID] retain];
}
return [super prepareURLRequest];
@@ -137,7 +137,7 @@
return nil;
}
- (void)deleteCachedObjectsMissingFromResult:(RKObjectMappingResult*)result
- (void)deleteCachedObjectsMissingFromResult:(RKObjectMappingResult *)result
{
if (! [self isGET]) {
RKLogDebug(@"Skipping cleanup of objects via managed object cache: only used for GET requests.");
@@ -159,11 +159,11 @@
}
// NOTE: We are on the background thread here, be mindful of Core Data's threading needs
- (void)processMappingResult:(RKObjectMappingResult*)result
- (void)processMappingResult:(RKObjectMappingResult *)result
{
NSAssert(_sentSynchronously || ![NSThread isMainThread], @"Mapping result processing should occur on a background thread");
if (_targetObjectID && self.targetObject && self.method == RKRequestMethodDELETE) {
NSManagedObject* backgroundThreadObject = [self.objectStore objectWithID:_targetObjectID];
NSManagedObject *backgroundThreadObject = [self.objectStore objectWithID:_targetObjectID];
RKLogInfo(@"Deleting local object %@ due to DELETE request", backgroundThreadObject);
[[self.objectStore managedObjectContextForCurrentThread] deleteObject:backgroundThreadObject];
}
@@ -175,8 +175,8 @@
BOOL success = [self.objectStore save:&error];
if (! success) {
RKLogError(@"Failed to save managed object context after mapping completed: %@", [error localizedDescription]);
NSMethodSignature* signature = [(NSObject *)self methodSignatureForSelector:@selector(informDelegateOfError:)];
RKManagedObjectThreadSafeInvocation* invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
NSMethodSignature *signature = [(NSObject *)self methodSignatureForSelector:@selector(informDelegateOfError:)];
RKManagedObjectThreadSafeInvocation *invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
[invocation setTarget:self];
[invocation setSelector:@selector(informDelegateOfError:)];
[invocation setArgument:&error atIndex:2];
@@ -189,9 +189,9 @@
}
}
NSDictionary* dictionary = [result asDictionary];
NSMethodSignature* signature = [self methodSignatureForSelector:@selector(informDelegateOfObjectLoadWithResultDictionary:)];
RKManagedObjectThreadSafeInvocation* invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
NSDictionary *dictionary = [result asDictionary];
NSMethodSignature *signature = [self methodSignatureForSelector:@selector(informDelegateOfObjectLoadWithResultDictionary:)];
RKManagedObjectThreadSafeInvocation *invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
[invocation setObjectStore:self.objectStore];
[invocation setTarget:self];
[invocation setSelector:@selector(informDelegateOfObjectLoadWithResultDictionary:)];
@@ -208,7 +208,7 @@
if (_targetObjectID) {
if (_deleteObjectOnFailure) {
RKLogInfo(@"Error response encountered: Deleting existing managed object with ID: %@", _targetObjectID);
NSManagedObject* objectToDelete = [self.objectStore objectWithID:_targetObjectID];
NSManagedObject *objectToDelete = [self.objectStore objectWithID:_targetObjectID];
if (objectToDelete) {
[[self.objectStore managedObjectContextForCurrentThread] deleteObject:objectToDelete];
[self.objectStore save:nil];
@@ -224,7 +224,7 @@
- (BOOL)isResponseMappable
{
if ([self.response wasLoadedFromCache]) {
NSArray* cachedObjects = [self cachedObjects];
NSArray *cachedObjects = [self cachedObjects];
if (! cachedObjects) {
RKLogDebug(@"Skipping managed object mapping optimization -> Managed object cache returned nil cachedObjects for resourcePath: %@", self.resourcePath);
return [super isResponseMappable];

View File

@@ -48,18 +48,18 @@
return [self mappingForEntityWithName:NSStringFromClass(objectClass) inManagedObjectStore:objectStore];
}
+ (RKManagedObjectMapping *)mappingForEntity:(NSEntityDescription*)entity inManagedObjectStore:(RKManagedObjectStore *)objectStore
+ (RKManagedObjectMapping *)mappingForEntity:(NSEntityDescription *)entity inManagedObjectStore:(RKManagedObjectStore *)objectStore
{
return [[[self alloc] initWithEntity:entity inManagedObjectStore:objectStore] autorelease];
}
+ (RKManagedObjectMapping *)mappingForEntityWithName:(NSString*)entityName inManagedObjectStore:(RKManagedObjectStore *)objectStore
+ (RKManagedObjectMapping *)mappingForEntityWithName:(NSString *)entityName inManagedObjectStore:(RKManagedObjectStore *)objectStore
{
return [self mappingForEntity:[NSEntityDescription entityForName:entityName inManagedObjectContext:objectStore.primaryManagedObjectContext]
inManagedObjectStore:objectStore];
}
- (id)initWithEntity:(NSEntityDescription*)entity inManagedObjectStore:(RKManagedObjectStore*)objectStore
- (id)initWithEntity:(NSEntityDescription *)entity inManagedObjectStore:(RKManagedObjectStore *)objectStore
{
NSAssert(entity, @"Cannot initialize an RKManagedObjectMapping without an entity. Maybe you want RKObjectMapping instead?");
NSAssert(objectStore, @"Object store cannot be nil");
@@ -98,23 +98,23 @@
[super dealloc];
}
- (NSDictionary*)relationshipsAndPrimaryKeyAttributes
- (NSDictionary *)relationshipsAndPrimaryKeyAttributes
{
return _relationshipToPrimaryKeyMappings;
}
- (void)connectRelationship:(NSString*)relationshipName withObjectForPrimaryKeyAttribute:(NSString*)primaryKeyAttribute
- (void)connectRelationship:(NSString *)relationshipName withObjectForPrimaryKeyAttribute:(NSString *)primaryKeyAttribute
{
NSAssert([_relationshipToPrimaryKeyMappings objectForKey:relationshipName] == nil, @"Cannot add connect relationship %@ by primary key, a mapping already exists.", relationshipName);
[_relationshipToPrimaryKeyMappings setObject:primaryKeyAttribute forKey:relationshipName];
}
- (void)connectRelationshipsWithObjectsForPrimaryKeyAttributes:(NSString*)firstRelationshipName, ...
- (void)connectRelationshipsWithObjectsForPrimaryKeyAttributes:(NSString *)firstRelationshipName, ...
{
va_list args;
va_start(args, firstRelationshipName);
for (NSString* relationshipName = firstRelationshipName; relationshipName != nil; relationshipName = va_arg(args, NSString*)) {
NSString* primaryKeyAttribute = va_arg(args, NSString*);
for (NSString *relationshipName = firstRelationshipName; relationshipName != nil; relationshipName = va_arg(args, NSString *)) {
NSString *primaryKeyAttribute = va_arg(args, NSString *);
NSAssert(primaryKeyAttribute != nil, @"Cannot connect a relationship without an attribute containing the primary key");
[self connectRelationship:relationshipName withObjectForPrimaryKeyAttribute:primaryKeyAttribute];
// TODO: Raise proper exception here, argument error...
@@ -122,23 +122,23 @@
va_end(args);
}
- (void)connectRelationship:(NSString*)relationshipName withObjectForPrimaryKeyAttribute:(NSString*)primaryKeyAttribute whenValueOfKeyPath:(NSString*)keyPath isEqualTo:(id)value
- (void)connectRelationship:(NSString *)relationshipName withObjectForPrimaryKeyAttribute:(NSString *)primaryKeyAttribute whenValueOfKeyPath:(NSString *)keyPath isEqualTo:(id)value
{
NSAssert([_relationshipToPrimaryKeyMappings objectForKey:relationshipName] == nil, @"Cannot add connect relationship %@ by primary key, a mapping already exists.", relationshipName);
RKDynamicObjectMappingMatcher* matcher = [[RKDynamicObjectMappingMatcher alloc] initWithKey:keyPath value:value primaryKeyAttribute:primaryKeyAttribute];
RKDynamicObjectMappingMatcher *matcher = [[RKDynamicObjectMappingMatcher alloc] initWithKey:keyPath value:value primaryKeyAttribute:primaryKeyAttribute];
[_relationshipToPrimaryKeyMappings setObject:matcher forKey:relationshipName];
[matcher release];
}
- (void)connectRelationship:(NSString*)relationshipName withObjectForPrimaryKeyAttribute:(NSString*)primaryKeyAttribute usingEvaluationBlock:(BOOL (^)(id data))block
- (void)connectRelationship:(NSString *)relationshipName withObjectForPrimaryKeyAttribute:(NSString *)primaryKeyAttribute usingEvaluationBlock:(BOOL (^)(id data))block
{
NSAssert([_relationshipToPrimaryKeyMappings objectForKey:relationshipName] == nil, @"Cannot add connect relationship %@ by primary key, a mapping already exists.", relationshipName);
RKDynamicObjectMappingMatcher* matcher = [[RKDynamicObjectMappingMatcher alloc] initWithPrimaryKeyAttribute:primaryKeyAttribute evaluationBlock:block];
RKDynamicObjectMappingMatcher *matcher = [[RKDynamicObjectMappingMatcher alloc] initWithPrimaryKeyAttribute:primaryKeyAttribute evaluationBlock:block];
[_relationshipToPrimaryKeyMappings setObject:matcher forKey:relationshipName];
[matcher release];
}
- (id)defaultValueForMissingAttribute:(NSString*)attributeName
- (id)defaultValueForMissingAttribute:(NSString *)attributeName
{
NSAttributeDescription *desc = [[self.entity attributesByName] valueForKey:attributeName];
return [desc defaultValue];
@@ -150,16 +150,16 @@
id object = nil;
id primaryKeyValue = nil;
NSString* primaryKeyAttribute;
NSString *primaryKeyAttribute;
NSEntityDescription* entity = [self entity];
RKObjectAttributeMapping* primaryKeyAttributeMapping = nil;
NSEntityDescription *entity = [self entity];
RKObjectAttributeMapping *primaryKeyAttributeMapping = nil;
primaryKeyAttribute = [self primaryKeyAttribute];
if (primaryKeyAttribute) {
// If a primary key has been set on the object mapping, find the attribute mapping
// so that we can extract any existing primary key from the mappable data
for (RKObjectAttributeMapping* attributeMapping in self.attributeMappings) {
for (RKObjectAttributeMapping *attributeMapping in self.attributeMappings) {
if ([attributeMapping.destinationKeyPath isEqualToString:primaryKeyAttribute]) {
primaryKeyAttributeMapping = attributeMapping;
break;
@@ -171,7 +171,7 @@
RKLogDebug(@"Detected use of nested dictionary key as primaryKey attribute...");
primaryKeyValue = [[mappableData allKeys] lastObject];
} else {
NSString* keyPathForPrimaryKeyElement = primaryKeyAttributeMapping.sourceKeyPath;
NSString *keyPathForPrimaryKeyElement = primaryKeyAttributeMapping.sourceKeyPath;
if (keyPathForPrimaryKeyElement) {
primaryKeyValue = [mappableData valueForKeyPath:keyPathForPrimaryKeyElement];
} else {
@@ -207,7 +207,7 @@
return object;
}
- (Class)classForProperty:(NSString*)propertyName
- (Class)classForProperty:(NSString *)propertyName
{
Class propertyClass = [super classForProperty:propertyName];
if (! propertyClass) {

View File

@@ -34,12 +34,12 @@
- (void)connectRelationship:(NSString *)relationshipName
{
NSDictionary* relationshipsAndPrimaryKeyAttributes = [(RKManagedObjectMapping*)self.objectMapping relationshipsAndPrimaryKeyAttributes];
NSDictionary *relationshipsAndPrimaryKeyAttributes = [(RKManagedObjectMapping *)self.objectMapping relationshipsAndPrimaryKeyAttributes];
id primaryKeyObject = [relationshipsAndPrimaryKeyAttributes objectForKey:relationshipName];
NSString* primaryKeyAttribute = nil;
NSString *primaryKeyAttribute = nil;
if ([primaryKeyObject isKindOfClass:[RKDynamicObjectMappingMatcher class]]) {
RKLogTrace(@"Found a dynamic matcher attempting to connect relationshipName: %@", relationshipName);
RKDynamicObjectMappingMatcher* matcher = (RKDynamicObjectMappingMatcher*)primaryKeyObject;
RKDynamicObjectMappingMatcher *matcher = (RKDynamicObjectMappingMatcher *)primaryKeyObject;
if ([matcher isMatchForData:self.destinationObject]) {
primaryKeyAttribute = matcher.primaryKeyAttribute;
RKLogTrace(@"Dynamic matched succeeded. Proceeding to connect relationshipName '%@' using primaryKeyAttribute '%@'", relationshipName, primaryKeyAttribute);
@@ -48,11 +48,11 @@
return;
}
} else if ([primaryKeyObject isKindOfClass:[NSString class]]) {
primaryKeyAttribute = (NSString*)primaryKeyObject;
primaryKeyAttribute = (NSString *)primaryKeyObject;
}
NSAssert(primaryKeyAttribute, @"Cannot connect relationship without primaryKeyAttribute");
RKObjectRelationshipMapping* relationshipMapping = [self.objectMapping mappingForRelationship:relationshipName];
RKObjectRelationshipMapping *relationshipMapping = [self.objectMapping mappingForRelationship:relationshipName];
RKObjectMappingDefinition *mapping = relationshipMapping.mapping;
NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined.");
if (! [mapping isKindOfClass:[RKObjectMapping class]]) {
@@ -63,7 +63,7 @@
NSAssert(relationshipMapping, @"Unable to find relationship mapping '%@' to connect by primaryKey", relationshipName);
NSAssert([relationshipMapping isKindOfClass:[RKObjectRelationshipMapping class]], @"Expected mapping for %@ to be a relationship mapping", relationshipName);
NSAssert([relationshipMapping.mapping isKindOfClass:[RKManagedObjectMapping class]], @"Can only connect RKManagedObjectMapping relationships");
NSString* primaryKeyAttributeOfRelatedObject = [(RKManagedObjectMapping*)objectMapping primaryKeyAttribute];
NSString *primaryKeyAttributeOfRelatedObject = [(RKManagedObjectMapping *)objectMapping primaryKeyAttribute];
NSAssert(primaryKeyAttributeOfRelatedObject, @"Cannot connect relationship: mapping for %@ has no primary key attribute specified", NSStringFromClass(objectMapping.objectClass));
id valueOfLocalPrimaryKeyAttribute = [self.destinationObject valueForKey:primaryKeyAttribute];
if (valueOfLocalPrimaryKeyAttribute) {
@@ -73,9 +73,9 @@
// Implemented for issue 284 - https://github.com/RestKit/RestKit/issues/284
relatedObject = [NSMutableSet set];
NSObject<RKManagedObjectCaching> *cache = [[(RKManagedObjectMapping*)[self objectMapping] objectStore] cacheStrategy];
NSObject<RKManagedObjectCaching> *cache = [[(RKManagedObjectMapping *)[self objectMapping] objectStore] cacheStrategy];
for (id foreignKey in valueOfLocalPrimaryKeyAttribute) {
id searchResult = [cache findInstanceOfEntity:objectMapping.entity withPrimaryKeyAttribute:primaryKeyAttributeOfRelatedObject value:foreignKey inManagedObjectContext:[[(RKManagedObjectMapping*)[self objectMapping] objectStore] managedObjectContextForCurrentThread]];
id searchResult = [cache findInstanceOfEntity:objectMapping.entity withPrimaryKeyAttribute:primaryKeyAttributeOfRelatedObject value:foreignKey inManagedObjectContext:[[(RKManagedObjectMapping *)[self objectMapping] objectStore] managedObjectContextForCurrentThread]];
if (searchResult) {
[relatedObject addObject:searchResult];
}
@@ -84,7 +84,7 @@
RKLogTrace(@"Connecting has-one relationship at keyPath '%@' to object with primaryKey attribute '%@'", relationshipName, primaryKeyAttributeOfRelatedObject);
// Normal foreign key
NSObject<RKManagedObjectCaching> *cache = [[(RKManagedObjectMapping*)[self objectMapping] objectStore] cacheStrategy];
NSObject<RKManagedObjectCaching> *cache = [[(RKManagedObjectMapping *)[self objectMapping] objectStore] cacheStrategy];
relatedObject = [cache findInstanceOfEntity:objectMapping.entity withPrimaryKeyAttribute:primaryKeyAttributeOfRelatedObject value:valueOfLocalPrimaryKeyAttribute inManagedObjectContext:[self.destinationObject managedObjectContext]];
}
if (relatedObject) {
@@ -105,9 +105,9 @@
- (void)connectRelationships
{
NSDictionary* relationshipsAndPrimaryKeyAttributes = [(RKManagedObjectMapping *)self.objectMapping relationshipsAndPrimaryKeyAttributes];
NSDictionary *relationshipsAndPrimaryKeyAttributes = [(RKManagedObjectMapping *)self.objectMapping relationshipsAndPrimaryKeyAttributes];
RKLogTrace(@"relationshipsAndPrimaryKeyAttributes: %@", relationshipsAndPrimaryKeyAttributes);
for (NSString* relationshipName in relationshipsAndPrimaryKeyAttributes) {
for (NSString *relationshipName in relationshipsAndPrimaryKeyAttributes) {
if (self.queue) {
RKLogTrace(@"Enqueueing relationship connection using operation queue");
__block RKManagedObjectMappingOperation *selfRef = self;

View File

@@ -40,12 +40,12 @@
* Normalize and tokenize the provided string into an NSArray.
* Note that returned value may contain entries of empty strings.
*/
+ (NSArray*)tokenizedNormalizedString:(NSString*)string;
+ (NSArray *)tokenizedNormalizedString:(NSString *)string;
/**
* Generate a predicate for the supplied search term against
* searchableAttributes (defined for an RKSearchableManagedObject)
*/
- (NSPredicate*)predicateForSearch:(NSString*)searchText;
- (NSPredicate *)predicateForSearch:(NSString *)searchText;
@end

View File

@@ -28,13 +28,13 @@
@implementation RKManagedObjectSearchEngine
static NSMutableCharacterSet* __removeSet;
static NSMutableCharacterSet *__removeSet;
@synthesize mode = _mode;
+ (id)searchEngine
{
RKManagedObjectSearchEngine* searchEngine = [[[RKManagedObjectSearchEngine alloc] init] autorelease];
RKManagedObjectSearchEngine *searchEngine = [[[RKManagedObjectSearchEngine alloc] init] autorelease];
return searchEngine;
}
@@ -50,10 +50,10 @@ static NSMutableCharacterSet* __removeSet;
#pragma mark -
#pragma mark Private
- (NSPredicate*)predicateForSearch:(NSArray*)searchTerms compoundSelector:(SEL)selector
- (NSPredicate *)predicateForSearch:(NSArray *)searchTerms compoundSelector:(SEL)selector
{
NSMutableArray* termPredicates = [NSMutableArray array];
for (NSString* searchTerm in searchTerms) {
NSMutableArray *termPredicates = [NSMutableArray array];
for (NSString *searchTerm in searchTerms) {
[termPredicates addObject:
[NSPredicate predicateWithFormat:@"(ANY searchWords.word beginswith %@)", searchTerm]];
}
@@ -63,28 +63,28 @@ static NSMutableCharacterSet* __removeSet;
#pragma mark -
#pragma mark Public
+ (NSArray*)tokenizedNormalizedString:(NSString*)string
+ (NSArray *)tokenizedNormalizedString:(NSString *)string
{
if (__removeSet == nil) {
NSMutableCharacterSet* removeSet = [[NSCharacterSet alphanumericCharacterSet] mutableCopy];
NSMutableCharacterSet *removeSet = [[NSCharacterSet alphanumericCharacterSet] mutableCopy];
[removeSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
[removeSet invert];
__removeSet = removeSet;
}
NSString* scannerString = [[[[string lowercaseString] decomposedStringWithCanonicalMapping]
NSString *scannerString = [[[[string lowercaseString] decomposedStringWithCanonicalMapping]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
stringByReplacingOccurrencesOfString:@"-" withString:@" "];
NSArray* tokens = [[[scannerString componentsSeparatedByCharactersInSet:__removeSet]
NSArray *tokens = [[[scannerString componentsSeparatedByCharactersInSet:__removeSet]
componentsJoinedByString:@""] componentsSeparatedByString:@" "];
return tokens;
}
- (NSPredicate*)predicateForSearch:(NSString*)searchText
- (NSPredicate *)predicateForSearch:(NSString *)searchText
{
NSString* searchQuery = [searchText copy];
NSArray* searchTerms = [RKManagedObjectSearchEngine tokenizedNormalizedString:searchQuery];
NSString *searchQuery = [searchText copy];
NSArray *searchTerms = [RKManagedObjectSearchEngine tokenizedNormalizedString:searchQuery];
[searchQuery release];
if ([searchTerms count] == 0) {

View File

@@ -21,13 +21,13 @@
#import "ObjectMapping.h"
// The default seed database filename. Used when the object store has not been initialized
extern NSString* const RKDefaultSeedDatabaseFileName;
extern NSString * const RKDefaultSeedDatabaseFileName;
@protocol RKManagedObjectSeederDelegate
@required
// Invoked when the seeder creates a new object
- (void)didSeedObject:(NSManagedObject*)object fromFile:(NSString*)fileName;
- (void)didSeedObject:(NSManagedObject *)object fromFile:(NSString *)fileName;
@end
/**
@@ -39,36 +39,36 @@ extern NSString* const RKDefaultSeedDatabaseFileName;
* data immediately available for use within Core Data.
*/
@interface RKManagedObjectSeeder : NSObject {
RKObjectManager* _manager;
NSObject<RKManagedObjectSeederDelegate>* _delegate;
RKObjectManager *_manager;
NSObject<RKManagedObjectSeederDelegate> *_delegate;
}
// Delegate for seeding operations
@property (nonatomic, assign) NSObject<RKManagedObjectSeederDelegate>* delegate;
@property (nonatomic, assign) NSObject<RKManagedObjectSeederDelegate> *delegate;
// Path to the generated seed database on disk
@property (nonatomic, readonly) NSString* pathToSeedDatabase;
@property (nonatomic, readonly) NSString *pathToSeedDatabase;
/**
* Generates a seed database using an object manager and a null terminated list of files. Exits
* the seeding process and outputs an informational message
*/
+ (void)generateSeedDatabaseWithObjectManager:(RKObjectManager*)objectManager fromFiles:(NSString*)fileName, ...;
+ (void)generateSeedDatabaseWithObjectManager:(RKObjectManager *)objectManager fromFiles:(NSString *)fileName, ...;
/**
* Returns an object seeder ready to begin seeding. Requires a fully configured instance of an object manager.
*/
+ (RKManagedObjectSeeder*)objectSeederWithObjectManager:(RKObjectManager*)objectManager;
+ (RKManagedObjectSeeder *)objectSeederWithObjectManager:(RKObjectManager *)objectManager;
/**
* Seed the database with objects from the specified file(s). The list must be terminated by nil
*/
- (void)seedObjectsFromFiles:(NSString*)fileName, ...;
- (void)seedObjectsFromFiles:(NSString *)fileName, ...;
/**
* Seed the database with objects from the specified file using the supplied object mapping.
*/
- (void)seedObjectsFromFile:(NSString*)fileName withObjectMapping:(RKObjectMapping*)nilOrObjectMapping;
- (void)seedObjectsFromFile:(NSString *)fileName withObjectMapping:(RKObjectMapping *)nilOrObjectMapping;
/**
* Seed the database with objects from the specified file, from the specified bundle, using the supplied object mapping.

View File

@@ -32,42 +32,42 @@
#define RKLogComponent lcl_cRestKitCoreData
@interface RKManagedObjectSeeder (Private)
- (id)initWithObjectManager:(RKObjectManager*)manager;
- (void)seedObjectsFromFileNames:(NSArray*)fileNames;
- (id)initWithObjectManager:(RKObjectManager *)manager;
- (void)seedObjectsFromFileNames:(NSArray *)fileNames;
@end
NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
NSString * const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
@implementation RKManagedObjectSeeder
@synthesize delegate = _delegate;
+ (void)generateSeedDatabaseWithObjectManager:(RKObjectManager*)objectManager fromFiles:(NSString*)firstFileName, ...
+ (void)generateSeedDatabaseWithObjectManager:(RKObjectManager *)objectManager fromFiles:(NSString *)firstFileName, ...
{
RKManagedObjectSeeder* seeder = [RKManagedObjectSeeder objectSeederWithObjectManager:objectManager];
RKManagedObjectSeeder *seeder = [RKManagedObjectSeeder objectSeederWithObjectManager:objectManager];
va_list args;
va_start(args, firstFileName);
NSMutableArray* fileNames = [NSMutableArray array];
for (NSString* fileName = firstFileName; fileName != nil; fileName = va_arg(args, id)) {
NSMutableArray *fileNames = [NSMutableArray array];
for (NSString *fileName = firstFileName; fileName != nil; fileName = va_arg(args, id)) {
[fileNames addObject:fileName];
}
va_end(args);
// Seed the files
for (NSString* fileName in fileNames) {
for (NSString *fileName in fileNames) {
[seeder seedObjectsFromFile:fileName withObjectMapping:nil];
}
[seeder finalizeSeedingAndExit];
}
+ (RKManagedObjectSeeder*)objectSeederWithObjectManager:(RKObjectManager*)objectManager
+ (RKManagedObjectSeeder *)objectSeederWithObjectManager:(RKObjectManager *)objectManager
{
return [[[RKManagedObjectSeeder alloc] initWithObjectManager:objectManager] autorelease];
}
- (id)initWithObjectManager:(RKObjectManager*)manager
- (id)initWithObjectManager:(RKObjectManager *)manager
{
self = [self init];
if (self) {
@@ -91,44 +91,44 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
[super dealloc];
}
- (NSString*)pathToSeedDatabase
- (NSString *)pathToSeedDatabase
{
return _manager.objectStore.pathToStoreFile;
}
- (void)seedObjectsFromFiles:(NSString*)firstFileName, ...
- (void)seedObjectsFromFiles:(NSString *)firstFileName, ...
{
va_list args;
va_start(args, firstFileName);
NSMutableArray* fileNames = [NSMutableArray array];
for (NSString* fileName = firstFileName; fileName != nil; fileName = va_arg(args, id)) {
NSMutableArray *fileNames = [NSMutableArray array];
for (NSString *fileName = firstFileName; fileName != nil; fileName = va_arg(args, id)) {
[fileNames addObject:fileName];
}
va_end(args);
for (NSString* fileName in fileNames) {
for (NSString *fileName in fileNames) {
[self seedObjectsFromFile:fileName withObjectMapping:nil];
}
}
- (void)seedObjectsFromFile:(NSString*)fileName withObjectMapping:(RKObjectMapping *)nilOrObjectMapping
- (void)seedObjectsFromFile:(NSString *)fileName withObjectMapping:(RKObjectMapping *)nilOrObjectMapping
{
[self seedObjectsFromFile:fileName withObjectMapping:nilOrObjectMapping bundle:nil];
}
- (void)seedObjectsFromFile:(NSString *)fileName withObjectMapping:(RKObjectMapping *)nilOrObjectMapping bundle:(NSBundle *)nilOrBundle
{
NSError* error = nil;
NSError *error = nil;
if (nilOrBundle == nil) {
nilOrBundle = [NSBundle mainBundle];
}
NSString* filePath = [nilOrBundle pathForResource:fileName ofType:nil];
NSString* payload = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];
NSString *filePath = [nilOrBundle pathForResource:fileName ofType:nil];
NSString *payload = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];
if (payload) {
NSString* MIMEType = [fileName MIMETypeForPathExtension];
NSString *MIMEType = [fileName MIMETypeForPathExtension];
if (MIMEType == nil) {
// Default the MIME type to the value of the Accept header if we couldn't detect it...
MIMEType = _manager.acceptMIMEType;
@@ -138,7 +138,7 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
id parsedData = [parser objectFromString:payload error:&error];
NSAssert(parsedData, @"Cannot perform object load without data for mapping");
RKObjectMappingProvider* mappingProvider = nil;
RKObjectMappingProvider *mappingProvider = nil;
if (nilOrObjectMapping) {
mappingProvider = [[RKObjectMappingProvider new] autorelease];
[mappingProvider setMapping:nilOrObjectMapping forKeyPath:@""];
@@ -146,19 +146,19 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
mappingProvider = _manager.mappingProvider;
}
RKObjectMapper* mapper = [RKObjectMapper mapperWithObject:parsedData mappingProvider:mappingProvider];
RKObjectMappingResult* result = [mapper performMapping];
RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:parsedData mappingProvider:mappingProvider];
RKObjectMappingResult *result = [mapper performMapping];
if (result == nil) {
RKLogError(@"Database seeding from file '%@' failed due to object mapping errors: %@", fileName, mapper.errors);
return;
}
NSArray* mappedObjects = [result asCollection];
NSArray *mappedObjects = [result asCollection];
NSAssert1([mappedObjects isKindOfClass:[NSArray class]], @"Expected an NSArray of objects, got %@", mappedObjects);
// Inform the delegate
if (self.delegate) {
for (NSManagedObject* object in mappedObjects) {
for (NSManagedObject *object in mappedObjects) {
[self.delegate didSeedObject:object fromFile:fileName];
}
}
@@ -177,10 +177,10 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite";
RKLogError(@"[RestKit] RKManagedObjectSeeder: Error saving object context: %@", [error localizedDescription]);
}
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString* storeFileName = [[_manager objectStore] storeFilename];
NSString* destinationPath = [basePath stringByAppendingPathComponent:storeFileName];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString *storeFileName = [[_manager objectStore] storeFilename];
NSString *destinationPath = [basePath stringByAppendingPathComponent:storeFileName];
RKLogInfo(@"A seeded database has been generated at '%@'. "
@"Please execute `open \"%@\"` in your Terminal and copy %@ to your app. Be sure to add the seed database to your \"Copy Resources\" build phase.",
destinationPath, basePath, storeFileName);

View File

@@ -27,7 +27,7 @@
/**
* Notifications
*/
extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
extern NSString * const RKManagedObjectStoreDidFailSaveNotification;
///////////////////////////////////////////////////////////////////
@@ -47,25 +47,25 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
///////////////////////////////////////////////////////////////////
@interface RKManagedObjectStore : NSObject {
NSObject<RKManagedObjectStoreDelegate>* _delegate;
NSString* _storeFilename;
NSString* _pathToStoreFile;
NSManagedObjectModel* _managedObjectModel;
NSPersistentStoreCoordinator* _persistentStoreCoordinator;
NSObject<RKManagedObjectStoreDelegate> *_delegate;
NSString *_storeFilename;
NSString *_pathToStoreFile;
NSManagedObjectModel *_managedObjectModel;
NSPersistentStoreCoordinator *_persistentStoreCoordinator;
}
// The delegate for this object store
@property (nonatomic, assign) NSObject<RKManagedObjectStoreDelegate>* delegate;
@property (nonatomic, assign) NSObject<RKManagedObjectStoreDelegate> *delegate;
// The filename of the database backing this object store
@property (nonatomic, readonly) NSString* storeFilename;
@property (nonatomic, readonly) NSString *storeFilename;
// The full path to the database backing this object store
@property (nonatomic, readonly) NSString* pathToStoreFile;
@property (nonatomic, readonly) NSString *pathToStoreFile;
// Core Data
@property (nonatomic, readonly) NSManagedObjectModel* managedObjectModel;
@property (nonatomic, readonly) NSPersistentStoreCoordinator* persistentStoreCoordinator;
@property (nonatomic, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
///-----------------------------------------------------------------------------
/// @name Accessing the Default Object Store
@@ -105,7 +105,7 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
/**
* Initialize a new managed object store with a SQLite database with the filename specified
*/
+ (RKManagedObjectStore*)objectStoreWithStoreFilename:(NSString*)storeFilename;
+ (RKManagedObjectStore *)objectStoreWithStoreFilename:(NSString *)storeFilename;
/**
* Initialize a new managed object store backed by a SQLite database with the specified filename.
@@ -113,7 +113,7 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
* copying the seed database from the main bundle. If the managed object model provided is nil,
* all models will be merged from the main bundle for you.
*/
+ (RKManagedObjectStore*)objectStoreWithStoreFilename:(NSString *)storeFilename usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel*)nilOrManagedObjectModel delegate:(id)delegate;
+ (RKManagedObjectStore *)objectStoreWithStoreFilename:(NSString *)storeFilename usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel *)nilOrManagedObjectModel delegate:(id)delegate;
/**
* Initialize a new managed object store backed by a SQLite database with the specified filename,
@@ -122,13 +122,13 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
* the store by copying the seed database from the main bundle. If the managed object model
* provided is nil, all models will be merged from the main bundle for you.
*/
+ (RKManagedObjectStore*)objectStoreWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)directory usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel*)nilOrManagedObjectModel delegate:(id)delegate;
+ (RKManagedObjectStore *)objectStoreWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)directory usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel *)nilOrManagedObjectModel delegate:(id)delegate;
/**
* Initialize a new managed object store with a SQLite database with the filename specified
* @deprecated
*/
- (id)initWithStoreFilename:(NSString*)storeFilename DEPRECATED_ATTRIBUTE;
- (id)initWithStoreFilename:(NSString *)storeFilename DEPRECATED_ATTRIBUTE;
/**
* Save the current contents of the managed object store
@@ -145,13 +145,13 @@ extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
/**
* Retrieves a model object from the appropriate context using the objectId
*/
- (NSManagedObject*)objectWithID:(NSManagedObjectID*)objectID;
- (NSManagedObject *)objectWithID:(NSManagedObjectID *)objectID;
/**
* Retrieves a array of model objects from the appropriate context using
* an array of NSManagedObjectIDs
*/
- (NSArray*)objectsWithIDs:(NSArray*)objectIDs;
- (NSArray *)objectsWithIDs:(NSArray *)objectIDs;
///-----------------------------------------------------------------------------
/// @name Retrieving Managed Object Contexts

View File

@@ -35,19 +35,19 @@
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
NSString* const RKManagedObjectStoreDidFailSaveNotification = @"RKManagedObjectStoreDidFailSaveNotification";
static NSString* const RKManagedObjectStoreThreadDictionaryContextKey = @"RKManagedObjectStoreThreadDictionaryContextKey";
static NSString* const RKManagedObjectStoreThreadDictionaryEntityCacheKey = @"RKManagedObjectStoreThreadDictionaryEntityCacheKey";
NSString * const RKManagedObjectStoreDidFailSaveNotification = @"RKManagedObjectStoreDidFailSaveNotification";
static NSString * const RKManagedObjectStoreThreadDictionaryContextKey = @"RKManagedObjectStoreThreadDictionaryContextKey";
static NSString * const RKManagedObjectStoreThreadDictionaryEntityCacheKey = @"RKManagedObjectStoreThreadDictionaryEntityCacheKey";
static RKManagedObjectStore *defaultObjectStore = nil;
@interface RKManagedObjectStore ()
@property (nonatomic, retain, readwrite) NSManagedObjectContext *primaryManagedObjectContext;
- (id)initWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)nilOrDirectoryPath usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel*)nilOrManagedObjectModel delegate:(id)delegate;
- (id)initWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)nilOrDirectoryPath usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel *)nilOrManagedObjectModel delegate:(id)delegate;
- (void)createPersistentStoreCoordinator;
- (void)createStoreIfNecessaryUsingSeedDatabase:(NSString*)seedDatabase;
- (NSManagedObjectContext*)newManagedObjectContext;
- (void)createStoreIfNecessaryUsingSeedDatabase:(NSString *)seedDatabase;
- (NSManagedObjectContext *)newManagedObjectContext;
@end
@implementation RKManagedObjectStore
@@ -76,8 +76,8 @@ static RKManagedObjectStore *defaultObjectStore = nil;
+ (void)deleteStoreAtPath:(NSString *)path
{
NSURL* storeURL = [NSURL fileURLWithPath:path];
NSError* error = nil;
NSURL *storeURL = [NSURL fileURLWithPath:path];
NSError *error = nil;
if ([[NSFileManager defaultManager] fileExistsAtPath:storeURL.path]) {
if (! [[NSFileManager defaultManager] removeItemAtPath:storeURL.path error:&error]) {
NSAssert(NO, @"Managed object store failed to delete persistent store : %@", error);
@@ -93,27 +93,27 @@ static RKManagedObjectStore *defaultObjectStore = nil;
[self deleteStoreAtPath:path];
}
+ (RKManagedObjectStore*)objectStoreWithStoreFilename:(NSString*)storeFilename
+ (RKManagedObjectStore *)objectStoreWithStoreFilename:(NSString *)storeFilename
{
return [self objectStoreWithStoreFilename:storeFilename usingSeedDatabaseName:nil managedObjectModel:nil delegate:nil];
}
+ (RKManagedObjectStore*)objectStoreWithStoreFilename:(NSString *)storeFilename usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel*)nilOrManagedObjectModel delegate:(id)delegate
+ (RKManagedObjectStore *)objectStoreWithStoreFilename:(NSString *)storeFilename usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel *)nilOrManagedObjectModel delegate:(id)delegate
{
return [[[self alloc] initWithStoreFilename:storeFilename inDirectory:nil usingSeedDatabaseName:nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:nilOrManagedObjectModel delegate:delegate] autorelease];
}
+ (RKManagedObjectStore*)objectStoreWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)directory usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel*)nilOrManagedObjectModel delegate:(id)delegate
+ (RKManagedObjectStore *)objectStoreWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)directory usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel *)nilOrManagedObjectModel delegate:(id)delegate
{
return [[[self alloc] initWithStoreFilename:storeFilename inDirectory:directory usingSeedDatabaseName:nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:nilOrManagedObjectModel delegate:delegate] autorelease];
}
- (id)initWithStoreFilename:(NSString*)storeFilename
- (id)initWithStoreFilename:(NSString *)storeFilename
{
return [self initWithStoreFilename:storeFilename inDirectory:nil usingSeedDatabaseName:nil managedObjectModel:nil delegate:nil];
}
- (id)initWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)nilOrDirectoryPath usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel*)nilOrManagedObjectModel delegate:(id)delegate
- (id)initWithStoreFilename:(NSString *)storeFilename inDirectory:(NSString *)nilOrDirectoryPath usingSeedDatabaseName:(NSString *)nilOrNameOfSeedDatabaseInMainBundle managedObjectModel:(NSManagedObjectModel *)nilOrManagedObjectModel delegate:(id)delegate
{
self = [self init];
if (self) {
@@ -134,7 +134,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
// NOTE: allBundles permits Core Data setup in unit tests
nilOrManagedObjectModel = [NSManagedObjectModel mergedModelFromBundles:[NSBundle allBundles]];
}
NSMutableArray* allManagedObjectModels = [NSMutableArray arrayWithObject:nilOrManagedObjectModel];
NSMutableArray *allManagedObjectModels = [NSMutableArray arrayWithObject:nilOrManagedObjectModel];
_managedObjectModel = [[NSManagedObjectModel modelByMergingModels:allManagedObjectModels] retain];
_delegate = delegate;
@@ -161,7 +161,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
- (void)setThreadLocalObject:(id)value forKey:(id)key
{
NSMutableDictionary* threadDictionary = [[NSThread currentThread] threadDictionary];
NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
NSString *objectStoreKey = [NSString stringWithFormat:@"RKManagedObjectStore_%p", self];
if (! [threadDictionary valueForKey:objectStoreKey]) {
[threadDictionary setValue:[NSMutableDictionary dictionary] forKey:objectStoreKey];
@@ -172,7 +172,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
- (id)threadLocalObjectForKey:(id)key
{
NSMutableDictionary* threadDictionary = [[NSThread currentThread] threadDictionary];
NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
NSString *objectStoreKey = [NSString stringWithFormat:@"RKManagedObjectStore_%p", self];
if (! [threadDictionary valueForKey:objectStoreKey]) {
[threadDictionary setObject:[NSMutableDictionary dictionary] forKey:objectStoreKey];
@@ -183,7 +183,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
- (void)removeThreadLocalObjectForKey:(id)key
{
NSMutableDictionary* threadDictionary = [[NSThread currentThread] threadDictionary];
NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
NSString *objectStoreKey = [NSString stringWithFormat:@"RKManagedObjectStore_%p", self];
if (! [threadDictionary valueForKey:objectStoreKey]) {
[threadDictionary setObject:[NSMutableDictionary dictionary] forKey:objectStoreKey];
@@ -232,7 +232,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
*/
- (BOOL)save:(NSError **)error
{
NSManagedObjectContext* moc = [self managedObjectContextForCurrentThread];
NSManagedObjectContext *moc = [self managedObjectContextForCurrentThread];
NSError *localError = nil;
@try {
@@ -241,7 +241,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
[self.delegate managedObjectStore:self didFailToSaveContext:moc error:localError exception:nil];
}
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:localError forKey:@"error"];
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:localError forKey:@"error"];
[[NSNotificationCenter defaultCenter] postNotificationName:RKManagedObjectStoreDidFailSaveNotification object:self userInfo:userInfo];
if ([[localError domain] isEqualToString:@"NSCocoaErrorDomain"]) {
@@ -281,7 +281,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
return NO;
}
}
@catch (NSException* e) {
@catch (NSException *e) {
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(managedObjectStore:didFailToSaveContext:error:exception:)]) {
[self.delegate managedObjectStore:self didFailToSaveContext:moc error:nil exception:e];
}
@@ -304,14 +304,14 @@ static RKManagedObjectStore *defaultObjectStore = nil;
return managedObjectContext;
}
- (void)createStoreIfNecessaryUsingSeedDatabase:(NSString*)seedDatabase
- (void)createStoreIfNecessaryUsingSeedDatabase:(NSString *)seedDatabase
{
if (NO == [[NSFileManager defaultManager] fileExistsAtPath:self.pathToStoreFile]) {
NSString* seedDatabasePath = [[NSBundle mainBundle] pathForResource:seedDatabase ofType:nil];
NSString *seedDatabasePath = [[NSBundle mainBundle] pathForResource:seedDatabase ofType:nil];
NSAssert1(seedDatabasePath, @"Unable to find seed database file '%@' in the Main Bundle, aborting...", seedDatabase);
RKLogInfo(@"No existing database found, copying from seed path '%@'", seedDatabasePath);
NSError* error;
NSError *error;
if (![[NSFileManager defaultManager] copyItemAtPath:seedDatabasePath toPath:self.pathToStoreFile error:&error]) {
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(managedObjectStore:didFailToCopySeedDatabase:error:)]) {
[self.delegate managedObjectStore:self didFailToCopySeedDatabase:seedDatabase error:error];
@@ -348,8 +348,8 @@ static RKManagedObjectStore *defaultObjectStore = nil;
- (void)deletePersistentStoreUsingSeedDatabaseName:(NSString *)seedFile
{
NSURL* storeURL = [NSURL fileURLWithPath:self.pathToStoreFile];
NSError* error = nil;
NSURL *storeURL = [NSURL fileURLWithPath:self.pathToStoreFile];
NSError *error = nil;
if ([[NSFileManager defaultManager] fileExistsAtPath:storeURL.path]) {
if (![[NSFileManager defaultManager] removeItemAtPath:storeURL.path error:&error]) {
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(managedObjectStore:didFailToDeletePersistentStore:error:)]) {
@@ -388,7 +388,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
}
// Background threads leverage thread-local storage
NSManagedObjectContext* managedObjectContext = [self threadLocalObjectForKey:RKManagedObjectStoreThreadDictionaryContextKey];
NSManagedObjectContext *managedObjectContext = [self threadLocalObjectForKey:RKManagedObjectStoreThreadDictionaryContextKey];
if (!managedObjectContext) {
managedObjectContext = [self newManagedObjectContext];
@@ -406,7 +406,7 @@ static RKManagedObjectStore *defaultObjectStore = nil;
return managedObjectContext;
}
- (void)mergeChangesOnMainThreadWithNotification:(NSNotification*)notification
- (void)mergeChangesOnMainThreadWithNotification:(NSNotification *)notification
{
assert([NSThread isMainThread]);
[self.primaryManagedObjectContext performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:)
@@ -423,19 +423,19 @@ static RKManagedObjectStore *defaultObjectStore = nil;
#pragma mark -
#pragma mark Helpers
- (NSManagedObject*)objectWithID:(NSManagedObjectID *)objectID
- (NSManagedObject *)objectWithID:(NSManagedObjectID *)objectID
{
NSAssert(objectID, @"Cannot fetch a managedObject with a nil objectID");
return [[self managedObjectContextForCurrentThread] objectWithID:objectID];
}
- (NSArray*)objectsWithIDs:(NSArray*)objectIDs
- (NSArray *)objectsWithIDs:(NSArray *)objectIDs
{
NSMutableArray* objects = [[NSMutableArray alloc] init];
for (NSManagedObjectID* objectID in objectIDs) {
NSMutableArray *objects = [[NSMutableArray alloc] init];
for (NSManagedObjectID *objectID in objectIDs) {
[objects addObject:[self objectWithID:objectID]];
}
NSArray* objectArray = [NSArray arrayWithArray:objects];
NSArray *objectArray = [NSArray arrayWithArray:objects];
[objects release];
return objectArray;

View File

@@ -21,18 +21,18 @@
#import "RKManagedObjectStore.h"
@interface RKManagedObjectThreadSafeInvocation : NSInvocation {
NSMutableDictionary* _argumentKeyPaths;
RKManagedObjectStore* _objectStore;
NSMutableDictionary *_argumentKeyPaths;
RKManagedObjectStore *_objectStore;
}
@property (nonatomic, retain) RKManagedObjectStore* objectStore;
@property (nonatomic, retain) RKManagedObjectStore *objectStore;
+ (RKManagedObjectThreadSafeInvocation*)invocationWithMethodSignature:(NSMethodSignature*)methodSignature;
- (void)setManagedObjectKeyPaths:(NSSet*)keyPaths forArgument:(NSInteger)index;
+ (RKManagedObjectThreadSafeInvocation *)invocationWithMethodSignature:(NSMethodSignature *)methodSignature;
- (void)setManagedObjectKeyPaths:(NSSet *)keyPaths forArgument:(NSInteger)index;
- (void)invokeOnMainThread;
// Private
- (void)serializeManagedObjectsForArgument:(id)argument withKeyPaths:(NSSet*)keyPaths;
- (void)deserializeManagedObjectIDsForArgument:(id)argument withKeyPaths:(NSSet*)keyPaths;
- (void)serializeManagedObjectsForArgument:(id)argument withKeyPaths:(NSSet *)keyPaths;
- (void)deserializeManagedObjectIDsForArgument:(id)argument withKeyPaths:(NSSet *)keyPaths;
@end

View File

@@ -24,18 +24,18 @@
@synthesize objectStore = _objectStore;
+ (RKManagedObjectThreadSafeInvocation*)invocationWithMethodSignature:(NSMethodSignature*)methodSignature
+ (RKManagedObjectThreadSafeInvocation *)invocationWithMethodSignature:(NSMethodSignature *)methodSignature
{
return (RKManagedObjectThreadSafeInvocation*) [super invocationWithMethodSignature:methodSignature];
return (RKManagedObjectThreadSafeInvocation *) [super invocationWithMethodSignature:methodSignature];
}
- (void)setManagedObjectKeyPaths:(NSSet*)keyPaths forArgument:(NSInteger)index
- (void)setManagedObjectKeyPaths:(NSSet *)keyPaths forArgument:(NSInteger)index
{
if (nil == _argumentKeyPaths) {
_argumentKeyPaths = [[NSMutableDictionary alloc] init];
}
NSNumber* argumentIndex = [NSNumber numberWithInteger:index];
NSNumber *argumentIndex = [NSNumber numberWithInteger:index];
[_argumentKeyPaths setObject:keyPaths forKey:argumentIndex];
}
@@ -52,18 +52,18 @@
}
}
- (void)serializeManagedObjectsForArgument:(id)argument withKeyPaths:(NSSet*)keyPaths
- (void)serializeManagedObjectsForArgument:(id)argument withKeyPaths:(NSSet *)keyPaths
{
for (NSString* keyPath in keyPaths) {
for (NSString *keyPath in keyPaths) {
id value = [argument valueForKeyPath:keyPath];
if ([value isKindOfClass:[NSManagedObject class]]) {
NSManagedObjectID *objectID = [(NSManagedObject*)value objectID];
NSManagedObjectID *objectID = [(NSManagedObject *)value objectID];
[self setValue:objectID forKeyPathOrKey:keyPath object:argument];
} else if ([value respondsToSelector:@selector(allObjects)]) {
id collection = [[[[[value class] alloc] init] autorelease] mutableCopy];
for (id subObject in value) {
if ([subObject isKindOfClass:[NSManagedObject class]]) {
[collection addObject:[(NSManagedObject*)subObject objectID]];
[collection addObject:[(NSManagedObject *)subObject objectID]];
} else {
[collection addObject:subObject];
}
@@ -75,13 +75,13 @@
}
}
- (void)deserializeManagedObjectIDsForArgument:(id)argument withKeyPaths:(NSSet*)keyPaths
- (void)deserializeManagedObjectIDsForArgument:(id)argument withKeyPaths:(NSSet *)keyPaths
{
for (NSString* keyPath in keyPaths) {
for (NSString *keyPath in keyPaths) {
id value = [argument valueForKeyPath:keyPath];
if ([value isKindOfClass:[NSManagedObjectID class]]) {
NSAssert(self.objectStore, @"Object store cannot be nil");
NSManagedObject* managedObject = [self.objectStore objectWithID:(NSManagedObjectID*)value];
NSManagedObject *managedObject = [self.objectStore objectWithID:(NSManagedObjectID *)value];
NSAssert(managedObject, @"Expected managed object for ID %@, got nil", value);
[self setValue:managedObject forKeyPathOrKey:keyPath object:argument];
} else if ([value respondsToSelector:@selector(allObjects)]) {
@@ -89,7 +89,7 @@
for (id subObject in value) {
if ([subObject isKindOfClass:[NSManagedObjectID class]]) {
NSAssert(self.objectStore, @"Object store cannot be nil");
NSManagedObject* managedObject = [self.objectStore objectWithID:(NSManagedObjectID*)subObject];
NSManagedObject *managedObject = [self.objectStore objectWithID:(NSManagedObjectID *)subObject];
[collection addObject:managedObject];
} else {
[collection addObject:subObject];
@@ -103,8 +103,8 @@
}
- (void)serializeManagedObjects
{
for (NSNumber* argumentIndex in _argumentKeyPaths) {
NSSet* managedKeyPaths = [_argumentKeyPaths objectForKey:argumentIndex];
for (NSNumber *argumentIndex in _argumentKeyPaths) {
NSSet *managedKeyPaths = [_argumentKeyPaths objectForKey:argumentIndex];
id argument = nil;
[self getArgument:&argument atIndex:[argumentIndex intValue]];
if (argument) {
@@ -115,8 +115,8 @@
- (void)deserializeManagedObjects
{
for (NSNumber* argumentIndex in _argumentKeyPaths) {
NSSet* managedKeyPaths = [_argumentKeyPaths objectForKey:argumentIndex];
for (NSNumber *argumentIndex in _argumentKeyPaths) {
NSSet *managedKeyPaths = [_argumentKeyPaths objectForKey:argumentIndex];
id argument = nil;
[self getArgument:&argument atIndex:[argumentIndex intValue]];
if (argument) {

View File

@@ -22,11 +22,11 @@
@interface RKObjectPropertyInspector (CoreData)
- (NSDictionary *)propertyNamesAndTypesForEntity:(NSEntityDescription*)entity;
- (NSDictionary *)propertyNamesAndTypesForEntity:(NSEntityDescription *)entity;
/**
Returns the Class type of the specified property on the object class
*/
- (Class)typeForProperty:(NSString*)propertyName ofEntity:(NSEntityDescription*)entity;
- (Class)typeForProperty:(NSString *)propertyName ofEntity:(NSEntityDescription *)entity;
@end

View File

@@ -33,31 +33,31 @@ RK_FIX_CATEGORY_BUG(RKObjectPropertyInspector_CoreData)
@implementation RKObjectPropertyInspector (CoreData)
- (NSDictionary *)propertyNamesAndTypesForEntity:(NSEntityDescription*)entity
- (NSDictionary *)propertyNamesAndTypesForEntity:(NSEntityDescription *)entity
{
NSMutableDictionary* propertyNamesAndTypes = [_cachedPropertyNamesAndTypes objectForKey:[entity name]];
NSMutableDictionary *propertyNamesAndTypes = [_cachedPropertyNamesAndTypes objectForKey:[entity name]];
if (propertyNamesAndTypes) {
return propertyNamesAndTypes;
}
propertyNamesAndTypes = [NSMutableDictionary dictionary];
for (NSString* name in [entity attributesByName]) {
NSAttributeDescription* attributeDescription = [[entity attributesByName] valueForKey:name];
for (NSString *name in [entity attributesByName]) {
NSAttributeDescription *attributeDescription = [[entity attributesByName] valueForKey:name];
if ([attributeDescription attributeValueClassName]) {
[propertyNamesAndTypes setValue:NSClassFromString([attributeDescription attributeValueClassName]) forKey:name];
} else if ([attributeDescription attributeType] == NSTransformableAttributeType &&
![name isEqualToString:@"_mapkit_hasPanoramaID"]) {
const char* className = [[entity managedObjectClassName] cStringUsingEncoding:NSUTF8StringEncoding];
const char* propertyName = [name cStringUsingEncoding:NSUTF8StringEncoding];
const char *className = [[entity managedObjectClassName] cStringUsingEncoding:NSUTF8StringEncoding];
const char *propertyName = [name cStringUsingEncoding:NSUTF8StringEncoding];
Class managedObjectClass = objc_getClass(className);
// property_getAttributes() returns everything we need to implement this...
// See: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html#//apple_ref/doc/uid/TP40008048-CH101-SW5
objc_property_t prop = class_getProperty(managedObjectClass, propertyName);
NSString* attributeString = [NSString stringWithCString:property_getAttributes(prop) encoding:NSUTF8StringEncoding];
const char* destinationClassName = [[RKObjectPropertyInspector propertyTypeFromAttributeString:attributeString] cStringUsingEncoding:NSUTF8StringEncoding];
NSString *attributeString = [NSString stringWithCString:property_getAttributes(prop) encoding:NSUTF8StringEncoding];
const char *destinationClassName = [[RKObjectPropertyInspector propertyTypeFromAttributeString:attributeString] cStringUsingEncoding:NSUTF8StringEncoding];
Class destinationClass = objc_getClass(destinationClassName);
if (destinationClass) {
[propertyNamesAndTypes setObject:destinationClass forKey:name];
@@ -65,12 +65,12 @@ RK_FIX_CATEGORY_BUG(RKObjectPropertyInspector_CoreData)
}
}
for (NSString* name in [entity relationshipsByName]) {
NSRelationshipDescription* relationshipDescription = [[entity relationshipsByName] valueForKey:name];
for (NSString *name in [entity relationshipsByName]) {
NSRelationshipDescription *relationshipDescription = [[entity relationshipsByName] valueForKey:name];
if ([relationshipDescription isToMany]) {
[propertyNamesAndTypes setValue:[NSSet class] forKey:name];
} else {
NSEntityDescription* destinationEntity = [relationshipDescription destinationEntity];
NSEntityDescription *destinationEntity = [relationshipDescription destinationEntity];
Class destinationClass = NSClassFromString([destinationEntity managedObjectClassName]);
[propertyNamesAndTypes setValue:destinationClass forKey:name];
}
@@ -81,7 +81,7 @@ RK_FIX_CATEGORY_BUG(RKObjectPropertyInspector_CoreData)
return propertyNamesAndTypes;
}
- (Class)typeForProperty:(NSString*)propertyName ofEntity:(NSEntityDescription*)entity
- (Class)typeForProperty:(NSString *)propertyName ofEntity:(NSEntityDescription *)entity
{
return [[self propertyNamesAndTypesForEntity:entity] valueForKey:propertyName];
}

View File

@@ -25,16 +25,16 @@ extern NSString * const RKSearchWordPrimaryKeyAttribute;
@interface RKSearchWord : NSManagedObject
@property (nonatomic, retain) NSString* word;
@property (nonatomic, retain) NSSet* searchableManagedObjects;
@property (nonatomic, retain) NSString *word;
@property (nonatomic, retain) NSSet *searchableManagedObjects;
@end
@interface RKSearchWord (SearchableManagedObjectsAccessors)
- (void)addSearchableManagedObjectsObject:(RKSearchableManagedObject*)searchableManagedObject;
- (void)removeSearchableManagedObjectsObject:(RKSearchableManagedObject*)searchableManagedObject;
- (void)addSearchableManagedObjects:(NSSet*)searchableManagedObjects;
- (void)removeSearchableManagedObjects:(NSSet*)searchableManagedObjects;
- (void)addSearchableManagedObjectsObject:(RKSearchableManagedObject *)searchableManagedObject;
- (void)removeSearchableManagedObjectsObject:(RKSearchableManagedObject *)searchableManagedObject;
- (void)addSearchableManagedObjects:(NSSet *)searchableManagedObjects;
- (void)removeSearchableManagedObjects:(NSSet *)searchableManagedObjects;
@end

View File

@@ -48,7 +48,7 @@
- (void)refreshSearchWords
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
RKLogDebug(@"Refreshing search words for %@ %@", NSStringFromClass([self class]), [self objectID]);
NSMutableSet *searchWords = [NSMutableSet set];

View File

@@ -35,7 +35,7 @@ RK_FIX_CATEGORY_BUG(NSData_RKAdditions)
CC_MD5(self.bytes, (CC_LONG) self.length, md5Buffer);
// Convert unsigned char buffer to NSString of hex values
NSMutableString* output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH *2];
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x", md5Buffer[i]];
}

View File

@@ -14,6 +14,6 @@
*
* @returns A UTF-8 encoded string representation of the object
*/
- (NSString*)URLEncodedString;
- (NSString *)URLEncodedString;
@end

View File

@@ -11,10 +11,10 @@
@implementation NSObject (URLEncoding)
- (NSString*)URLEncodedString
- (NSString *)URLEncodedString
{
NSString *string = [NSString stringWithFormat:@"%@", self];
NSString *encodedString = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL,
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)string,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",

View File

@@ -47,7 +47,7 @@ NSString *RKMakeURLPath(NSString *resourcePath) {
return [[[RKClient sharedClient].baseURL URLByAppendingResourcePath:resourcePath] absoluteString];
}
NSString *RKMakePathWithObjectAddingEscapes(NSString* pattern, id object, BOOL addEscapes) {
NSString *RKMakePathWithObjectAddingEscapes(NSString *pattern, id object, BOOL addEscapes) {
NSCAssert(pattern != NULL, @"Pattern string must not be empty in order to create a path from an interpolated object.");
NSCAssert(object != NULL, @"Object provided is invalid; cannot create a path from a NULL object");
RKPathMatcher *matcher = [RKPathMatcher matcherWithPattern:pattern];
@@ -378,7 +378,7 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar
- (RKRequest *)load:(NSString *)resourcePath method:(RKRequestMethod)method params:(NSObject<RKRequestSerializable> *)params delegate:(id)delegate
{
RKURL* resourcePathURL = nil;
RKURL *resourcePathURL = nil;
if (method == RKRequestMethodGET) {
resourcePathURL = [self.baseURL URLByAppendingResourcePath:resourcePath queryParameters:(NSDictionary *)params];
} else {

View File

@@ -79,7 +79,7 @@
//Use the parsedBody answer in NSDictionary
NSDictionary* oauthResponse = (NSDictionary *) [response parsedBody:&error];
NSDictionary *oauthResponse = (NSDictionary *) [response parsedBody:&error];
if ([oauthResponse isKindOfClass:[NSDictionary class]]) {
//Check the if an access token comes in the response
@@ -117,7 +117,7 @@
errorCode = RKOAuthClientErrorInvalidScope;
}
NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
errorDescription, NSLocalizedDescriptionKey, nil];
NSError *error = [NSError errorWithDomain:RKErrorDomain code:errorCode userInfo:userInfo];
@@ -169,7 +169,7 @@
- (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error
{
NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
error, NSUnderlyingErrorKey, nil];
NSError *clientError = [NSError errorWithDomain:RKErrorDomain code:RKOAuthClientErrorRequestFailure userInfo:userInfo];
if ([self.delegate respondsToSelector:@selector(OAuthClient:didFailLoadingRequest:withError:)]) {

View File

@@ -34,19 +34,19 @@
/**
* The boundary used used for multi-part headers
*/
NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY";
NSString * const kRKStringBoundary = @"0xKhTmLbOuNdArY";
@implementation RKParams
+ (RKParams*)params
+ (RKParams *)params
{
RKParams* params = [[[RKParams alloc] init] autorelease];
RKParams *params = [[[RKParams alloc] init] autorelease];
return params;
}
+ (RKParams*)paramsWithDictionary:(NSDictionary*)dictionary
+ (RKParams *)paramsWithDictionary:(NSDictionary *)dictionary
{
RKParams* params = [[[RKParams alloc] initWithDictionary:dictionary] autorelease];
RKParams *params = [[[RKParams alloc] initWithDictionary:dictionary] autorelease];
return params;
}
@@ -199,7 +199,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY";
_length += [attachment length];
}
return (NSInputStream*)self;
return (NSInputStream *)self;
}
#pragma mark NSInputStream methods

View File

@@ -31,7 +31,7 @@
/**
* The multi-part boundary. See RKParams.m
*/
extern NSString* const kRKStringBoundary;
extern NSString * const kRKStringBoundary;
@implementation RKParamsAttachment
@@ -56,7 +56,7 @@ extern NSString* const kRKStringBoundary;
{
if ((self = [self initWithName:name])) {
if ([value respondsToSelector:@selector(dataUsingEncoding:)]) {
_body = [[(NSString*)value dataUsingEncoding:NSUTF8StringEncoding] retain];
_body = [[(NSString *)value dataUsingEncoding:NSUTF8StringEncoding] retain];
} else {
_body = [[[NSString stringWithFormat:@"%@", value] dataUsingEncoding:NSUTF8StringEncoding] retain];
}
@@ -69,7 +69,7 @@ extern NSString* const kRKStringBoundary;
return self;
}
- (id)initWithName:(NSString*)name data:(NSData*)data
- (id)initWithName:(NSString *)name data:(NSData *)data
{
self = [self initWithName:name];
if (self) {
@@ -81,7 +81,7 @@ extern NSString* const kRKStringBoundary;
return self;
}
- (id)initWithName:(NSString*)name file:(NSString*)filePath
- (id)initWithName:(NSString *)name file:(NSString *)filePath
{
self = [self initWithName:name];
if (self) {
@@ -93,8 +93,8 @@ extern NSString* const kRKStringBoundary;
_MIMEType = [MIMEType retain];
_bodyStream = [[NSInputStream alloc] initWithFileAtPath:filePath];
NSError* error;
NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error];
NSError *error;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error];
if (attributes) {
_bodyLength = [[attributes objectForKey:NSFileSize] unsignedIntegerValue];
}
@@ -125,7 +125,7 @@ extern NSString* const kRKStringBoundary;
[super dealloc];
}
- (NSString*)MIMEBoundary
- (NSString *)MIMEBoundary
{
return kRKStringBoundary;
}

View File

@@ -43,9 +43,9 @@
@end
// Constants
NSString* const RKReachabilityDidChangeNotification = @"RKReachabilityDidChangeNotification";
NSString* const RKReachabilityFlagsUserInfoKey = @"RKReachabilityFlagsUserInfoKey";
NSString* const RKReachabilityWasDeterminedNotification = @"RKReachabilityWasDeterminedNotification";
NSString * const RKReachabilityDidChangeNotification = @"RKReachabilityDidChangeNotification";
NSString * const RKReachabilityFlagsUserInfoKey = @"RKReachabilityFlagsUserInfoKey";
NSString * const RKReachabilityWasDeterminedNotification = @"RKReachabilityWasDeterminedNotification";
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

View File

@@ -135,12 +135,12 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
@synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier;
#endif
+ (RKRequest*)requestWithURL:(NSURL*)URL
+ (RKRequest *)requestWithURL:(NSURL *)URL
{
return [[[RKRequest alloc] initWithURL:URL] autorelease];
}
- (id)initWithURL:(NSURL*)URL
- (id)initWithURL:(NSURL *)URL
{
self = [self init];
if (self) {
@@ -198,7 +198,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
return;
}
UIApplication* app = [UIApplication sharedApplication];
UIApplication *app = [UIApplication sharedApplication];
if ([app respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)]) {
[app endBackgroundTask:_backgroundTaskIdentifier];
_backgroundTaskIdentifier = UIBackgroundTaskInvalid;
@@ -286,7 +286,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
}
}
- (NSData*)HTTPBody
- (NSData *)HTTPBody
{
return self.URLRequest.HTTPBody;
}
@@ -296,7 +296,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
[self.URLRequest setHTTPBody:HTTPBody];
}
- (NSString*)HTTPBodyString
- (NSString *)HTTPBodyString
{
return [[[NSString alloc] initWithData:self.URLRequest.HTTPBody encoding:NSASCIIStringEncoding] autorelease];
}
@@ -392,7 +392,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
}
if (self.cachePolicy & RKRequestCachePolicyEtag) {
NSString* etag = [self.cache etagForRequest:self];
NSString *etag = [self.cache etagForRequest:self];
if (etag) {
RKLogTrace(@"Setting If-None-Match header to '%@'", etag);
[_URLRequest setValue:etag forHTTPHeaderField:@"If-None-Match"];
@@ -412,7 +412,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
[self setRequestBody];
[self addHeadersToRequest];
NSString* body = [[NSString alloc] initWithData:[_URLRequest HTTPBody] encoding:NSUTF8StringEncoding];
NSString *body = [[NSString alloc] initWithData:[_URLRequest HTTPBody] encoding:NSUTF8StringEncoding];
RKLogTrace(@"Prepared %@ URLRequest '%@'. HTTP Headers: %@. HTTP Body: %@.", [self HTTPMethod], _URLRequest, [_URLRequest allHTTPHeaderFields], body);
[body release];
@@ -463,7 +463,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
[self.delegate requestDidStartLoad:self];
}
RKResponse* response = [[[RKResponse alloc] initWithRequest:self] autorelease];
RKResponse *response = [[[RKResponse alloc] initWithRequest:self] autorelease];
_connection = [[[[NSURLConnection alloc] initWithRequest:_URLRequest delegate:response startImmediately:NO] autorelease] retain];
[_connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:self.runLoopMode];
@@ -479,7 +479,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
if (self.cachePolicy & RKRequestCachePolicyEnabled) {
return YES;
} else if (self.cachePolicy & RKRequestCachePolicyTimeout) {
NSDate* date = [self.cache cacheDateForRequest:self];
NSDate *date = [self.cache cacheDateForRequest:self];
NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:date];
return interval <= self.cacheTimeoutInterval;
}
@@ -487,7 +487,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
return NO;
}
- (RKResponse*)loadResponseFromCache
- (RKResponse *)loadResponseFromCache
{
RKLogDebug(@"Found cached content, loading...");
return [self.cache responseForRequest:self];
@@ -507,14 +507,14 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
NSAssert(NO == self.loading || NO == self.loaded, @"Cannot send a request that is loading or loaded without resetting it first.");
_sentSynchronously = NO;
if ([self shouldLoadFromCache]) {
RKResponse* response = [self loadResponseFromCache];
RKResponse *response = [self loadResponseFromCache];
self.loading = YES;
[self performSelector:@selector(didFinishLoad:) withObject:response afterDelay:0];
} else if ([self shouldDispatchRequest]) {
[self createTimeoutTimer];
#if TARGET_OS_IPHONE
// Background Request Policy support
UIApplication* app = [UIApplication sharedApplication];
UIApplication *app = [UIApplication sharedApplication];
if (self.backgroundPolicy == RKRequestBackgroundPolicyNone ||
NO == [app respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)]) {
// No support for background (iOS 3.x) or the policy is none -- just fire the request
@@ -530,7 +530,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
RKLogInfo(@"Beginning background task to perform processing...");
// Fork a background task for continueing a long-running request
__block RKRequest* weakSelf = self;
__block RKRequest *weakSelf = self;
__block id<RKRequestDelegate> weakDelegate = _delegate;
_backgroundTaskIdentifier = [app beginBackgroundTaskWithExpirationHandler:^{
RKLogInfo(@"Background request time expired, canceling request.");
@@ -560,23 +560,23 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
self.loading = YES;
RKLogError(@"Failed to send request to %@ due to unreachable network. Reachability observer = %@", [[self URL] absoluteString], self.reachabilityObserver);
NSString* errorMessage = [NSString stringWithFormat:@"The client is unable to contact the resource at %@", [[self URL] absoluteString]];
NSString *errorMessage = [NSString stringWithFormat:@"The client is unable to contact the resource at %@", [[self URL] absoluteString]];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
errorMessage, NSLocalizedDescriptionKey,
nil];
NSError* error = [NSError errorWithDomain:RKErrorDomain code:RKRequestBaseURLOfflineError userInfo:userInfo];
NSError *error = [NSError errorWithDomain:RKErrorDomain code:RKRequestBaseURLOfflineError userInfo:userInfo];
[self performSelector:@selector(didFailLoadWithError:) withObject:error afterDelay:0];
}
}
}
- (RKResponse*)sendSynchronously
- (RKResponse *)sendSynchronously
{
NSAssert(NO == self.loading || NO == self.loaded, @"Cannot send a request that is loading or loaded without resetting it first.");
NSHTTPURLResponse* URLResponse = nil;
NSError* error;
NSData* payload = nil;
RKResponse* response = nil;
NSHTTPURLResponse *URLResponse = nil;
NSError *error;
NSData *payload = nil;
RKResponse *response = nil;
_sentSynchronously = YES;
if ([self shouldLoadFromCache]) {
@@ -620,7 +620,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
response = [self loadResponseFromCache];
} else {
NSString* errorMessage = [NSString stringWithFormat:@"The client is unable to contact the resource at %@", [[self URL] absoluteString]];
NSString *errorMessage = [NSString stringWithFormat:@"The client is unable to contact the resource at %@", [[self URL] absoluteString]];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
errorMessage, NSLocalizedDescriptionKey,
nil];
@@ -647,11 +647,11 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
{
[self cancelAndInformDelegate:NO];
RKLogError(@"Failed to send request to %@ due to connection timeout. Timeout interval = %f", [[self URL] absoluteString], self.timeoutInterval);
NSString* errorMessage = [NSString stringWithFormat:@"The client timed out connecting to the resource at %@", [[self URL] absoluteString]];
NSString *errorMessage = [NSString stringWithFormat:@"The client timed out connecting to the resource at %@", [[self URL] absoluteString]];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
errorMessage, NSLocalizedDescriptionKey,
nil];
NSError* error = [NSError errorWithDomain:RKErrorDomain code:RKRequestConnectionTimeoutError userInfo:userInfo];
NSError *error = [NSError errorWithDomain:RKErrorDomain code:RKRequestConnectionTimeoutError userInfo:userInfo];
[self didFailLoadWithError:error];
}
@@ -661,7 +661,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
_timeoutTimer = nil;
}
- (void)didFailLoadWithError:(NSError*)error
- (void)didFailLoadWithError:(NSError *)error
{
if (_cachePolicy & RKRequestCachePolicyLoadOnError &&
[self.cache hasResponseForRequest:self]) {
@@ -680,7 +680,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
}
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:error forKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey];
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:error forKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey];
[[NSNotificationCenter defaultCenter] postNotificationName:RKRequestDidFailWithErrorNotification
object:self
userInfo:userInfo];
@@ -693,7 +693,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
- (void)updateInternalCacheDate
{
NSDate* date = [NSDate date];
NSDate *date = [NSDate date];
RKLogInfo(@"Updating cache date for request %@ to %@", self, date);
[self.cache setCacheDate:date forRequest:self];
}
@@ -729,7 +729,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
[[NSNotificationCenter defaultCenter] postNotificationName:RKServiceDidBecomeUnavailableNotification object:self];
}
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:self.response
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:self.response
forKey:RKRequestDidLoadResponseNotificationUserInfoResponseKey];
[[NSNotificationCenter defaultCenter] postNotificationName:RKRequestDidLoadResponseNotification
object:self
@@ -770,11 +770,11 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
return self.loading == NO && self.loaded == NO;
}
- (NSString*)resourcePath
- (NSString *)resourcePath
{
NSString* resourcePath = nil;
NSString *resourcePath = nil;
if ([self.URL isKindOfClass:[RKURL class]]) {
RKURL* url = (RKURL*)self.URL;
RKURL *url = (RKURL *)self.URL;
resourcePath = url.resourcePath;
}
return resourcePath;
@@ -797,7 +797,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
}
}
- (BOOL)wasSentToResourcePath:(NSString*)resourcePath
- (BOOL)wasSentToResourcePath:(NSString *)resourcePath
{
return [[self resourcePath] isEqualToString:resourcePath];
}
@@ -807,7 +807,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
return (self.method == method && [self wasSentToResourcePath:resourcePath]);
}
- (void)appDidEnterBackgroundNotification:(NSNotification*)notification
- (void)appDidEnterBackgroundNotification:(NSNotification *)notification
{
#if TARGET_OS_IPHONE
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
@@ -826,14 +826,14 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
return _method == RKRequestMethodGET;
}
- (NSString*)cacheKey
- (NSString *)cacheKey
{
if (! [self isCacheable]) {
return nil;
}
// Use [_params HTTPBody] because the URLRequest body may not have been set up yet.
NSString* compositeCacheKey = nil;
NSString *compositeCacheKey = nil;
if (_params) {
if ([_params respondsToSelector:@selector(HTTPBody)]) {
compositeCacheKey = [NSString stringWithFormat:@"%@-%d-%@", self.URL, _method, [_params HTTPBody]];
@@ -852,7 +852,7 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:MIMEType];
NSError *error = nil;
NSString* parsedValue = [parser stringFromObject:body error:&error];
NSString *parsedValue = [parser stringFromObject:body error:&error];
RKLogTrace(@"parser=%@, error=%@, parsedValue=%@", parser, error, parsedValue);
@@ -863,12 +863,12 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) {
}
// Deprecations
+ (RKRequest*)requestWithURL:(NSURL*)URL delegate:(id)delegate
+ (RKRequest *)requestWithURL:(NSURL *)URL delegate:(id)delegate
{
return [[[RKRequest alloc] initWithURL:URL delegate:delegate] autorelease];
}
- (id)initWithURL:(NSURL*)URL delegate:(id)delegate
- (id)initWithURL:(NSURL *)URL delegate:(id)delegate
{
self = [self initWithURL:URL];
if (self) {

View File

@@ -33,13 +33,13 @@ NSString * const RKRequestCacheStatusCodeHeadersKey = @"X-RESTKIT-CACHED-RESPONS
NSString * const RKRequestCacheMIMETypeHeadersKey = @"X-RESTKIT-CACHED-MIME-TYPE";
NSString * const RKRequestCacheURLHeadersKey = @"X-RESTKIT-CACHED-URL";
static NSDateFormatter* __rfc1123DateFormatter;
static NSDateFormatter *__rfc1123DateFormatter;
@implementation RKRequestCache
@synthesize storagePolicy = _storagePolicy;
+ (NSDateFormatter*)rfc1123DateFormatter
+ (NSDateFormatter *)rfc1123DateFormatter
{
if (__rfc1123DateFormatter == nil) {
__rfc1123DateFormatter = [[NSDateFormatter alloc] init];
@@ -49,7 +49,7 @@ static NSDateFormatter* __rfc1123DateFormatter;
return __rfc1123DateFormatter;
}
- (id)initWithPath:(NSString*)cachePath storagePolicy:(RKRequestCacheStoragePolicy)storagePolicy
- (id)initWithPath:(NSString *)cachePath storagePolicy:(RKRequestCacheStoragePolicy)storagePolicy
{
self = [super init];
if (self) {
@@ -70,15 +70,15 @@ static NSDateFormatter* __rfc1123DateFormatter;
[super dealloc];
}
- (NSString*)path
- (NSString *)path
{
return _cache.cachePath;
}
- (NSString*)pathForRequest:(RKRequest*)request
- (NSString *)pathForRequest:(RKRequest *)request
{
NSString* pathForRequest = nil;
NSString* requestCacheKey = [request cacheKey];
NSString *pathForRequest = nil;
NSString *requestCacheKey = [request cacheKey];
if (requestCacheKey) {
if (_storagePolicy == RKRequestCacheStoragePolicyForDurationOfSession) {
pathForRequest = [RKRequestCacheSessionCacheDirectory stringByAppendingPathComponent:requestCacheKey];
@@ -93,10 +93,10 @@ static NSDateFormatter* __rfc1123DateFormatter;
return pathForRequest;
}
- (BOOL)hasResponseForRequest:(RKRequest*)request
- (BOOL)hasResponseForRequest:(RKRequest *)request
{
BOOL hasEntryForRequest = NO;
NSString* cacheKey = [self pathForRequest:request];
NSString *cacheKey = [self pathForRequest:request];
if (cacheKey) {
hasEntryForRequest = ([_cache hasEntry:cacheKey] &&
[_cache hasEntry:[cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension]]);
@@ -105,21 +105,21 @@ static NSDateFormatter* __rfc1123DateFormatter;
return hasEntryForRequest;
}
- (void)storeResponse:(RKResponse*)response forRequest:(RKRequest*)request
- (void)storeResponse:(RKResponse *)response forRequest:(RKRequest *)request
{
if ([self hasResponseForRequest:request]) {
[self invalidateRequest:request];
}
if (_storagePolicy != RKRequestCacheStoragePolicyDisabled) {
NSString* cacheKey = [self pathForRequest:request];
NSString *cacheKey = [self pathForRequest:request];
if (cacheKey) {
[_cache writeData:response.body withCacheKey:cacheKey];
NSMutableDictionary* headers = [response.allHeaderFields mutableCopy];
NSMutableDictionary *headers = [response.allHeaderFields mutableCopy];
if (headers) {
// TODO: expose this?
NSHTTPURLResponse* urlResponse = [response valueForKey:@"_httpURLResponse"];
NSHTTPURLResponse *urlResponse = [response valueForKey:@"_httpURLResponse"];
// Cache Loaded Time
[headers setObject:[[RKRequestCache rfc1123DateFormatter] stringFromDate:[NSDate date]]
forKey:RKRequestCacheDateHeaderKey];
@@ -140,25 +140,25 @@ static NSDateFormatter* __rfc1123DateFormatter;
}
}
- (RKResponse*)responseForRequest:(RKRequest*)request
- (RKResponse *)responseForRequest:(RKRequest *)request
{
RKResponse* response = nil;
NSString* cacheKey = [self pathForRequest:request];
RKResponse *response = nil;
NSString *cacheKey = [self pathForRequest:request];
if (cacheKey) {
NSData* responseData = [_cache dataForCacheKey:cacheKey];
NSDictionary* responseHeaders = [_cache dictionaryForCacheKey:[cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension]];
NSData *responseData = [_cache dataForCacheKey:cacheKey];
NSDictionary *responseHeaders = [_cache dictionaryForCacheKey:[cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension]];
response = [[[RKResponse alloc] initWithRequest:request body:responseData headers:responseHeaders] autorelease];
}
RKLogDebug(@"Found cached RKResponse '%@' for '%@'", response, request);
return response;
}
- (NSDictionary*)headersForRequest:(RKRequest*)request
- (NSDictionary *)headersForRequest:(RKRequest *)request
{
NSDictionary* headers = nil;
NSString* cacheKey = [self pathForRequest:request];
NSDictionary *headers = nil;
NSString *cacheKey = [self pathForRequest:request];
if (cacheKey) {
NSString* headersCacheKey = [cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension];
NSString *headersCacheKey = [cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension];
headers = [_cache dictionaryForCacheKey:headersCacheKey];
if (headers) {
RKLogDebug(@"Read cached headers '%@' from headersCacheKey '%@' for '%@'", headers, headersCacheKey, request);
@@ -171,13 +171,13 @@ static NSDateFormatter* __rfc1123DateFormatter;
return headers;
}
- (NSString*)etagForRequest:(RKRequest*)request
- (NSString *)etagForRequest:(RKRequest *)request
{
NSString* etag = nil;
NSString *etag = nil;
NSDictionary* responseHeaders = [self headersForRequest:request];
NSDictionary *responseHeaders = [self headersForRequest:request];
if (responseHeaders) {
for (NSString* responseHeader in responseHeaders) {
for (NSString *responseHeader in responseHeaders) {
if ([[responseHeader uppercaseString] isEqualToString:[@"ETag" uppercaseString]]) {
etag = [responseHeaders objectForKey:responseHeader];
}
@@ -187,11 +187,11 @@ static NSDateFormatter* __rfc1123DateFormatter;
return etag;
}
- (void)setCacheDate:(NSDate*)date forRequest:(RKRequest*)request
- (void)setCacheDate:(NSDate *)date forRequest:(RKRequest *)request
{
NSString* cacheKey = [self pathForRequest:request];
NSString *cacheKey = [self pathForRequest:request];
if (cacheKey) {
NSMutableDictionary* responseHeaders = [[self headersForRequest:request] mutableCopy];
NSMutableDictionary *responseHeaders = [[self headersForRequest:request] mutableCopy];
[responseHeaders setObject:[[RKRequestCache rfc1123DateFormatter] stringFromDate:date]
forKey:RKRequestCacheDateHeaderKey];
@@ -201,14 +201,14 @@ static NSDateFormatter* __rfc1123DateFormatter;
}
}
- (NSDate*)cacheDateForRequest:(RKRequest*)request
- (NSDate *)cacheDateForRequest:(RKRequest *)request
{
NSDate* date = nil;
NSString* dateString = nil;
NSDate *date = nil;
NSString *dateString = nil;
NSDictionary* responseHeaders = [self headersForRequest:request];
NSDictionary *responseHeaders = [self headersForRequest:request];
if (responseHeaders) {
for (NSString* responseHeader in responseHeaders) {
for (NSString *responseHeader in responseHeaders) {
if ([[responseHeader uppercaseString] isEqualToString:[RKRequestCacheDateHeaderKey uppercaseString]]) {
dateString = [responseHeaders objectForKey:responseHeader];
}
@@ -219,10 +219,10 @@ static NSDateFormatter* __rfc1123DateFormatter;
return date;
}
- (void)invalidateRequest:(RKRequest*)request
- (void)invalidateRequest:(RKRequest *)request
{
RKLogDebug(@"Invalidating cache entry for '%@'", request);
NSString* cacheKey = [self pathForRequest:request];
NSString *cacheKey = [self pathForRequest:request];
if (cacheKey) {
[_cache invalidateEntry:cacheKey];
[_cache invalidateEntry:[cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension]];

View File

@@ -32,7 +32,7 @@
RK_FIX_CATEGORY_BUG(UIApplication_RKNetworkActivity)
// Constants
static NSMutableArray* RKRequestQueueInstances = nil;
static NSMutableArray *RKRequestQueueInstances = nil;
static const NSTimeInterval kFlushDelay = 0.3;
@@ -41,7 +41,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
#define RKLogComponent lcl_cRestKitNetworkQueue
@interface RKRequestQueue ()
@property (nonatomic, retain, readwrite) NSString* name;
@property (nonatomic, retain, readwrite) NSString *name;
@end
@implementation RKRequestQueue
@@ -56,13 +56,13 @@ static const NSTimeInterval kFlushDelay = 0.3;
@synthesize showsNetworkActivityIndicatorWhenBusy = _showsNetworkActivityIndicatorWhenBusy;
#endif
+ (RKRequestQueue*)sharedQueue
+ (RKRequestQueue *)sharedQueue
{
RKLogWarning(@"Deprecated invocation of [RKRequestQueue sharedQueue]. Returning [RKClient sharedClient].requestQueue. Update your code to reference the queue you want explicitly.");
return [RKClient sharedClient].requestQueue;
}
+ (void)setSharedQueue:(RKRequestQueue*)requestQueue
+ (void)setSharedQueue:(RKRequestQueue *)requestQueue
{
RKLogWarning(@"Deprecated access to [RKRequestQueue setSharedQueue:]. Invoking [[RKClient sharedClient] setRequestQueue:]. Update your code to reference the specific queue instance you want.");
[RKClient sharedClient].requestQueue = requestQueue;
@@ -73,7 +73,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
return [[self new] autorelease];
}
+ (id)newRequestQueueWithName:(NSString*)name
+ (id)newRequestQueueWithName:(NSString *)name
{
if (RKRequestQueueInstances == nil) {
RKRequestQueueInstances = [NSMutableArray new];
@@ -83,7 +83,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
return nil;
}
RKRequestQueue* queue = [self new];
RKRequestQueue *queue = [self new];
queue.name = name;
[RKRequestQueueInstances addObject:[NSValue valueWithNonretainedObject:queue]];
@@ -99,8 +99,8 @@ static const NSTimeInterval kFlushDelay = 0.3;
// Find existing reference
NSArray *requestQueueInstances = [RKRequestQueueInstances copy];
RKRequestQueue *namedQueue = nil;
for (NSValue* value in requestQueueInstances) {
RKRequestQueue* queue = (RKRequestQueue*) [value nonretainedObjectValue];
for (NSValue *value in requestQueueInstances) {
RKRequestQueue *queue = (RKRequestQueue *) [value nonretainedObjectValue];
if ([queue.name isEqualToString:name]) {
namedQueue = queue;
break;
@@ -117,13 +117,13 @@ static const NSTimeInterval kFlushDelay = 0.3;
return namedQueue;
}
+ (BOOL)requestQueueExistsWithName:(NSString*)name
+ (BOOL)requestQueueExistsWithName:(NSString *)name
{
BOOL queueExists = NO;
if (RKRequestQueueInstances) {
NSArray *requestQueueInstances = [RKRequestQueueInstances copy];
for (NSValue* value in requestQueueInstances) {
RKRequestQueue* queue = (RKRequestQueue*) [value nonretainedObjectValue];
for (NSValue *value in requestQueueInstances) {
RKRequestQueue *queue = (RKRequestQueue *) [value nonretainedObjectValue];
if ([queue.name isEqualToString:name]) {
queueExists = YES;
break;
@@ -165,8 +165,8 @@ static const NSTimeInterval kFlushDelay = 0.3;
- (void)removeFromNamedQueues
{
if (self.name) {
for (NSValue* value in RKRequestQueueInstances) {
RKRequestQueue* queue = (RKRequestQueue*) [value nonretainedObjectValue];
for (NSValue *value in RKRequestQueueInstances) {
RKRequestQueue *queue = (RKRequestQueue *) [value nonretainedObjectValue];
if ([queue.name isEqualToString:self.name]) {
[RKRequestQueueInstances removeObject:value];
return;
@@ -196,7 +196,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
return [_requests count];
}
- (NSString*)description
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p name=%@ suspended=%@ requestCount=%d loadingCount=%d/%d>",
NSStringFromClass([self class]), self, self.name, self.suspended ? @"YES" : @"NO",
@@ -208,7 +208,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
return [_loadingRequests count];
}
- (void)addLoadingRequest:(RKRequest*)request
- (void)addLoadingRequest:(RKRequest *)request
{
if (self.loadingCount == 0) {
RKLogTrace(@"Loading count increasing from 0 to 1. Firing requestQueueDidBeginLoading");
@@ -230,7 +230,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
RKLogTrace(@"Loading count now %ld for queue %@", (long) self.loadingCount, self);
}
- (void)removeLoadingRequest:(RKRequest*)request
- (void)removeLoadingRequest:(RKRequest *)request
{
if (self.loadingCount == 1 && [_loadingRequests containsObject:request]) {
RKLogTrace(@"Loading count decreasing from 1 to 0. Firing requestQueueDidFinishLoading");
@@ -264,10 +264,10 @@ static const NSTimeInterval kFlushDelay = 0.3;
}
}
- (RKRequest*)nextRequest
- (RKRequest *)nextRequest
{
for (NSUInteger i = 0; i < [_requests count]; i++) {
RKRequest* request = [_requests objectAtIndex:i];
RKRequest *request = [_requests objectAtIndex:i];
if ([request isUnsent]) {
return request;
}
@@ -294,11 +294,11 @@ static const NSTimeInterval kFlushDelay = 0.3;
return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
_queueTimer = nil;
@synchronized(self) {
RKRequest* request = [self nextRequest];
RKRequest *request = [self nextRequest];
while (request && self.loadingCount < _concurrentRequestsLimit) {
RKLogTrace(@"Processing request %@ in queue %@", request, self);
if ([_delegate respondsToSelector:@selector(requestQueue:willSendRequest:)]) {
@@ -354,7 +354,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
}
}
- (void)addRequest:(RKRequest*)request
- (void)addRequest:(RKRequest *)request
{
RKLogTrace(@"Request %@ added to queue %@", request, self);
NSAssert(![self containsRequest:request], @"Attempting to add the same request multiple times");
@@ -380,7 +380,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
[self loadNextInQueue];
}
- (BOOL)removeRequest:(RKRequest*)request
- (BOOL)removeRequest:(RKRequest *)request
{
if ([self containsRequest:request]) {
RKLogTrace(@"Removing request %@ from queue %@", request, self);
@@ -401,14 +401,14 @@ static const NSTimeInterval kFlushDelay = 0.3;
return NO;
}
- (BOOL)containsRequest:(RKRequest*)request
- (BOOL)containsRequest:(RKRequest *)request
{
@synchronized(self) {
return [_requests containsObject:request];
}
}
- (void)cancelRequest:(RKRequest*)request loadNext:(BOOL)loadNext
- (void)cancelRequest:(RKRequest *)request loadNext:(BOOL)loadNext
{
if ([request isUnsent]) {
RKLogDebug(@"Cancelled undispatched request %@ and removed from queue %@", request, self);
@@ -437,18 +437,18 @@ static const NSTimeInterval kFlushDelay = 0.3;
}
}
- (void)cancelRequest:(RKRequest*)request
- (void)cancelRequest:(RKRequest *)request
{
[self cancelRequest:request loadNext:YES];
}
- (void)cancelRequestsWithDelegate:(NSObject<RKRequestDelegate>*)delegate
- (void)cancelRequestsWithDelegate:(NSObject<RKRequestDelegate> *)delegate
{
RKLogDebug(@"Cancelling all request in queue %@ with delegate %p", self, delegate);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray* requestsCopy = [NSArray arrayWithArray:_requests];
for (RKRequest* request in requestsCopy) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *requestsCopy = [NSArray arrayWithArray:_requests];
for (RKRequest *request in requestsCopy) {
if (request.delegate && request.delegate == delegate) {
[self cancelRequest:request];
}
@@ -456,13 +456,13 @@ static const NSTimeInterval kFlushDelay = 0.3;
[pool drain];
}
- (void)abortRequestsWithDelegate:(NSObject<RKRequestDelegate>*)delegate
- (void)abortRequestsWithDelegate:(NSObject<RKRequestDelegate> *)delegate
{
RKLogDebug(@"Aborting all request in queue %@ with delegate %p", self, delegate);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray* requestsCopy = [NSArray arrayWithArray:_requests];
for (RKRequest* request in requestsCopy) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *requestsCopy = [NSArray arrayWithArray:_requests];
for (RKRequest *request in requestsCopy) {
if (request.delegate && request.delegate == delegate) {
request.delegate = nil;
[self cancelRequest:request];
@@ -475,9 +475,9 @@ static const NSTimeInterval kFlushDelay = 0.3;
{
RKLogDebug(@"Cancelling all request in queue %@", self);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray* requestsCopy = [NSArray arrayWithArray:_requests];
for (RKRequest* request in requestsCopy) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *requestsCopy = [NSArray arrayWithArray:_requests];
for (RKRequest *request in requestsCopy) {
[self cancelRequest:request loadNext:NO];
}
[pool drain];
@@ -494,13 +494,13 @@ static const NSTimeInterval kFlushDelay = 0.3;
NSAssert([notification.object isKindOfClass:[RKRequest class]], @"Notification expected to contain an RKRequest, got a %@", NSStringFromClass([notification.object class]));
RKLogTrace(@"Received notification: %@", notification);
RKRequest* request = (RKRequest*)notification.object;
NSDictionary* userInfo = [notification userInfo];
RKRequest *request = (RKRequest *)notification.object;
NSDictionary *userInfo = [notification userInfo];
// We successfully loaded a response
RKLogDebug(@"Received response for request %@, removing from queue. (Now loading %ld of %ld)", request, (long) self.loadingCount, (long) _concurrentRequestsLimit);
RKResponse* response = [userInfo objectForKey:RKRequestDidLoadResponseNotificationUserInfoResponseKey];
RKResponse *response = [userInfo objectForKey:RKRequestDidLoadResponseNotificationUserInfoResponseKey];
if ([_delegate respondsToSelector:@selector(requestQueue:didLoadResponse:)]) {
[_delegate requestQueue:self didLoadResponse:response];
}
@@ -514,11 +514,11 @@ static const NSTimeInterval kFlushDelay = 0.3;
NSAssert([notification.object isKindOfClass:[RKRequest class]], @"Notification expected to contain an RKRequest, got a %@", NSStringFromClass([notification.object class]));
RKLogTrace(@"Received notification: %@", notification);
RKRequest* request = (RKRequest*)notification.object;
NSDictionary* userInfo = [notification userInfo];
RKRequest *request = (RKRequest *)notification.object;
NSDictionary *userInfo = [notification userInfo];
// We failed with an error
NSError* error = nil;
NSError *error = nil;
if (userInfo) {
error = [userInfo objectForKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey];
RKLogDebug(@"Request %@ failed loading in queue %@ with error: %@.(Now loading %ld of %ld)", request, self,
@@ -544,7 +544,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
NSAssert([notification.object isKindOfClass:[RKRequest class]], @"Notification expected to contain an RKRequest, got a %@", NSStringFromClass([notification.object class]));
RKLogTrace(@"Received notification: %@", notification);
RKRequest* request = (RKRequest*)notification.object;
RKRequest *request = (RKRequest *)notification.object;
if ([self containsRequest:request]) {
[self removeRequest:request];

View File

@@ -20,6 +20,6 @@
@interface RKRequest (Internals)
- (BOOL)prepareURLRequest;
- (void)didFailLoadWithError:(NSError*)error;
- (void)didFailLoadWithError:(NSError *)error;
- (void)finalizeLoad:(BOOL)successful;
@end

View File

@@ -65,7 +65,7 @@ return __VA_ARGS__;
return self;
}
- (id)initWithRequest:(RKRequest*)request body:(NSData*)body headers:(NSDictionary*)headers
- (id)initWithRequest:(RKRequest *)request body:(NSData *)body headers:(NSDictionary *)headers
{
self = [self initWithRequest:request];
if (self) {
@@ -77,7 +77,7 @@ return __VA_ARGS__;
return self;
}
- (id)initWithSynchronousRequest:(RKRequest*)request URLResponse:(NSHTTPURLResponse*)URLResponse body:(NSData*)body error:(NSError*)error
- (id)initWithSynchronousRequest:(RKRequest *)request URLResponse:(NSHTTPURLResponse *)URLResponse body:(NSData *)body error:(NSError *)error
{
self = [super init];
if (self) {
@@ -263,7 +263,7 @@ return __VA_ARGS__;
}
}
- (NSString*)localizedStatusCodeString
- (NSString *)localizedStatusCodeString
{
return [NSHTTPURLResponse localizedStringForStatusCode:[self statusCode]];
}
@@ -299,7 +299,7 @@ return __VA_ARGS__;
return nil;
}
- (id)parsedBody:(NSError**)error
- (id)parsedBody:(NSError **)error
{
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:[self MIMEType]];
if (! parser) {
@@ -316,7 +316,7 @@ return __VA_ARGS__;
return object;
}
- (NSString*)failureErrorDescription
- (NSString *)failureErrorDescription
{
if ([self isFailure]) {
return [_failureError localizedDescription];
@@ -330,7 +330,7 @@ return __VA_ARGS__;
return (_responseHeaders != nil);
}
- (NSURL*)URL
- (NSURL *)URL
{
if ([self wasLoadedFromCache]) {
return [NSURL URLWithString:[_responseHeaders valueForKey:RKRequestCacheURLHeadersKey]];
@@ -338,7 +338,7 @@ return __VA_ARGS__;
return [_httpURLResponse URL];
}
- (NSString*)MIMEType
- (NSString *)MIMEType
{
if ([self wasLoadedFromCache]) {
return [_responseHeaders valueForKey:RKRequestCacheMIMETypeHeadersKey];
@@ -354,7 +354,7 @@ return __VA_ARGS__;
return ([_httpURLResponse respondsToSelector:@selector(statusCode)] ? [_httpURLResponse statusCode] : 200);
}
- (NSDictionary*)allHeaderFields
- (NSDictionary *)allHeaderFields
{
if ([self wasLoadedFromCache]) {
return _responseHeaders;
@@ -362,7 +362,7 @@ return __VA_ARGS__;
return ([_httpURLResponse respondsToSelector:@selector(allHeaderFields)] ? [_httpURLResponse allHeaderFields] : nil);
}
- (NSArray*)cookies
- (NSArray *)cookies
{
return [NSHTTPCookie cookiesWithResponseHeaderFields:self.allHeaderFields forURL:self.URL];
}
@@ -472,24 +472,24 @@ return __VA_ARGS__;
return ([self statusCode] == 503);
}
- (NSString*)contentType
- (NSString *)contentType
{
return ([[self allHeaderFields] objectForKey:@"Content-Type"]);
}
- (NSString*)contentLength
- (NSString *)contentLength
{
return ([[self allHeaderFields] objectForKey:@"Content-Length"]);
}
- (NSString*)location
- (NSString *)location
{
return ([[self allHeaderFields] objectForKey:@"Location"]);
}
- (BOOL)isHTML
{
NSString* contentType = [self contentType];
NSString *contentType = [self contentType];
return (contentType && ([contentType rangeOfString:@"text/html"
options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0 ||
[self isXHTML]));
@@ -497,7 +497,7 @@ return __VA_ARGS__;
- (BOOL)isXHTML
{
NSString* contentType = [self contentType];
NSString *contentType = [self contentType];
return (contentType &&
[contentType rangeOfString:@"application/xhtml+xml"
options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0);
@@ -505,7 +505,7 @@ return __VA_ARGS__;
- (BOOL)isXML
{
NSString* contentType = [self contentType];
NSString *contentType = [self contentType];
return (contentType &&
[contentType rangeOfString:@"application/xml"
options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0);
@@ -513,7 +513,7 @@ return __VA_ARGS__;
- (BOOL)isJSON
{
NSString* contentType = [self contentType];
NSString *contentType = [self contentType];
return (contentType &&
[contentType rangeOfString:@"application/json"
options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0);

View File

@@ -80,11 +80,11 @@
NSString *resourcePathWithoutQueryString = (queryCharacterRange.location == NSNotFound) ? theResourcePath : [theResourcePath substringToIndex:queryCharacterRange.location];
NSString *baseURLPath = [[theBaseURL path] isEqualToString:@"/"] ? @"" : [[theBaseURL path] stringByStandardizingPath];
NSString *completePath = resourcePathWithoutQueryString ? [baseURLPath stringByAppendingString:resourcePathWithoutQueryString] : baseURLPath;
NSString* completePathWithQuery = [completePath stringByAppendingQueryParameters:mergedQueryParameters];
NSString *completePathWithQuery = [completePath stringByAppendingQueryParameters:mergedQueryParameters];
// NOTE: You can't safely use initWithString:relativeToURL: in a NSURL subclass, see http://www.openradar.me/9729706
// So we unfortunately convert into an NSURL before going back into an NSString -> RKURL
NSURL* completeURL = [NSURL URLWithString:completePathWithQuery relativeToURL:theBaseURL];
NSURL *completeURL = [NSURL URLWithString:completePathWithQuery relativeToURL:theBaseURL];
if (!completeURL) {
RKLogError(@"Failed to build RKURL by appending resourcePath and query parameters '%@' to baseURL '%@'", theResourcePath, theBaseURL);
[self release];

View File

@@ -87,7 +87,7 @@ typedef RKObjectMapping *(^RKDynamicObjectMappingDelegateBlock)(id);
the gender of the person. When the gender is 'male', we want to use the Boy class and when then the gender
is 'female' we want to use the Girl class. We might define our dynamic mapping like so:
RKDynamicObjectMapping* mapping = [RKDynamicObjectMapping dynamicMapping];
RKDynamicObjectMapping *mapping = [RKDynamicObjectMapping dynamicMapping];
[mapping setObjectMapping:boyMapping whenValueOfKeyPath:@"gender" isEqualTo:@"male"];
[mapping setObjectMapping:boyMapping whenValueOfKeyPath:@"gender" isEqualTo:@"female"];
*/

View File

@@ -32,7 +32,7 @@
@synthesize delegate = _delegate;
@synthesize objectMappingForDataBlock = _objectMappingForDataBlock;
+ (RKDynamicObjectMapping*)dynamicMapping
+ (RKDynamicObjectMapping *)dynamicMapping
{
return [[self new] autorelease];
}
@@ -41,12 +41,12 @@
+ (RKDynamicObjectMapping *)dynamicMappingUsingBlock:(void(^)(RKDynamicObjectMapping *))block
{
RKDynamicObjectMapping* mapping = [self dynamicMapping];
RKDynamicObjectMapping *mapping = [self dynamicMapping];
block(mapping);
return mapping;
}
+ (RKDynamicObjectMapping*)dynamicMappingWithBlock:(void(^)(RKDynamicObjectMapping*))block
+ (RKDynamicObjectMapping *)dynamicMappingWithBlock:(void(^)(RKDynamicObjectMapping *))block
{
return [self dynamicMappingUsingBlock:block];
}
@@ -69,23 +69,23 @@
[super dealloc];
}
- (void)setObjectMapping:(RKObjectMapping*)objectMapping whenValueOfKeyPath:(NSString*)keyPath isEqualTo:(id)value
- (void)setObjectMapping:(RKObjectMapping *)objectMapping whenValueOfKeyPath:(NSString *)keyPath isEqualTo:(id)value
{
RKLogDebug(@"Adding dynamic object mapping for key '%@' with value '%@' to destination class: %@", keyPath, value, NSStringFromClass(objectMapping.objectClass));
RKDynamicObjectMappingMatcher* matcher = [[RKDynamicObjectMappingMatcher alloc] initWithKey:keyPath value:value objectMapping:objectMapping];
RKDynamicObjectMappingMatcher *matcher = [[RKDynamicObjectMappingMatcher alloc] initWithKey:keyPath value:value objectMapping:objectMapping];
[_matchers addObject:matcher];
[matcher release];
}
- (RKObjectMapping*)objectMappingForDictionary:(NSDictionary*)data
- (RKObjectMapping *)objectMappingForDictionary:(NSDictionary *)data
{
NSAssert([data isKindOfClass:[NSDictionary class]], @"Dynamic object mapping can only be performed on NSDictionary mappables, got %@", NSStringFromClass([data class]));
RKObjectMapping* mapping = nil;
RKObjectMapping *mapping = nil;
RKLogTrace(@"Performing dynamic object mapping for mappable data: %@", data);
// Consult the declarative matchers first
for (RKDynamicObjectMappingMatcher* matcher in _matchers) {
for (RKDynamicObjectMappingMatcher *matcher in _matchers) {
if ([matcher isMatchForData:data]) {
RKLogTrace(@"Found declarative match for data: %@.", [matcher matchDescription]);
return matcher.objectMapping;

View File

@@ -11,20 +11,20 @@
@interface RKDynamicObjectMappingMatcher : NSObject {
NSString* _keyPath;
NSString *_keyPath;
id _value;
RKObjectMapping* _objectMapping;
NSString* _primaryKeyAttribute;
RKObjectMapping *_objectMapping;
NSString *_primaryKeyAttribute;
BOOL (^_isMatchForDataBlock)(id data);
}
@property (nonatomic, readonly) RKObjectMapping* objectMapping;
@property (nonatomic, readonly) NSString* primaryKeyAttribute;
@property (nonatomic, readonly) RKObjectMapping *objectMapping;
@property (nonatomic, readonly) NSString *primaryKeyAttribute;
- (id)initWithKey:(NSString*)key value:(id)value objectMapping:(RKObjectMapping*)objectMapping;
- (id)initWithKey:(NSString*)key value:(id)value primaryKeyAttribute:(NSString*)primaryKeyAttribute;
- (id)initWithPrimaryKeyAttribute:(NSString*)primaryKeyAttribute evaluationBlock:(BOOL (^)(id data))block;
- (id)initWithKey:(NSString *)key value:(id)value objectMapping:(RKObjectMapping *)objectMapping;
- (id)initWithKey:(NSString *)key value:(id)value primaryKeyAttribute:(NSString *)primaryKeyAttribute;
- (id)initWithPrimaryKeyAttribute:(NSString *)primaryKeyAttribute evaluationBlock:(BOOL (^)(id data))block;
- (BOOL)isMatchForData:(id)data;
- (NSString*)matchDescription;
- (NSString *)matchDescription;
@end

View File

@@ -19,7 +19,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue);
@synthesize objectMapping = _objectMapping;
@synthesize primaryKeyAttribute = _primaryKeyAttribute;
- (id)initWithKey:(NSString*)key value:(id)value objectMapping:(RKObjectMapping*)objectMapping
- (id)initWithKey:(NSString *)key value:(id)value objectMapping:(RKObjectMapping *)objectMapping
{
self = [super init];
if (self) {
@@ -31,7 +31,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue);
return self;
}
- (id)initWithKey:(NSString*)key value:(id)value primaryKeyAttribute:(NSString*)primaryKeyAttribute
- (id)initWithKey:(NSString *)key value:(id)value primaryKeyAttribute:(NSString *)primaryKeyAttribute
{
self = [super init];
if (self) {
@@ -43,7 +43,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue);
return self;
}
- (id)initWithPrimaryKeyAttribute:(NSString*)primaryKeyAttribute evaluationBlock:(BOOL (^)(id data))block
- (id)initWithPrimaryKeyAttribute:(NSString *)primaryKeyAttribute evaluationBlock:(BOOL (^)(id data))block
{
self = [super init];
if (self) {
@@ -73,7 +73,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue);
return RKObjectIsValueEqualToValue([data valueForKeyPath:_keyPath], _value);
}
- (NSString*)matchDescription
- (NSString *)matchDescription
{
if (_isMatchForDataBlock) {
return @"No description available. Using block to perform match.";

View File

@@ -24,12 +24,12 @@
A destination class for mapping simple remote error messages.
*/
@interface RKErrorMessage : NSObject {
NSString* _errorMessage;
NSString *_errorMessage;
}
/**
The error message string mapped from the response payload
*/
@property (nonatomic, retain) NSString* errorMessage;
@property (nonatomic, retain) NSString *errorMessage;
@end

View File

@@ -31,7 +31,7 @@
[super dealloc];
}
- (NSString*)description
- (NSString *)description
{
return _errorMessage;
}

View File

@@ -20,7 +20,7 @@
#import "RKObjectAttributeMapping.h"
extern NSString* const RKObjectMappingNestingAttributeKeyName;
extern NSString * const RKObjectMappingNestingAttributeKeyName;
@implementation RKObjectAttributeMapping
@@ -45,7 +45,7 @@ extern NSString* const RKObjectMappingNestingAttributeKeyName;
- (id)copyWithZone:(NSZone *)zone
{
RKObjectAttributeMapping* copy = [[[self class] allocWithZone:zone] initWithSourceKeyPath:self.sourceKeyPath andDestinationKeyPath:self.destinationKeyPath];
RKObjectAttributeMapping *copy = [[[self class] allocWithZone:zone] initWithSourceKeyPath:self.sourceKeyPath andDestinationKeyPath:self.destinationKeyPath];
return copy;
}

View File

@@ -285,6 +285,6 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction
@class RKObjectManager;
@interface RKObjectLoader (Deprecations)
+ (id)loaderWithResourcePath:(NSString*)resourcePath objectManager:(RKObjectManager*)objectManager delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (id)initWithResourcePath:(NSString*)resourcePath objectManager:(RKObjectManager*)objectManager delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
+ (id)loaderWithResourcePath:(NSString *)resourcePath objectManager:(RKObjectManager *)objectManager delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (id)initWithResourcePath:(NSString *)resourcePath objectManager:(RKObjectManager *)objectManager delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
@end

View File

@@ -139,11 +139,11 @@
}
// Invoked on the main thread. Inform the delegate.
- (void)informDelegateOfObjectLoadWithResultDictionary:(NSDictionary*)resultDictionary
- (void)informDelegateOfObjectLoadWithResultDictionary:(NSDictionary *)resultDictionary
{
NSAssert([NSThread isMainThread], @"RKObjectLoaderDelegate callbacks must occur on the main thread");
RKObjectMappingResult* result = [RKObjectMappingResult mappingResultWithDictionary:resultDictionary];
RKObjectMappingResult *result = [RKObjectMappingResult mappingResultWithDictionary:resultDictionary];
// Dictionary callback
if ([self.delegate respondsToSelector:@selector(objectLoader:didLoadObjectDictionary:)]) {
@@ -182,7 +182,7 @@
at thread boundaries.
@protected
*/
- (void)processMappingResult:(RKObjectMappingResult*)result
- (void)processMappingResult:(RKObjectMappingResult *)result
{
NSAssert(_sentSynchronously || ![NSThread isMainThread], @"Mapping result processing should occur on a background thread");
[self performSelectorOnMainThread:@selector(informDelegateOfObjectLoadWithResultDictionary:) withObject:[result asDictionary] waitUntilDone:YES];
@@ -190,7 +190,7 @@
#pragma mark - Response Object Mapping
- (RKObjectMappingResult*)mapResponseWithMappingProvider:(RKObjectMappingProvider*)mappingProvider toObject:(id)targetObject inContext:(RKObjectMappingProviderContext)context error:(NSError**)error
- (RKObjectMappingResult *)mapResponseWithMappingProvider:(RKObjectMappingProvider *)mappingProvider toObject:(id)targetObject inContext:(RKObjectMappingProviderContext)context error:(NSError **)error
{
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:self.response.MIMEType];
NSAssert1(parser, @"Cannot perform object load without a parser for MIME Type '%@'", self.response.MIMEType);
@@ -220,11 +220,11 @@
[(NSObject<RKObjectLoaderDelegate>*)self.delegate objectLoader:self willMapData:&parsedData];
}
RKObjectMapper* mapper = [RKObjectMapper mapperWithObject:parsedData mappingProvider:mappingProvider];
RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:parsedData mappingProvider:mappingProvider];
mapper.targetObject = targetObject;
mapper.delegate = self;
mapper.context = context;
RKObjectMappingResult* result = [mapper performMapping];
RKObjectMappingResult *result = [mapper performMapping];
// Log any mapping errors
if (mapper.errorCount > 0) {
@@ -250,11 +250,11 @@
return [self.mappingProvider objectMappingForResourcePath:self.resourcePath];
}
- (RKObjectMappingResult*)performMapping:(NSError**)error
- (RKObjectMappingResult *)performMapping:(NSError **)error
{
NSAssert(_sentSynchronously || ![NSThread isMainThread], @"Mapping should occur on a background thread");
RKObjectMappingProvider* mappingProvider;
RKObjectMappingProvider *mappingProvider;
RKObjectMappingDefinition *configuredObjectMapping = [self configuredObjectMapping];
if (configuredObjectMapping) {
mappingProvider = [RKObjectMappingProvider mappingProvider];
@@ -275,7 +275,7 @@
{
NSAssert(self.mappingQueue, @"mappingQueue cannot be nil");
dispatch_async(self.mappingQueue, ^{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
RKLogDebug(@"Beginning object mapping activities within GCD queue labeled: %s", dispatch_queue_get_label(self.mappingQueue));
NSError *error = nil;
@@ -291,7 +291,7 @@
});
}
- (BOOL)canParseMIMEType:(NSString*)MIMEType
- (BOOL)canParseMIMEType:(NSString *)MIMEType
{
if ([[RKParserRegistry sharedRegistry] parserForMIMEType:self.response.MIMEType]) {
return YES;
@@ -327,7 +327,7 @@
} else if (NO == [self canParseMIMEType:[self.response MIMEType]]) {
// We can't parse the response, it's unmappable regardless of the status code
RKLogWarning(@"Encountered unexpected response with status code: %ld (MIME Type: %@ -> URL: %@)", (long) self.response.statusCode, self.response.MIMEType, self.URL);
NSError* error = [NSError errorWithDomain:RKErrorDomain code:RKObjectLoaderUnexpectedResponseError userInfo:nil];
NSError *error = [NSError errorWithDomain:RKErrorDomain code:RKObjectLoaderUnexpectedResponseError userInfo:nil];
if ([_delegate respondsToSelector:@selector(objectLoaderDidLoadUnexpectedResponse:)]) {
[(NSObject<RKObjectLoaderDelegate>*)_delegate objectLoaderDidLoadUnexpectedResponse:self];
} else {
@@ -372,8 +372,8 @@
if ((self.sourceObject && self.params == nil) && (self.method == RKRequestMethodPOST || self.method == RKRequestMethodPUT)) {
NSAssert(self.serializationMapping, @"You must provide a serialization mapping for objects of type '%@'", NSStringFromClass([self.sourceObject class]));
RKLogDebug(@"POST or PUT request for source object %@, serializing to MIME Type %@ for transport...", self.sourceObject, self.serializationMIMEType);
RKObjectSerializer* serializer = [RKObjectSerializer serializerWithObject:self.sourceObject mapping:self.serializationMapping];
NSError* error = nil;
RKObjectSerializer *serializer = [RKObjectSerializer serializerWithObject:self.sourceObject mapping:self.serializationMapping];
NSError *error = nil;
id params = [serializer serializationForMIMEType:self.serializationMIMEType error:&error];
if (error) {
@@ -402,7 +402,7 @@
- (void)didFailLoadWithError:(NSError *)error
{
NSParameterAssert(error);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (_cachePolicy & RKRequestCachePolicyLoadOnError &&
[self.cache hasResponseForRequest:self]) {
@@ -419,7 +419,7 @@
// If we failed due to a transport error or before we have a response, the request itself failed
if (!self.response || [self.response isFailure]) {
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:error forKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey];
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:error forKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey];
[[NSNotificationCenter defaultCenter] postNotificationName:RKRequestDidFailWithErrorNotification
object:self
userInfo:userInfo];
@@ -436,7 +436,7 @@
}
// NOTE: We do NOT call super here. We are overloading the default behavior from RKRequest
- (void)didFinishLoad:(RKResponse*)response
- (void)didFinishLoad:(RKResponse *)response
{
NSAssert([NSThread isMainThread], @"RKObjectLoaderDelegate callbacks must occur on the main thread");
self.response = response;
@@ -460,7 +460,7 @@
}
// Post the notification
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:self.response
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:self.response
forKey:RKRequestDidLoadResponseNotificationUserInfoResponseKey];
[[NSNotificationCenter defaultCenter] postNotificationName:RKRequestDidLoadResponseNotification
object:self
@@ -469,7 +469,7 @@
if ([self isResponseMappable]) {
// Determine if we are synchronous here or not.
if (_sentSynchronously) {
NSError* error = nil;
NSError *error = nil;
_result = [[self performMapping:&error] retain];
if (self.result) {
[self processMappingResult:self.result];
@@ -511,12 +511,12 @@
@implementation RKObjectLoader (Deprecations)
+ (id)loaderWithResourcePath:(NSString*)resourcePath objectManager:(RKObjectManager*)objectManager delegate:(id<RKObjectLoaderDelegate>)delegate
+ (id)loaderWithResourcePath:(NSString *)resourcePath objectManager:(RKObjectManager *)objectManager delegate:(id<RKObjectLoaderDelegate>)delegate
{
return [[[self alloc] initWithResourcePath:resourcePath objectManager:objectManager delegate:delegate] autorelease];
}
- (id)initWithResourcePath:(NSString*)resourcePath objectManager:(RKObjectManager*)objectManager delegate:(id<RKObjectLoaderDelegate>)theDelegate
- (id)initWithResourcePath:(NSString *)resourcePath objectManager:(RKObjectManager *)objectManager delegate:(id<RKObjectLoaderDelegate>)theDelegate
{
if ((self = [self initWithURL:[objectManager.baseURL URLByAppendingResourcePath:resourcePath] mappingProvider:objectManager.mappingProvider])) {
[objectManager.client configureRequest:self];

View File

@@ -22,12 +22,12 @@
@interface RKObjectLoader (Internals) <RKObjectMapperDelegate>
@property (nonatomic, readonly) RKClient* client;
@property (nonatomic, readonly) RKClient *client;
- (void)handleTargetObject;
- (void)informDelegateOfObjectLoadWithResultDictionary:(NSDictionary*)dictionary;
- (void)informDelegateOfObjectLoadWithResultDictionary:(NSDictionary *)dictionary;
- (void)performMappingOnBackgroundThread;
- (BOOL)isResponseMappable;
- (void)finalizeLoad:(BOOL)successful error:(NSError*)error;
- (void)finalizeLoad:(BOOL)successful error:(NSError *)error;
@end

View File

@@ -32,12 +32,12 @@
/**
Posted when the object managed has transitioned to the offline state
*/
extern NSString* const RKObjectManagerDidBecomeOfflineNotification;
extern NSString * const RKObjectManagerDidBecomeOfflineNotification;
/**
Posted when the object managed has transitioned to the online state
*/
extern NSString* const RKObjectManagerDidBecomeOnlineNotification;
extern NSString * const RKObjectManagerDidBecomeOnlineNotification;
typedef enum {
RKObjectManagerNetworkStatusUnknown,
@@ -93,8 +93,8 @@ typedef enum {
Mappings are registered by constructing instances of RKObjectMapping and registering them with the provider:
`
RKObjectManager* manager = [RKObjectManager managerWithBaseURL:myBaseURL];
RKObjectMapping* articleMapping = [RKObjectMapping mappingForClass:[Article class]];
RKObjectManager *manager = [RKObjectManager managerWithBaseURL:myBaseURL];
RKObjectMapping *articleMapping = [RKObjectMapping mappingForClass:[Article class]];
[mapping mapAttributes:@"title", @"body", @"publishedAt", nil];
[manager.mappingProvider setObjectMapping:articleMapping forKeyPath:@"article"];
@@ -366,7 +366,7 @@ typedef enum {
For example:
- (void)loadObjectUsingBlockExample {
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/monkeys.json" usingBlock:^(RKObjectLoader* loader) {
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/monkeys.json" usingBlock:^(RKObjectLoader *loader) {
loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[Monkey class]];
}];
}
@@ -379,16 +379,16 @@ typedef enum {
For example:
- (BOOL)changePassword:(NSString*)newPassword error:(NSError**)error {
- (BOOL)changePassword:(NSString *)newPassword error:(NSError **)error {
if ([self validatePassword:newPassword error:error]) {
self.password = newPassword;
[[RKObjectManager sharedManager] sendObject:self toResourcePath:@"/some/path" usingBlock:^(RKObjectLoader* loader) {
[[RKObjectManager sharedManager] sendObject:self toResourcePath:@"/some/path" usingBlock:^(RKObjectLoader *loader) {
loader.delegate = self;
loader.method = RKRequestMethodPOST;
loader.serializationMIMEType = RKMIMETypeJSON; // We want to send this request as JSON
loader.targetObject = nil; // Map the results back onto a new object instead of self
// Set up a custom serialization mapping to handle this request
loader.serializationMapping = [RKObjectMapping serializationMappingUsingBlock:^(RKObjectMapping* mapping) {
loader.serializationMapping = [RKObjectMapping serializationMappingUsingBlock:^(RKObjectMapping *mapping) {
[mapping mapAttributes:@"password", nil];
}];
}];
@@ -434,8 +434,8 @@ typedef enum {
+ (RKObjectManager *)objectManagerWithBaseURLString:(NSString *)baseURLString;
+ (RKObjectManager *)objectManagerWithBaseURL:(NSURL *)baseURL;
- (void)loadObjectsAtResourcePath:(NSString*)resourcePath objectMapping:(RKObjectMapping*)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (RKObjectLoader *)objectLoaderWithResourcePath:(NSString*)resourcePath delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (void)loadObjectsAtResourcePath:(NSString *)resourcePath objectMapping:(RKObjectMapping *)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (RKObjectLoader *)objectLoaderWithResourcePath:(NSString *)resourcePath delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (RKObjectLoader *)objectLoaderForObject:(id<NSObject>)object method:(RKRequestMethod)method delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
/*
@@ -444,7 +444,7 @@ typedef enum {
The mapResponseWith: family of methods have been deprecated by the support for object mapping selection
using resourcePath's
*/
- (RKObjectLoader*)objectLoaderForObject:(id<NSObject>)object method:(RKRequestMethod)method delegate:(id<RKObjectLoaderDelegate>)delegate;
- (RKObjectLoader *)objectLoaderForObject:(id<NSObject>)object method:(RKRequestMethod)method delegate:(id<RKObjectLoaderDelegate>)delegate;
- (RKObjectLoader *)objectLoaderForObject:(id<NSObject>)object method:(RKRequestMethod)method delegate:(id<RKObjectLoaderDelegate>)delegate;
- (void)getObject:(id<NSObject>)object mapResponseWith:(RKObjectMapping *)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;
- (void)postObject:(id<NSObject>)object mapResponseWith:(RKObjectMapping *)objectMapping delegate:(id<RKObjectLoaderDelegate>)delegate DEPRECATED_ATTRIBUTE;

View File

@@ -24,8 +24,8 @@
#import "RKManagedObjectLoader.h"
#import "Support.h"
NSString* const RKObjectManagerDidBecomeOfflineNotification = @"RKDidEnterOfflineModeNotification";
NSString* const RKObjectManagerDidBecomeOnlineNotification = @"RKDidEnterOnlineModeNotification";
NSString * const RKObjectManagerDidBecomeOfflineNotification = @"RKDidEnterOfflineModeNotification";
NSString * const RKObjectManagerDidBecomeOnlineNotification = @"RKDidEnterOnlineModeNotification";
//////////////////////////////////
// Shared Instances
@@ -263,7 +263,7 @@ static dispatch_queue_t defaultMappingQueue = nil;
- (id)loaderForObject:(id<NSObject>)object method:(RKRequestMethod)method
{
NSString* resourcePath = (method == RKRequestMethodInvalid) ? nil : [self.router resourcePathForObject:object method:method];
NSString *resourcePath = (method == RKRequestMethodInvalid) ? nil : [self.router resourcePathForObject:object method:method];
RKObjectLoader *loader = [self loaderWithResourcePath:resourcePath];
loader.method = method;
loader.sourceObject = object;
@@ -324,9 +324,9 @@ static dispatch_queue_t defaultMappingQueue = nil;
#pragma mark - Block Configured Object Loaders
- (void)loadObjectsAtResourcePath:(NSString*)resourcePath usingBlock:(void(^)(RKObjectLoader *))block
- (void)loadObjectsAtResourcePath:(NSString *)resourcePath usingBlock:(void(^)(RKObjectLoader *))block
{
RKObjectLoader* loader = [self loaderWithResourcePath:resourcePath];
RKObjectLoader *loader = [self loaderWithResourcePath:resourcePath];
loader.method = RKRequestMethodGET;
// Yield to the block for setup
@@ -460,13 +460,13 @@ static dispatch_queue_t defaultMappingQueue = nil;
- (RKObjectLoader *)objectLoaderWithResourcePath:(NSString *)resourcePath delegate:(id<RKObjectLoaderDelegate>)delegate
{
RKObjectLoader* loader = [self loaderWithResourcePath:resourcePath];
RKObjectLoader *loader = [self loaderWithResourcePath:resourcePath];
loader.delegate = delegate;
return loader;
}
- (RKObjectLoader*)objectLoaderForObject:(id<NSObject>)object method:(RKRequestMethod)method delegate:(id<RKObjectLoaderDelegate>)delegate
- (RKObjectLoader *)objectLoaderForObject:(id<NSObject>)object method:(RKRequestMethod)method delegate:(id<RKObjectLoaderDelegate>)delegate
{
RKObjectLoader *loader = [self loaderForObject:object method:method];
loader.delegate = delegate;

View File

@@ -32,15 +32,15 @@
@optional
- (void)objectMapperWillBeginMapping:(RKObjectMapper*)objectMapper;
- (void)objectMapperDidFinishMapping:(RKObjectMapper*)objectMapper;
- (void)objectMapper:(RKObjectMapper*)objectMapper didAddError:(NSError*)error;
- (void)objectMapper:(RKObjectMapper*)objectMapper didFindMappableObject:(id)object atKeyPath:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)mapping;
- (void)objectMapper:(RKObjectMapper*)objectMapper didNotFindMappableObjectAtKeyPath:(NSString*)keyPath;
- (void)objectMapperWillBeginMapping:(RKObjectMapper *)objectMapper;
- (void)objectMapperDidFinishMapping:(RKObjectMapper *)objectMapper;
- (void)objectMapper:(RKObjectMapper *)objectMapper didAddError:(NSError *)error;
- (void)objectMapper:(RKObjectMapper *)objectMapper didFindMappableObject:(id)object atKeyPath:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)mapping;
- (void)objectMapper:(RKObjectMapper *)objectMapper didNotFindMappableObjectAtKeyPath:(NSString *)keyPath;
- (void)objectMapper:(RKObjectMapper*)objectMapper willMapFromObject:(id)sourceObject toObject:(id)destinationObject atKeyPath:(NSString*)keyPath usingMapping:(RKObjectMappingDefinition *)objectMapping;
- (void)objectMapper:(RKObjectMapper*)objectMapper didMapFromObject:(id)sourceObject toObject:(id)destinationObject atKeyPath:(NSString*)keyPath usingMapping:(RKObjectMappingDefinition *)objectMapping;
- (void)objectMapper:(RKObjectMapper*)objectMapper didFailMappingFromObject:(id)sourceObject toObject:(id)destinationObject withError:(NSError*)error atKeyPath:(NSString*)keyPath usingMapping:(RKObjectMappingDefinition *)objectMapping;
- (void)objectMapper:(RKObjectMapper *)objectMapper willMapFromObject:(id)sourceObject toObject:(id)destinationObject atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)objectMapping;
- (void)objectMapper:(RKObjectMapper *)objectMapper didMapFromObject:(id)sourceObject toObject:(id)destinationObject atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)objectMapping;
- (void)objectMapper:(RKObjectMapper *)objectMapper didFailMappingFromObject:(id)sourceObject toObject:(id)destinationObject withError:(NSError *)error atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)objectMapping;
@end
/**
@@ -49,21 +49,21 @@
@interface RKObjectMapper : NSObject {
@protected
RKMappingOperationQueue *operationQueue;
NSMutableArray* errors;
NSMutableArray *errors;
}
@property (nonatomic, readonly) id sourceObject;
@property (nonatomic, assign) id targetObject;
@property (nonatomic, readonly) RKObjectMappingProvider* mappingProvider;
@property (nonatomic, readonly) RKObjectMappingProvider *mappingProvider;
@property (nonatomic, assign) RKObjectMappingProviderContext context;
@property (nonatomic, assign) id<RKObjectMapperDelegate> delegate;
@property (nonatomic, readonly) NSArray* errors;
@property (nonatomic, readonly) NSArray *errors;
+ (id)mapperWithObject:(id)object mappingProvider:(RKObjectMappingProvider*)mappingProvider;
- (id)initWithObject:(id)object mappingProvider:(RKObjectMappingProvider*)mappingProvider;
+ (id)mapperWithObject:(id)object mappingProvider:(RKObjectMappingProvider *)mappingProvider;
- (id)initWithObject:(id)object mappingProvider:(RKObjectMappingProvider *)mappingProvider;
// Primary entry point for the mapper. Examines the type of object and processes it appropriately...
- (RKObjectMappingResult*)performMapping;
- (RKObjectMappingResult *)performMapping;
- (NSUInteger)errorCount;
@end

View File

@@ -94,7 +94,7 @@
@"RKObjectMapperKeyPath", keyPath ? keyPath : (NSString *) [NSNull null],
nil];
[userInfo addEntriesFromDictionary:otherInfo];
NSError* error = [NSError errorWithDomain:RKErrorDomain code:errorCode userInfo:userInfo];
NSError *error = [NSError errorWithDomain:RKErrorDomain code:errorCode userInfo:userInfo];
[self addError:error];
}
@@ -311,7 +311,7 @@
// Found something to map
foundMappable = YES;
RKObjectMappingDefinition * mapping = [mappingsByKeyPath objectForKey:keyPath];
RKObjectMappingDefinition *mapping = [mappingsByKeyPath objectForKey:keyPath];
if ([self.delegate respondsToSelector:@selector(objectMapper:didFindMappableObject:atKeyPath:withMapping:)]) {
[self.delegate objectMapper:self didFindMappableObject:mappableValue atKeyPath:keyPath withMapping:mapping];
}
@@ -351,7 +351,7 @@
} else if ([mappingsForContext isKindOfClass:[RKObjectMappingDefinition class]]) {
id mappableData = self.sourceObject;
if ([mappingsForContext rootKeyPath] != nil) {
NSString* rootKeyPath = [mappingsForContext rootKeyPath];
NSString *rootKeyPath = [mappingsForContext rootKeyPath];
mappableData = [self.sourceObject valueForKeyPath:rootKeyPath];
RKLogDebug(@"Selected object mapping has rootKeyPath. Apply valueForKeyPath to mappable data: %@", rootKeyPath);
}

View File

@@ -21,7 +21,7 @@
@interface RKObjectMapper (Private)
- (id)mapObject:(id)mappableObject atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)mapping;
- (NSArray*)mapCollection:(NSArray*)mappableObjects atKeyPath:(NSString*)keyPath usingMapping:(RKObjectMappingDefinition *)mapping;
- (NSArray *)mapCollection:(NSArray *)mappableObjects atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)mapping;
- (BOOL)mapFromObject:(id)mappableObject toObject:(id)destinationObject atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)mapping;
- (id)objectWithMapping:(RKObjectMappingDefinition *)objectMapping andData:(id)mappableData;

View File

@@ -45,8 +45,8 @@ relationship. Relationships are processed using an object mapping as well.
*/
@interface RKObjectMapping : RKObjectMappingDefinition <NSCopying> {
Class _objectClass;
NSMutableArray* _mappings;
NSString* _rootKeyPath;
NSMutableArray *_mappings;
NSString *_rootKeyPath;
BOOL _setDefaultValueForMissingAttributes;
BOOL _setNilForMissingRelationships;
BOOL _performKeyValueValidation;
@@ -176,8 +176,8 @@ relationship. Relationships are processed using an object mapping as well.
For example, consider we have a one-off request that will load a few attributes for our object.
Using blocks, this is very succinct:
[[RKObjectManager sharedManager] postObject:self usingBlock:^(RKObjectLoader* loader) {
loader.objectMapping = [RKObjectMapping mappingForClass:[Person class] usingBlock:^(RKObjectMapping* mapping) {
[[RKObjectManager sharedManager] postObject:self usingBlock:^(RKObjectLoader *loader) {
loader.objectMapping = [RKObjectMapping mappingForClass:[Person class] usingBlock:^(RKObjectMapping *mapping) {
[mapping mapAttributes:@"email", @"first_name", nil];
}];
}];
@@ -192,11 +192,11 @@ relationship. Relationships are processed using an object mapping as well.
For example, consider we have a one-off request within which we want to post a subset of our object
data. Using blocks, this is very succinct:
- (BOOL)changePassword:(NSString*)newPassword error:(NSError**)error {
- (BOOL)changePassword:(NSString *)newPassword error:(NSError **)error {
if ([self validatePassword:newPassword error:error]) {
self.password = newPassword;
[[RKObjectManager sharedManager] putObject:self delegate:self block:^(RKObjectLoader* loader) {
loader.serializationMapping = [RKObjectMapping serializationMappingUsingBlock:^(RKObjectMapping* mapping) {
[[RKObjectManager sharedManager] putObject:self delegate:self block:^(RKObjectLoader *loader) {
loader.serializationMapping = [RKObjectMapping serializationMappingUsingBlock:^(RKObjectMapping *mapping) {
[mapping mapAttributes:@"password", nil];
}];
}];
@@ -213,14 +213,14 @@ relationship. Relationships are processed using an object mapping as well.
@see RKObjectAttributeMapping
*/
- (void)addAttributeMapping:(RKObjectAttributeMapping*)mapping;
- (void)addAttributeMapping:(RKObjectAttributeMapping *)mapping;
/**
Add a configured attribute mapping to this object mapping
@see RKObjectRelationshipMapping
*/
- (void)addRelationshipMapping:(RKObjectRelationshipMapping*)mapping;
- (void)addRelationshipMapping:(RKObjectRelationshipMapping *)mapping;
#pragma mark - Retrieving Mappings
@@ -230,7 +230,7 @@ relationship. Relationships are processed using an object mapping as well.
@param sourceKeyPath A keyPath within the mappable source object that is mapped to an
attribute or relationship in this object mapping.
*/
- (id)mappingForKeyPath:(NSString*)sourceKeyPath;
- (id)mappingForKeyPath:(NSString *)sourceKeyPath;
/**
Returns the attribute or relationship mapping for the given source keyPath.
@@ -238,7 +238,7 @@ relationship. Relationships are processed using an object mapping as well.
@param sourceKeyPath A keyPath within the mappable source object that is mapped to an
attribute or relationship in this object mapping.
*/
- (id)mappingForSourceKeyPath:(NSString*)sourceKeyPath;
- (id)mappingForSourceKeyPath:(NSString *)sourceKeyPath;
/**
Returns the attribute or relationship mapping for the given destination keyPath.
@@ -259,7 +259,7 @@ relationship. Relationships are processed using an object mapping as well.
@param relationshipKey The name of the relationship we want to retrieve the mapping for
*/
- (RKObjectRelationshipMapping*)mappingForRelationship:(NSString*)relationshipKey;
- (RKObjectRelationshipMapping *)mappingForRelationship:(NSString *)relationshipKey;
#pragma mark - Attribute & Relationship Mapping
@@ -322,14 +322,14 @@ relationship. Relationships are processed using an object mapping as well.
To a Person class with corresponding 'cat' relationship property, we could configure the mappings via:
RKObjectMapping* catMapping = [RKObjectMapping mappingForClass:[Cat class]];
RKObjectMapping *catMapping = [RKObjectMapping mappingForClass:[Cat class]];
[personMapping mapRelationship:@"cat" withObjectMapping:catMapping];
@param relationshipKey A key-value coding key corresponding to a value in the mappable source object and a property
on the destination class that have the same name.
@param objectOrDynamicMapping An RKObjectMapping or RKObjectDynamic mapping to apply when mapping the relationship
*/
- (void)mapRelationship:(NSString*)relationshipKey withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
- (void)mapRelationship:(NSString *)relationshipKey withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
/**
Syntactic sugar to improve readability when defining a relationship mapping. Implies that the mapping
@@ -337,7 +337,7 @@ relationship. Relationships are processed using an object mapping as well.
@see mapRelationship:withObjectMapping:
*/
- (void)hasMany:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
- (void)hasMany:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
/**
Syntactic sugar to improve readability when defining a relationship mapping. Implies that the mapping
@@ -345,7 +345,7 @@ relationship. Relationships are processed using an object mapping as well.
@see mapRelationship:withObjectMapping:
*/
- (void)hasOne:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
- (void)hasOne:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
/**
Instantiate and add an RKObjectAttributeMapping instance targeting a keyPath within the mappable
@@ -365,7 +365,7 @@ relationship. Relationships are processed using an object mapping as well.
@param destinationAttribute The attribute name to assign the mapped value to
@see RKObjectAttributeMapping
*/
- (void)mapKeyPath:(NSString*)sourceKeyPath toAttribute:(NSString*)destinationAttribute;
- (void)mapKeyPath:(NSString *)sourceKeyPath toAttribute:(NSString *)destinationAttribute;
/**
Instantiate and add an RKObjectRelationshipMapping instance targeting a keyPath within the mappable
@@ -386,7 +386,7 @@ relationship. Relationships are processed using an object mapping as well.
@param objectMapping An object mapping to use when processing the nested objects
@see RKObjectRelationshipMapping
*/
- (void)mapKeyPath:(NSString *)sourceKeyPath toRelationship:(NSString*)destinationRelationship withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
- (void)mapKeyPath:(NSString *)sourceKeyPath toRelationship:(NSString *)destinationRelationship withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
/**
Instantiate and add an RKObjectRelationshipMapping instance targeting a keyPath within the mappable
@@ -401,7 +401,7 @@ relationship. Relationships are processed using an object mapping as well.
@see mapKeyPath:toRelationship:withObjectMapping:
*/
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping serialize:(BOOL)serialize;
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping serialize:(BOOL)serialize;
/**
Quickly define a group of attribute mappings using alternating keyPath and attribute names. You must provide
@@ -413,7 +413,7 @@ relationship. Relationships are processed using an object mapping as well.
@param sourceKeyPath A key-value coding key path to fetch a mappable value from
@param ... A nil-terminated sequence of strings alternating between source key paths and destination attributes
*/
- (void)mapKeyPathsToAttributes:(NSString*)sourceKeyPath, ... NS_REQUIRES_NIL_TERMINATION;
- (void)mapKeyPathsToAttributes:(NSString *)sourceKeyPath, ... NS_REQUIRES_NIL_TERMINATION;
/**
@@ -430,7 +430,7 @@ relationship. Relationships are processed using an object mapping as well.
We can configure our mappings to handle this in the following form:
RKObjectMapping* mapping = [RKObjectMapping mappingForClass:[User class]];
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[User class]];
mapping.forceCollectionMapping = YES; // RestKit cannot infer this is a collection, so we force it
[mapping mapKeyOfNestedDictionaryToAttribute:@"firstName"];
[mapping mapFromKeyPath:@"(firstName).id" toAttribute:"userID"];
@@ -459,14 +459,14 @@ relationship. Relationships are processed using an object mapping as well.
@param attributeOrRelationshipMapping The attribute or relationship mapping to remove
*/
- (void)removeMapping:(RKObjectAttributeMapping*)attributeOrRelationshipMapping;
- (void)removeMapping:(RKObjectAttributeMapping *)attributeOrRelationshipMapping;
/**
Remove the attribute or relationship mapping for the specified source keyPath
@param sourceKeyPath A key-value coding key path to remove the mappings for
*/
- (void)removeMappingForKeyPath:(NSString*)sourceKeyPath;
- (void)removeMappingForKeyPath:(NSString *)sourceKeyPath;
#pragma mark - Inverse Mappings
@@ -475,7 +475,7 @@ relationship. Relationships are processed using an object mapping as well.
quickly generate a corresponding serialization mapping from a configured object mapping. The inverse
mapping will have the source and destination keyPaths swapped for all attribute and relationship mappings.
*/
- (RKObjectMapping*)inverseMapping;
- (RKObjectMapping *)inverseMapping;
/**
Returns the default value to be assigned to the specified attribute when it is missing from a
@@ -486,7 +486,7 @@ relationship. Relationships are processed using an object mapping as well.
@see [RKManagedObjectMapping defaultValueForMissingAttribute:]
*/
- (id)defaultValueForMissingAttribute:(NSString*)attributeName;
- (id)defaultValueForMissingAttribute:(NSString *)attributeName;
/**
Returns an auto-released object that can be used to apply this object mapping
@@ -503,7 +503,7 @@ relationship. Relationships are processed using an object mapping as well.
@param propertyName The name of the property we would like to retrieve the type of
*/
- (Class)classForProperty:(NSString*)propertyName;
- (Class)classForProperty:(NSString *)propertyName;
/**
Returns an auto-released object that can be used to apply this object mapping
@@ -514,9 +514,9 @@ relationship. Relationships are processed using an object mapping as well.
- (id)mappableObjectForData:(id)mappableData;
// Deprecations
+ (id)mappingForClass:(Class)objectClass withBlock:(void (^)(RKObjectMapping*))block DEPRECATED_ATTRIBUTE;
+ (id)mappingForClass:(Class)objectClass block:(void (^)(RKObjectMapping*))block DEPRECATED_ATTRIBUTE;
+ (id)serializationMappingWithBlock:(void (^)(RKObjectMapping*))block DEPRECATED_ATTRIBUTE;
+ (id)mappingForClass:(Class)objectClass withBlock:(void (^)(RKObjectMapping *))block DEPRECATED_ATTRIBUTE;
+ (id)mappingForClass:(Class)objectClass block:(void (^)(RKObjectMapping *))block DEPRECATED_ATTRIBUTE;
+ (id)serializationMappingWithBlock:(void (^)(RKObjectMapping *))block DEPRECATED_ATTRIBUTE;
@end

View File

@@ -25,7 +25,7 @@
#import "RKISO8601DateFormatter.h"
// Constants
NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE>";
NSString * const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE>";
@implementation RKObjectMapping
@@ -41,7 +41,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
+ (id)mappingForClass:(Class)objectClass
{
RKObjectMapping* mapping = [self new];
RKObjectMapping *mapping = [self new];
mapping.objectClass = objectClass;
return [mapping autorelease];
}
@@ -58,34 +58,34 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
#if NS_BLOCKS_AVAILABLE
+ (id)mappingForClass:(Class)objectClass usingBlock:(void (^)(RKObjectMapping*))block
+ (id)mappingForClass:(Class)objectClass usingBlock:(void (^)(RKObjectMapping *))block
{
RKObjectMapping* mapping = [self mappingForClass:objectClass];
RKObjectMapping *mapping = [self mappingForClass:objectClass];
block(mapping);
return mapping;
}
+ (id)serializationMappingUsingBlock:(void (^)(RKObjectMapping*))block
+ (id)serializationMappingUsingBlock:(void (^)(RKObjectMapping *))block
{
RKObjectMapping* mapping = [self serializationMapping];
RKObjectMapping *mapping = [self serializationMapping];
block(mapping);
return mapping;
}
// Deprecated... Move to category or bottom...
+ (id)mappingForClass:(Class)objectClass withBlock:(void (^)(RKObjectMapping*))block
+ (id)mappingForClass:(Class)objectClass withBlock:(void (^)(RKObjectMapping *))block
{
return [self mappingForClass:objectClass usingBlock:block];
}
+ (id)mappingForClass:(Class)objectClass block:(void (^)(RKObjectMapping*))block
+ (id)mappingForClass:(Class)objectClass block:(void (^)(RKObjectMapping *))block
{
return [self mappingForClass:objectClass usingBlock:block];
}
+ (id)serializationMappingWithBlock:(void (^)(RKObjectMapping*))block
+ (id)serializationMappingWithBlock:(void (^)(RKObjectMapping *))block
{
RKObjectMapping* mapping = [self serializationMapping];
RKObjectMapping *mapping = [self serializationMapping];
block(mapping);
return mapping;
}
@@ -152,8 +152,8 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
- (NSArray *)attributeMappings
{
NSMutableArray* mappings = [NSMutableArray array];
for (RKObjectAttributeMapping* mapping in self.mappings) {
NSMutableArray *mappings = [NSMutableArray array];
for (RKObjectAttributeMapping *mapping in self.mappings) {
if ([mapping isMemberOfClass:[RKObjectAttributeMapping class]]) {
[mappings addObject:mapping];
}
@@ -164,8 +164,8 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
- (NSArray *)relationshipMappings
{
NSMutableArray* mappings = [NSMutableArray array];
for (RKObjectAttributeMapping* mapping in self.mappings) {
NSMutableArray *mappings = [NSMutableArray array];
for (RKObjectAttributeMapping *mapping in self.mappings) {
if ([mapping isMemberOfClass:[RKObjectRelationshipMapping class]]) {
[mappings addObject:mapping];
}
@@ -174,13 +174,13 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
return mappings;
}
- (void)addAttributeMapping:(RKObjectAttributeMapping*)mapping
- (void)addAttributeMapping:(RKObjectAttributeMapping *)mapping
{
NSAssert1([[self mappedKeyPaths] containsObject:mapping.destinationKeyPath] == NO, @"Unable to add mapping for keyPath %@, one already exists...", mapping.destinationKeyPath);
[_mappings addObject:mapping];
}
- (void)addRelationshipMapping:(RKObjectRelationshipMapping*)mapping
- (void)addRelationshipMapping:(RKObjectRelationshipMapping *)mapping
{
[self addAttributeMapping:mapping];
}
@@ -197,7 +197,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
- (id)mappingForSourceKeyPath:(NSString *)sourceKeyPath
{
for (RKObjectAttributeMapping* mapping in _mappings) {
for (RKObjectAttributeMapping *mapping in _mappings) {
if ([mapping.sourceKeyPath isEqualToString:sourceKeyPath]) {
return mapping;
}
@@ -208,7 +208,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
- (id)mappingForDestinationKeyPath:(NSString *)destinationKeyPath
{
for (RKObjectAttributeMapping* mapping in _mappings) {
for (RKObjectAttributeMapping *mapping in _mappings) {
if ([mapping.destinationKeyPath isEqualToString:destinationKeyPath]) {
return mapping;
}
@@ -219,18 +219,18 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
- (void)mapAttributesCollection:(id<NSFastEnumeration>)attributes
{
for (NSString* attributeKeyPath in attributes) {
for (NSString *attributeKeyPath in attributes) {
[self addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:attributeKeyPath toKeyPath:attributeKeyPath]];
}
}
- (void)mapAttributes:(NSString*)attributeKeyPath, ...
- (void)mapAttributes:(NSString *)attributeKeyPath, ...
{
va_list args;
va_start(args, attributeKeyPath);
NSMutableSet* attributeKeyPaths = [NSMutableSet set];
NSMutableSet *attributeKeyPaths = [NSMutableSet set];
for (NSString* keyPath = attributeKeyPath; keyPath != nil; keyPath = va_arg(args, NSString*)) {
for (NSString *keyPath = attributeKeyPath; keyPath != nil; keyPath = va_arg(args, NSString *)) {
[attributeKeyPaths addObject:keyPath];
}
@@ -249,34 +249,34 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
[self mapAttributesCollection:[NSSet setWithArray:array]];
}
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping serialize:(BOOL)serialize
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping serialize:(BOOL)serialize
{
RKObjectRelationshipMapping* mapping = [RKObjectRelationshipMapping mappingFromKeyPath:relationshipKeyPath toKeyPath:keyPath withMapping:objectOrDynamicMapping reversible:serialize];
RKObjectRelationshipMapping *mapping = [RKObjectRelationshipMapping mappingFromKeyPath:relationshipKeyPath toKeyPath:keyPath withMapping:objectOrDynamicMapping reversible:serialize];
[self addRelationshipMapping:mapping];
}
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
{
[self mapKeyPath:relationshipKeyPath toRelationship:keyPath withMapping:objectOrDynamicMapping serialize:YES];
}
- (void)mapRelationship:(NSString*)relationshipKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
- (void)mapRelationship:(NSString *)relationshipKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
{
[self mapKeyPath:relationshipKeyPath toRelationship:relationshipKeyPath withMapping:objectOrDynamicMapping];
}
- (void)mapKeyPath:(NSString*)sourceKeyPath toAttribute:(NSString*)destinationKeyPath
- (void)mapKeyPath:(NSString *)sourceKeyPath toAttribute:(NSString *)destinationKeyPath
{
RKObjectAttributeMapping* mapping = [RKObjectAttributeMapping mappingFromKeyPath:sourceKeyPath toKeyPath:destinationKeyPath];
RKObjectAttributeMapping *mapping = [RKObjectAttributeMapping mappingFromKeyPath:sourceKeyPath toKeyPath:destinationKeyPath];
[self addAttributeMapping:mapping];
}
- (void)hasMany:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
- (void)hasMany:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
{
[self mapRelationship:keyPath withMapping:objectOrDynamicMapping];
}
- (void)hasOne:(NSString*)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
- (void)hasOne:(NSString *)keyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
{
[self mapRelationship:keyPath withMapping:objectOrDynamicMapping];
}
@@ -286,53 +286,53 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
[_mappings removeAllObjects];
}
- (void)removeMapping:(RKObjectAttributeMapping*)attributeOrRelationshipMapping
- (void)removeMapping:(RKObjectAttributeMapping *)attributeOrRelationshipMapping
{
[_mappings removeObject:attributeOrRelationshipMapping];
}
- (void)removeMappingForKeyPath:(NSString*)keyPath
- (void)removeMappingForKeyPath:(NSString *)keyPath
{
RKObjectAttributeMapping* mapping = [self mappingForKeyPath:keyPath];
RKObjectAttributeMapping *mapping = [self mappingForKeyPath:keyPath];
[self removeMapping:mapping];
}
#ifndef MAX_INVERSE_MAPPING_RECURSION_DEPTH
#define MAX_INVERSE_MAPPING_RECURSION_DEPTH (100)
#endif
- (RKObjectMapping*)inverseMappingAtDepth:(NSInteger)depth
- (RKObjectMapping *)inverseMappingAtDepth:(NSInteger)depth
{
NSAssert(depth < MAX_INVERSE_MAPPING_RECURSION_DEPTH, @"Exceeded max recursion level in inverseMapping. This is likely due to a loop in the serialization graph. To break this loop, specify one-way relationships by setting serialize to NO in mapKeyPath:toRelationship:withObjectMapping:serialize:");
RKObjectMapping* inverseMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
for (RKObjectAttributeMapping* attributeMapping in self.attributeMappings) {
RKObjectMapping *inverseMapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
for (RKObjectAttributeMapping *attributeMapping in self.attributeMappings) {
[inverseMapping mapKeyPath:attributeMapping.destinationKeyPath toAttribute:attributeMapping.sourceKeyPath];
}
for (RKObjectRelationshipMapping* relationshipMapping in self.relationshipMappings) {
for (RKObjectRelationshipMapping *relationshipMapping in self.relationshipMappings) {
if (relationshipMapping.reversible) {
RKObjectMappingDefinition * mapping = relationshipMapping.mapping;
RKObjectMappingDefinition *mapping = relationshipMapping.mapping;
if (! [mapping isKindOfClass:[RKObjectMapping class]]) {
RKLogWarning(@"Unable to generate inverse mapping for relationship '%@': %@ relationships cannot be inversed.", relationshipMapping.sourceKeyPath, NSStringFromClass([mapping class]));
continue;
}
[inverseMapping mapKeyPath:relationshipMapping.destinationKeyPath toRelationship:relationshipMapping.sourceKeyPath withMapping:[(RKObjectMapping*)mapping inverseMappingAtDepth:depth+1]];
[inverseMapping mapKeyPath:relationshipMapping.destinationKeyPath toRelationship:relationshipMapping.sourceKeyPath withMapping:[(RKObjectMapping *)mapping inverseMappingAtDepth:depth+1]];
}
}
return inverseMapping;
}
- (RKObjectMapping*)inverseMapping
- (RKObjectMapping *)inverseMapping
{
return [self inverseMappingAtDepth:0];
}
- (void)mapKeyPathsToAttributes:(NSString*)firstKeyPath, ...
- (void)mapKeyPathsToAttributes:(NSString *)firstKeyPath, ...
{
va_list args;
va_start(args, firstKeyPath);
for (NSString* keyPath = firstKeyPath; keyPath != nil; keyPath = va_arg(args, NSString*)) {
NSString* attributeKeyPath = va_arg(args, NSString*);
for (NSString *keyPath = firstKeyPath; keyPath != nil; keyPath = va_arg(args, NSString *)) {
NSString *attributeKeyPath = va_arg(args, NSString *);
NSAssert(attributeKeyPath != nil, @"Cannot map a keyPath without a destination attribute keyPath");
[self mapKeyPath:keyPath toAttribute:attributeKeyPath];
// TODO: Raise proper exception here, argument error...
@@ -340,7 +340,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
va_end(args);
}
- (void)mapKeyOfNestedDictionaryToAttribute:(NSString*)attributeName
- (void)mapKeyOfNestedDictionaryToAttribute:(NSString *)attributeName
{
[self mapKeyPath:RKObjectMappingNestingAttributeKeyName toAttribute:attributeName];
}
@@ -350,9 +350,9 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
return [self mappingForKeyPath:RKObjectMappingNestingAttributeKeyName];
}
- (RKObjectAttributeMapping*)mappingForAttribute:(NSString*)attributeKey
- (RKObjectAttributeMapping *)mappingForAttribute:(NSString *)attributeKey
{
for (RKObjectAttributeMapping* mapping in [self attributeMappings]) {
for (RKObjectAttributeMapping *mapping in [self attributeMappings]) {
if ([mapping.destinationKeyPath isEqualToString:attributeKey]) {
return mapping;
}
@@ -361,9 +361,9 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
return nil;
}
- (RKObjectRelationshipMapping*)mappingForRelationship:(NSString*)relationshipKey
- (RKObjectRelationshipMapping *)mappingForRelationship:(NSString *)relationshipKey
{
for (RKObjectRelationshipMapping* mapping in [self relationshipMappings]) {
for (RKObjectRelationshipMapping *mapping in [self relationshipMappings]) {
if ([mapping.destinationKeyPath isEqualToString:relationshipKey]) {
return mapping;
}
@@ -372,7 +372,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
return nil;
}
- (id)defaultValueForMissingAttribute:(NSString*)attributeName
- (id)defaultValueForMissingAttribute:(NSString *)attributeName
{
return nil;
}
@@ -382,7 +382,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @"<RK_NESTING_ATTRIBUTE
return [[self.objectClass new] autorelease];
}
- (Class)classForProperty:(NSString*)propertyName
- (Class)classForProperty:(NSString *)propertyName
{
return [[RKObjectPropertyInspector sharedInspector] typeForProperty:propertyName ofClass:self.objectClass];
}

View File

@@ -97,10 +97,10 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
_destinationObject = [destinationObject retain];
if ([objectMapping isKindOfClass:[RKDynamicObjectMapping class]]) {
_objectMapping = [[(RKDynamicObjectMapping*)objectMapping objectMappingForDictionary:_sourceObject] retain];
_objectMapping = [[(RKDynamicObjectMapping *)objectMapping objectMappingForDictionary:_sourceObject] retain];
RKLogDebug(@"RKObjectMappingOperation was initialized with a dynamic mapping. Determined concrete mapping = %@", _objectMapping);
} else if ([objectMapping isKindOfClass:[RKObjectMapping class]]) {
_objectMapping = (RKObjectMapping*)[objectMapping retain];
_objectMapping = (RKObjectMapping *)[objectMapping retain];
}
NSAssert(_objectMapping, @"Cannot perform a mapping operation with an object mapping");
}
@@ -119,11 +119,11 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
[super dealloc];
}
- (NSDate*)parseDateFromString:(NSString*)string
- (NSDate *)parseDateFromString:(NSString *)string
{
RKLogTrace(@"Transforming string value '%@' to NSDate...", string);
NSDate* date = nil;
NSDate *date = nil;
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
@@ -168,23 +168,23 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
if ([sourceType isSubclassOfClass:[NSString class]]) {
if ([destinationType isSubclassOfClass:[NSDate class]]) {
// String -> Date
return [self parseDateFromString:(NSString*)value];
return [self parseDateFromString:(NSString *)value];
} else if ([destinationType isSubclassOfClass:[NSURL class]]) {
// String -> URL
return [NSURL URLWithString:(NSString*)value];
return [NSURL URLWithString:(NSString *)value];
} else if ([destinationType isSubclassOfClass:[NSDecimalNumber class]]) {
// String -> Decimal Number
return [NSDecimalNumber decimalNumberWithString:(NSString*)value];
return [NSDecimalNumber decimalNumberWithString:(NSString *)value];
} else if ([destinationType isSubclassOfClass:[NSNumber class]]) {
// String -> Number
NSString* lowercasedString = [(NSString*)value lowercaseString];
NSSet* trueStrings = [NSSet setWithObjects:@"true", @"t", @"yes", nil];
NSSet* booleanStrings = [trueStrings setByAddingObjectsFromSet:[NSSet setWithObjects:@"false", @"f", @"no", nil]];
NSString *lowercasedString = [(NSString *)value lowercaseString];
NSSet *trueStrings = [NSSet setWithObjects:@"true", @"t", @"yes", nil];
NSSet *booleanStrings = [trueStrings setByAddingObjectsFromSet:[NSSet setWithObjects:@"false", @"f", @"no", nil]];
if ([booleanStrings containsObject:lowercasedString]) {
// Handle booleans encoded as Strings
return [NSNumber numberWithBool:[trueStrings containsObject:lowercasedString]];
} else {
return [NSNumber numberWithDouble:[(NSString*)value doubleValue]];
return [NSNumber numberWithDouble:[(NSString *)value doubleValue]];
}
}
} else if (value == [NSNull null] || [value isEqual:[NSNull null]]) {
@@ -193,7 +193,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
} else if ([sourceType isSubclassOfClass:[NSSet class]]) {
// Set -> Array
if ([destinationType isSubclassOfClass:[NSArray class]]) {
return [(NSSet*)value allObjects];
return [(NSSet *)value allObjects];
}
} else if (orderedSetClass && [sourceType isSubclassOfClass:orderedSetClass]) {
// OrderedSet -> Array
@@ -212,11 +212,11 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
} else if ([sourceType isSubclassOfClass:[NSNumber class]] && [destinationType isSubclassOfClass:[NSDate class]]) {
// Number -> Date
if ([destinationType isSubclassOfClass:[NSDate class]]) {
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber*)value intValue]];
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber *)value intValue]];
} else if ([sourceType isSubclassOfClass:NSClassFromString(@"__NSCFBoolean")] && [destinationType isSubclassOfClass:[NSString class]]) {
return ([value boolValue] ? @"true" : @"false");
}
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber*)value doubleValue]];
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber *)value doubleValue]];
} else if ([sourceType isSubclassOfClass:[NSNumber class]] && [destinationType isSubclassOfClass:[NSDecimalNumber class]]) {
// Number -> Decimal Number
return [NSDecimalNumber decimalNumberWithDecimal:[value decimalValue]];
@@ -225,7 +225,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
[destinationType isSubclassOfClass:[NSString class]]) {
return ([value boolValue] ? @"true" : @"false");
if ([destinationType isSubclassOfClass:[NSDate class]]) {
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber*)value intValue]];
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber *)value intValue]];
} else if (([sourceType isSubclassOfClass:NSClassFromString(@"__NSCFBoolean")] || [sourceType isSubclassOfClass:NSClassFromString(@"NSCFBoolean")]) && [destinationType isSubclassOfClass:[NSString class]]) {
return ([value boolValue] ? @"true" : @"false");
}
@@ -234,7 +234,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
} else if ([destinationType isSubclassOfClass:[NSString class]] && [value isKindOfClass:[NSDate class]]) {
// NSDate -> NSString
// Transform using the preferred date formatter
NSString* dateString = nil;
NSString *dateString = nil;
@synchronized(self.objectMapping.preferredDateFormatter) {
dateString = [self.objectMapping.preferredDateFormatter stringForObjectValue:value];
}
@@ -251,7 +251,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return RKObjectIsValueEqualToValue(sourceValue, destinationValue);
}
- (BOOL)validateValue:(id *)value atKeyPath:(NSString*)keyPath
- (BOOL)validateValue:(id *)value atKeyPath:(NSString *)keyPath
{
BOOL success = YES;
@@ -270,7 +270,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return success;
}
- (BOOL)shouldSetValue:(id *)value atKeyPath:(NSString*)keyPath
- (BOOL)shouldSetValue:(id *)value atKeyPath:(NSString *)keyPath
{
id currentValue = [self.destinationObject valueForKeyPath:keyPath];
if (currentValue == [NSNull null] || [currentValue isEqual:[NSNull null]]) {
@@ -304,14 +304,14 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return NO;
}
- (NSArray*)applyNestingToMappings:(NSArray*)mappings
- (NSArray *)applyNestingToMappings:(NSArray *)mappings
{
if (_nestedAttributeSubstitution) {
NSString* searchString = [NSString stringWithFormat:@"(%@)", [[_nestedAttributeSubstitution allKeys] lastObject]];
NSString* replacementString = [[_nestedAttributeSubstitution allValues] lastObject];
NSMutableArray* array = [NSMutableArray arrayWithCapacity:[self.objectMapping.attributeMappings count]];
for (RKObjectAttributeMapping* mapping in mappings) {
RKObjectAttributeMapping* nestedMapping = [mapping copy];
NSString *searchString = [NSString stringWithFormat:@"(%@)", [[_nestedAttributeSubstitution allKeys] lastObject]];
NSString *replacementString = [[_nestedAttributeSubstitution allValues] lastObject];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self.objectMapping.attributeMappings count]];
for (RKObjectAttributeMapping *mapping in mappings) {
RKObjectAttributeMapping *nestedMapping = [mapping copy];
nestedMapping.sourceKeyPath = [nestedMapping.sourceKeyPath stringByReplacingOccurrencesOfString:searchString withString:replacementString];
nestedMapping.destinationKeyPath = [nestedMapping.destinationKeyPath stringByReplacingOccurrencesOfString:searchString withString:replacementString];
[array addObject:nestedMapping];
@@ -324,17 +324,17 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return mappings;
}
- (NSArray*)attributeMappings
- (NSArray *)attributeMappings
{
return [self applyNestingToMappings:self.objectMapping.attributeMappings];
}
- (NSArray*)relationshipMappings
- (NSArray *)relationshipMappings
{
return [self applyNestingToMappings:self.objectMapping.relationshipMappings];
}
- (void)applyAttributeMapping:(RKObjectAttributeMapping*)attributeMapping withValue:(id)value
- (void)applyAttributeMapping:(RKObjectAttributeMapping *)attributeMapping withValue:(id)value
{
if ([self.delegate respondsToSelector:@selector(objectMappingOperation:didFindMapping:forKeyPath:)]) {
[self.delegate objectMappingOperation:self didFindMapping:attributeMapping forKeyPath:attributeMapping.sourceKeyPath];
@@ -373,7 +373,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
RKLogDebug(@"Key-value validation is disabled for mapping, skipping...");
}
for (RKObjectAttributeMapping* attributeMapping in [self attributeMappings]) {
for (RKObjectAttributeMapping *attributeMapping in [self attributeMappings]) {
if ([attributeMapping isMappingForKeyOfNestedDictionary]) {
RKLogTrace(@"Skipping attribute mapping for special keyPath '%@'", attributeMapping.sourceKeyPath);
continue;
@@ -441,15 +441,15 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return [self isTypeACollection:[value class]];
}
- (BOOL)mapNestedObject:(id)anObject toObject:(id)anotherObject withRealtionshipMapping:(RKObjectRelationshipMapping*)relationshipMapping
- (BOOL)mapNestedObject:(id)anObject toObject:(id)anotherObject withRealtionshipMapping:(RKObjectRelationshipMapping *)relationshipMapping
{
NSAssert(anObject, @"Cannot map nested object without a nested source object");
NSAssert(anotherObject, @"Cannot map nested object without a destination object");
NSAssert(relationshipMapping, @"Cannot map a nested object relationship without a relationship mapping");
NSError* error = nil;
NSError *error = nil;
RKLogTrace(@"Performing nested object mapping using mapping %@ for data: %@", relationshipMapping, anObject);
RKObjectMappingOperation* subOperation = [RKObjectMappingOperation mappingOperationFromObject:anObject toObject:anotherObject withMapping:relationshipMapping.mapping];
RKObjectMappingOperation *subOperation = [RKObjectMappingOperation mappingOperationFromObject:anObject toObject:anotherObject withMapping:relationshipMapping.mapping];
subOperation.delegate = self.delegate;
subOperation.queue = self.queue;
if (NO == [subOperation performMapping:&error]) {
@@ -464,7 +464,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
BOOL appliedMappings = NO;
id destinationObject = nil;
for (RKObjectRelationshipMapping* relationshipMapping in [self relationshipMappings]) {
for (RKObjectRelationshipMapping *relationshipMapping in [self relationshipMappings]) {
id value = nil;
@try {
value = [self.sourceObject valueForKeyPath:relationshipMapping.sourceKeyPath];
@@ -497,10 +497,10 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
// If we have forced mapping of a dictionary, map each subdictionary
if ([value isKindOfClass:[NSDictionary class]]) {
RKLogDebug(@"Collection mapping forced for NSDictionary, mapping each key/value independently...");
NSArray* objectsToMap = [NSMutableArray arrayWithCapacity:[value count]];
NSArray *objectsToMap = [NSMutableArray arrayWithCapacity:[value count]];
for (id key in value) {
NSDictionary* dictionaryToMap = [NSDictionary dictionaryWithObject:[value valueForKey:key] forKey:key];
[(NSMutableArray*)objectsToMap addObject:dictionaryToMap];
NSDictionary *dictionaryToMap = [NSDictionary dictionaryWithObject:[value valueForKey:key] forKey:key];
[(NSMutableArray *)objectsToMap addObject:dictionaryToMap];
}
value = objectsToMap;
} else {
@@ -539,16 +539,16 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
RKLogWarning(@"Key path '%@' yielded collection containing another collection rather than a collection of objects: %@", relationshipMapping.sourceKeyPath, value);
}
for (id nestedObject in value) {
RKObjectMappingDefinition * mapping = relationshipMapping.mapping;
RKObjectMapping* objectMapping = nil;
RKObjectMappingDefinition *mapping = relationshipMapping.mapping;
RKObjectMapping *objectMapping = nil;
if ([mapping isKindOfClass:[RKDynamicObjectMapping class]]) {
objectMapping = [(RKDynamicObjectMapping*)mapping objectMappingForDictionary:nestedObject];
objectMapping = [(RKDynamicObjectMapping *)mapping objectMappingForDictionary:nestedObject];
if (! objectMapping) {
RKLogDebug(@"Mapping %@ declined mapping for data %@: returned nil objectMapping", mapping, nestedObject);
continue;
}
} else if ([mapping isKindOfClass:[RKObjectMapping class]]) {
objectMapping = (RKObjectMapping*)mapping;
objectMapping = (RKObjectMapping *)mapping;
} else {
NSAssert(objectMapping, @"Encountered unknown mapping type '%@'", NSStringFromClass([mapping class]));
}
@@ -572,11 +572,11 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
RKLogTrace(@"Found a managedObject collection. About to apply value via mutable[Set|Array]ValueForKey");
if ([destinationObject isKindOfClass:[NSSet class]]) {
RKLogTrace(@"Mapped NSSet relationship object from keyPath '%@' to '%@'. Value: %@", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath, destinationObject);
NSMutableSet* destinationSet = [self.destinationObject mutableSetValueForKey:relationshipMapping.destinationKeyPath];
NSMutableSet *destinationSet = [self.destinationObject mutableSetValueForKey:relationshipMapping.destinationKeyPath];
[destinationSet setSet:destinationObject];
} else if ([destinationObject isKindOfClass:[NSArray class]]) {
RKLogTrace(@"Mapped NSArray relationship object from keyPath '%@' to '%@'. Value: %@", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath, destinationObject);
NSMutableArray* destinationArray = [self.destinationObject mutableArrayValueForKey:relationshipMapping.destinationKeyPath];
NSMutableArray *destinationArray = [self.destinationObject mutableArrayValueForKey:relationshipMapping.destinationKeyPath];
[destinationArray setArray:destinationObject];
} else if (nsOrderedSetClass && [destinationObject isKindOfClass:nsOrderedSetClass]) {
RKLogTrace(@"Mapped NSOrderedSet relationship object from keyPath '%@' to '%@'. Value: %@", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath, destinationObject);
@@ -595,12 +595,12 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
// One to one relationship
RKLogDebug(@"Mapping one to one relationship value at keyPath '%@' to '%@'", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath);
RKObjectMappingDefinition * mapping = relationshipMapping.mapping;
RKObjectMapping* objectMapping = nil;
RKObjectMappingDefinition *mapping = relationshipMapping.mapping;
RKObjectMapping *objectMapping = nil;
if ([mapping isKindOfClass:[RKDynamicObjectMapping class]]) {
objectMapping = [(RKDynamicObjectMapping*)mapping objectMappingForDictionary:value];
objectMapping = [(RKDynamicObjectMapping *)mapping objectMappingForDictionary:value];
} else if ([mapping isKindOfClass:[RKObjectMapping class]]) {
objectMapping = (RKObjectMapping*)mapping;
objectMapping = (RKObjectMapping *)mapping;
}
NSAssert(objectMapping, @"Encountered unknown mapping type '%@'", NSStringFromClass([mapping class]));
destinationObject = [objectMapping mappableObjectForData:value];
@@ -636,7 +636,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
- (void)applyNestedMappings
{
RKObjectAttributeMapping* attributeMapping = [self.objectMapping attributeMappingForKeyOfNestedDictionary];
RKObjectAttributeMapping *attributeMapping = [self.objectMapping attributeMappingForKeyOfNestedDictionary];
if (attributeMapping) {
RKLogDebug(@"Found nested mapping definition to attribute '%@'", attributeMapping.destinationKeyPath);
id attributeValue = [[self.sourceObject allKeys] lastObject];
@@ -650,7 +650,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
}
}
- (BOOL)performMapping:(NSError**)error
- (BOOL)performMapping:(NSError **)error
{
RKLogDebug(@"Starting mapping operation...");
RKLogTrace(@"Performing mapping operation: %@", self);
@@ -679,7 +679,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return NO;
}
- (NSString*)description
- (NSString *)description
{
return [NSString stringWithFormat:@"RKObjectMappingOperation for '%@' object. Mapping values from object %@ to object %@ with object mapping %@",
NSStringFromClass([self.destinationObject class]), self.sourceObject, self.destinationObject, self.objectMapping];

View File

@@ -126,7 +126,7 @@ typedef enum {
We might configure a mapping like so:
RKObjectMapping* mapping = [RKObjectMapping mappingForClass:[Person class]];
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Person class]];
[mapping mapAttributes:@"first_name", @"last_name", nil];
If we want to parse the above JSON and serialize it such that using postObject: or putObject: use the same format,
@@ -139,7 +139,7 @@ typedef enum {
If you want to manipulate the serialization mapping yourself, you can work with the mapping directly:
RKObjectMapping* serializationMappingForPerson = [personMapping inverseMapping];
RKObjectMapping *serializationMappingForPerson = [personMapping inverseMapping];
// NOTE: Serialization mapping default to a nil root keyPath and will serialize to a flat dictionary
[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:serializationMappingForPerson forClass:[Person class]];

View File

@@ -34,7 +34,7 @@
+ (RKObjectMappingProvider *)mappingProviderUsingBlock:(void (^)(RKObjectMappingProvider *mappingProvider))block
{
RKObjectMappingProvider* mappingProvider = [self mappingProvider];
RKObjectMappingProvider *mappingProvider = [self mappingProvider];
block(mappingProvider);
return mappingProvider;
}
@@ -90,7 +90,7 @@
return (RKObjectMapping *) [self mappingForKeyPath:NSStringFromClass(objectClass) context:RKObjectMappingProviderContextSerialization];
}
- (NSDictionary*)objectMappingsByKeyPath
- (NSDictionary *)objectMappingsByKeyPath
{
return [NSDictionary dictionaryWithDictionary:(NSDictionary *) [self valueForContext:RKObjectMappingProviderContextObjectsByKeyPath]];
}
@@ -100,7 +100,7 @@
// TODO: Should generate logs
objectMapping.rootKeyPath = keyPath;
[self setMapping:objectMapping forKeyPath:keyPath];
RKObjectMapping* inverseMapping = [objectMapping inverseMapping];
RKObjectMapping *inverseMapping = [objectMapping inverseMapping];
inverseMapping.rootKeyPath = keyPath;
[self setSerializationMapping:inverseMapping forClass:objectMapping.objectClass];
}
@@ -129,7 +129,7 @@
- (RKObjectMapping *)objectMappingForClass:(Class)theClass
{
NSArray* objectMappings = [self objectMappingsForClass:theClass];
NSArray *objectMappings = [self objectMappingsForClass:theClass];
return ([objectMappings count] > 0) ? [objectMappings objectAtIndex:0] : nil;
}
@@ -375,7 +375,7 @@
}
// Deprecated
+ (id)mappingProviderWithBlock:(void (^)(RKObjectMappingProvider*))block
+ (id)mappingProviderWithBlock:(void (^)(RKObjectMappingProvider *))block
{
return [self mappingProviderUsingBlock:block];
}

View File

@@ -45,7 +45,7 @@
{
int prime = 31;
int result = 1;
result = prime * [self.userData hash] ? [self.mapping hash] : [self.userData hash];
result = prime *[self.userData hash] ? [self.mapping hash] : [self.userData hash];
return result;
}

View File

@@ -26,14 +26,14 @@
}
- (id)initWithDictionary:(id)dictionary;
+ (RKObjectMappingResult*)mappingResultWithDictionary:(NSDictionary*)keyPathToMappedObjects;
+ (RKObjectMappingResult *)mappingResultWithDictionary:(NSDictionary *)keyPathToMappedObjects;
/**
Return the mapping result as a dictionary
*/
- (NSDictionary*)asDictionary;
- (NSDictionary *)asDictionary;
- (id)asObject;
- (NSArray*)asCollection;
- (NSError*)asError;
- (NSArray *)asCollection;
- (NSError *)asError;
@end

View File

@@ -40,20 +40,20 @@
[super dealloc];
}
+ (RKObjectMappingResult*)mappingResultWithDictionary:(NSDictionary*)keyPathToMappedObjects
+ (RKObjectMappingResult *)mappingResultWithDictionary:(NSDictionary *)keyPathToMappedObjects
{
return [[[self alloc] initWithDictionary:keyPathToMappedObjects] autorelease];
}
- (NSDictionary*)asDictionary
- (NSDictionary *)asDictionary
{
return _keyPathToMappedObjects;
}
- (NSArray*)asCollection
- (NSArray *)asCollection
{
// Flatten results down into a single array
NSMutableArray* collection = [NSMutableArray array];
NSMutableArray *collection = [NSMutableArray array];
for (id object in [_keyPathToMappedObjects allValues]) {
// We don't want to strip the keys off of a mapped dictionary result
@@ -69,7 +69,7 @@
- (id)asObject
{
NSArray* collection = [self asCollection];
NSArray *collection = [self asCollection];
NSUInteger count = [collection count];
if (count == 0) {
return nil;
@@ -79,19 +79,19 @@
return [collection objectAtIndex:0];
}
- (NSError*)asError
- (NSError *)asError
{
NSArray* collection = [self asCollection];
NSString* description = nil;
NSArray *collection = [self asCollection];
NSString *description = nil;
if ([collection count] > 0) {
description = [[collection valueForKeyPath:@"description"] componentsJoinedByString:@", "];
} else {
RKLogWarning(@"Expected mapping result to contain at least one object to construct an error");
}
NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:collection, RKObjectMapperErrorObjectsKey,
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:collection, RKObjectMapperErrorObjectsKey,
description, NSLocalizedDescriptionKey, nil];
NSError* error = [NSError errorWithDomain:RKErrorDomain code:RKObjectMapperErrorFromMappingResult userInfo:userInfo];
NSError *error = [NSError errorWithDomain:RKErrorDomain code:RKObjectMapperErrorFromMappingResult userInfo:userInfo];
return error;
}

View File

@@ -23,10 +23,10 @@
@class NSEntityDescription;
@interface RKObjectPropertyInspector : NSObject {
NSMutableDictionary* _cachedPropertyNamesAndTypes;
NSMutableDictionary *_cachedPropertyNamesAndTypes;
}
+ (RKObjectPropertyInspector*)sharedInspector;
+ (RKObjectPropertyInspector *)sharedInspector;
/**
* Returns a dictionary of names and types for the properties of a given class
@@ -36,7 +36,7 @@
/**
Returns the Class type of the specified property on the object class
*/
- (Class)typeForProperty:(NSString*)propertyName ofClass:(Class)objectClass;
- (Class)typeForProperty:(NSString *)propertyName ofClass:(Class)objectClass;
/**
Returns the name of a property when provided the name of a property obtained

View File

@@ -26,11 +26,11 @@
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
static RKObjectPropertyInspector* sharedInspector = nil;
static RKObjectPropertyInspector *sharedInspector = nil;
@implementation RKObjectPropertyInspector
+ (RKObjectPropertyInspector*)sharedInspector
+ (RKObjectPropertyInspector *)sharedInspector
{
if (sharedInspector == nil) {
sharedInspector = [RKObjectPropertyInspector new];
@@ -54,7 +54,7 @@ static RKObjectPropertyInspector* sharedInspector = nil;
[super dealloc];
}
+ (NSString*)propertyTypeFromAttributeString:(NSString*)attributeString
+ (NSString *)propertyTypeFromAttributeString:(NSString *)attributeString
{
NSString *type = [NSString string];
NSScanner *typeScanner = [NSScanner scannerWithString:attributeString];
@@ -72,7 +72,7 @@ static RKObjectPropertyInspector* sharedInspector = nil;
- (NSDictionary *)propertyNamesAndTypesForClass:(Class)theClass
{
NSMutableDictionary* propertyNames = [_cachedPropertyNamesAndTypes objectForKey:theClass];
NSMutableDictionary *propertyNames = [_cachedPropertyNamesAndTypes objectForKey:theClass];
if (propertyNames) {
return propertyNames;
}
@@ -91,12 +91,12 @@ static RKObjectPropertyInspector* sharedInspector = nil;
for (i = 0; i < outCount; i++) {
// property_getAttributes() returns everything we need to implement this...
// See: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html#//apple_ref/doc/uid/TP40008048-CH101-SW5
objc_property_t* prop = propList + i;
NSString* attributeString = [NSString stringWithCString:property_getAttributes(*prop) encoding:NSUTF8StringEncoding];
objc_property_t *prop = propList + i;
NSString *attributeString = [NSString stringWithCString:property_getAttributes(*prop) encoding:NSUTF8StringEncoding];
propName = [NSString stringWithCString:property_getName(*prop) encoding:NSUTF8StringEncoding];
if (![propName isEqualToString:@"_mapkit_hasPanoramaID"]) {
const char* className = [[RKObjectPropertyInspector propertyTypeFromAttributeString:attributeString] cStringUsingEncoding:NSUTF8StringEncoding];
const char *className = [[RKObjectPropertyInspector propertyTypeFromAttributeString:attributeString] cStringUsingEncoding:NSUTF8StringEncoding];
Class aClass = objc_getClass(className);
if (aClass) {
[propertyNames setObject:aClass forKey:propName];
@@ -113,9 +113,9 @@ static RKObjectPropertyInspector* sharedInspector = nil;
return propertyNames;
}
- (Class)typeForProperty:(NSString*)propertyName ofClass:(Class)objectClass
- (Class)typeForProperty:(NSString *)propertyName ofClass:(Class)objectClass
{
NSDictionary* dictionary = [self propertyNamesAndTypesForClass:objectClass];
NSDictionary *dictionary = [self propertyNamesAndTypesForClass:objectClass];
return [dictionary objectForKey:propertyName];
}

View File

@@ -25,15 +25,15 @@
@class RKObjectmapping;
@interface RKObjectRelationshipMapping : RKObjectAttributeMapping {
RKObjectMappingDefinition * _mapping;
RKObjectMappingDefinition *_mapping;
BOOL _reversible;
}
@property (nonatomic, retain) RKObjectMappingDefinition * mapping;
@property (nonatomic, retain) RKObjectMappingDefinition *mapping;
@property (nonatomic, assign) BOOL reversible;
+ (RKObjectRelationshipMapping*)mappingFromKeyPath:(NSString*)sourceKeyPath toKeyPath:(NSString*)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
+ (RKObjectRelationshipMapping *)mappingFromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping;
+ (RKObjectRelationshipMapping*)mappingFromKeyPath:(NSString*)sourceKeyPath toKeyPath:(NSString*)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping reversible:(BOOL)reversible;
+ (RKObjectRelationshipMapping *)mappingFromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping reversible:(BOOL)reversible;
@end

View File

@@ -25,22 +25,22 @@
@synthesize mapping = _mapping;
@synthesize reversible = _reversible;
+ (RKObjectRelationshipMapping*)mappingFromKeyPath:(NSString*)sourceKeyPath toKeyPath:(NSString*)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping reversible:(BOOL)reversible
+ (RKObjectRelationshipMapping *)mappingFromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping reversible:(BOOL)reversible
{
RKObjectRelationshipMapping* relationshipMapping = (RKObjectRelationshipMapping*) [self mappingFromKeyPath:sourceKeyPath toKeyPath:destinationKeyPath];
RKObjectRelationshipMapping *relationshipMapping = (RKObjectRelationshipMapping *) [self mappingFromKeyPath:sourceKeyPath toKeyPath:destinationKeyPath];
relationshipMapping.reversible = reversible;
relationshipMapping.mapping = objectOrDynamicMapping;
return relationshipMapping;
}
+ (RKObjectRelationshipMapping*)mappingFromKeyPath:(NSString*)sourceKeyPath toKeyPath:(NSString*)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
+ (RKObjectRelationshipMapping *)mappingFromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
{
return [self mappingFromKeyPath:sourceKeyPath toKeyPath:destinationKeyPath withMapping:objectOrDynamicMapping reversible:YES];
}
- (id)copyWithZone:(NSZone *)zone
{
RKObjectRelationshipMapping* copy = [super copyWithZone:zone];
RKObjectRelationshipMapping *copy = [super copyWithZone:zone];
copy.mapping = self.mapping;
copy.reversible = self.reversible;
return copy;

View File

@@ -31,14 +31,14 @@
* the resourcePath using a single colon delimiter, such as /users/:userID
*/
@interface RKObjectRouter : NSObject <RKRouter> {
NSMutableDictionary* _routes;
NSMutableDictionary *_routes;
}
/**
* Register a mapping from an object class to a resource path. This resourcePath can be static
* (i.e. /this/is/the/path) or dynamic (i.e. /users/:userID/:username). Dynamic routes are
* evaluated against the object being routed using Key-Value coding and coerced into a string.
* *NOTE* - The pattern matcher fully supports KVM, so /:key1.otherKey normally resolves as it
* *NOTE *- The pattern matcher fully supports KVM, so /:key1.otherKey normally resolves as it
* would in any other KVM situation, ... otherKey is a sub-key on a the object represented by
* key1. This presents a problem in situations where you might want to build a pattern like
* /:filename.json, where the dot isn't intended as a sub-key on the dynamic "filename", but
@@ -46,13 +46,13 @@
* dot with two backslashes, like so: /:filename\\.json
* @see RKPathMatcher
*/
- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString*)resourcePathPattern;
- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString *)resourcePathPattern;
/**
* Register a mapping from an object class to a resource path for a specific HTTP method.
* @see RKPathMatcher
*/
- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString*)resourcePathPattern forMethod:(RKRequestMethod)method;
- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString *)resourcePathPattern forMethod:(RKRequestMethod)method;
/**
* Register a mapping from an object class to a resource path for a specific HTTP method,
@@ -63,13 +63,13 @@
* @"%2Fthis%2Fis%2Fthe%2Fpath".
* @see RKPathMatcher
*/
- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString*)resourcePathPattern forMethod:(RKRequestMethod)method escapeRoutedPath:(BOOL)addEscapes;
- (void)routeClass:(Class)objectClass toResourcePathPattern:(NSString *)resourcePathPattern forMethod:(RKRequestMethod)method escapeRoutedPath:(BOOL)addEscapes;
@end
// Method signatures being phased out
@interface RKObjectRouter (CompatibilityAliases)
- (void)routeClass:(Class)objectClass toResourcePath:(NSString*)resourcePath;
- (void)routeClass:(Class)objectClass toResourcePath:(NSString*)resourcePath forMethod:(RKRequestMethod)method;
- (void)routeClass:(Class)objectClass toResourcePath:(NSString*)resourcePath forMethod:(RKRequestMethod)method escapeRoutedPath:(BOOL)addEscapes;
- (void)routeClass:(Class)objectClass toResourcePath:(NSString *)resourcePath;
- (void)routeClass:(Class)objectClass toResourcePath:(NSString *)resourcePath forMethod:(RKRequestMethod)method;
- (void)routeClass:(Class)objectClass toResourcePath:(NSString *)resourcePath forMethod:(RKRequestMethod)method escapeRoutedPath:(BOOL)addEscapes;
@end

View File

@@ -30,34 +30,34 @@
*/
@interface RKObjectSerializer : NSObject <RKObjectMappingOperationDelegate> {
id _object;
RKObjectMapping* _mapping;
RKObjectMapping *_mapping;
}
@property (nonatomic, readonly) id object;
@property (nonatomic, readonly) RKObjectMapping* mapping;
@property (nonatomic, readonly) RKObjectMapping *mapping;
+ (id)serializerWithObject:(id)object mapping:(RKObjectMapping*)mapping;
- (id)initWithObject:(id)object mapping:(RKObjectMapping*)mapping;
+ (id)serializerWithObject:(id)object mapping:(RKObjectMapping *)mapping;
- (id)initWithObject:(id)object mapping:(RKObjectMapping *)mapping;
/**
Return a serialized representation of the source object by applying an object mapping
with a target object type of NSMutableDictionary. The serialized object will contain attributes
and relationships composed of simple KVC compliant Cocoa types.
*/
- (NSMutableDictionary*)serializedObject:(NSError**)error;
- (NSMutableDictionary *)serializedObject:(NSError **)error;
/**
Return a serialized representation of the source object by mapping it into a NSMutableDictionary and
then encoding it into the destination MIME Type via an instance of RKParser that is registered
for the specified MIME Type
*/
- (NSString*)serializedObjectForMIMEType:(NSString*)MIMEType error:(NSError**)error;
- (NSString *)serializedObjectForMIMEType:(NSString *)MIMEType error:(NSError **)error;
/**
Return a request serialization for the source object by mapping it to an NSMutableDictionary, encoding
the data via a parser into the specified MIME Type, and wrapping it into a serializable format that can
be used as the params of an RKRequest or RKObjectLoader
*/
- (id<RKRequestSerializable>)serializationForMIMEType:(NSString*)mimeType error:(NSError**)error;
- (id<RKRequestSerializable>)serializationForMIMEType:(NSString *)mimeType error:(NSError **)error;
@end

View File

@@ -35,12 +35,12 @@
@synthesize object = _object;
@synthesize mapping = _mapping;
+ (id)serializerWithObject:(id)object mapping:(RKObjectMapping*)mapping
+ (id)serializerWithObject:(id)object mapping:(RKObjectMapping *)mapping
{
return [[[self alloc] initWithObject:object mapping:mapping] autorelease];
}
- (id)initWithObject:(id)object mapping:(RKObjectMapping*)mapping
- (id)initWithObject:(id)object mapping:(RKObjectMapping *)mapping
{
self = [super init];
if (self) {
@@ -59,10 +59,10 @@
}
// Return it serialized into a dictionary
- (id)serializedObject:(NSError**)error
- (id)serializedObject:(NSError **)error
{
NSMutableDictionary* dictionary = [NSMutableDictionary dictionary];
RKObjectMappingOperation* operation = [RKObjectMappingOperation mappingOperationFromObject:_object toObject:dictionary withMapping:_mapping];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
RKObjectMappingOperation *operation = [RKObjectMappingOperation mappingOperationFromObject:_object toObject:dictionary withMapping:_mapping];
operation.delegate = self;
BOOL success = [operation performMapping:error];
if (!success) {
@@ -78,13 +78,13 @@
return dictionary;
}
- (id)serializedObjectForMIMEType:(NSString*)MIMEType error:(NSError**)error
- (id)serializedObjectForMIMEType:(NSString *)MIMEType error:(NSError **)error
{
// TODO: This will fail for form encoded...
id serializedObject = [self serializedObject:error];
if (serializedObject) {
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:MIMEType];
NSString* string = [parser stringFromObject:serializedObject error:error];
NSString *string = [parser stringFromObject:serializedObject error:error];
if (string == nil) {
return nil;
}
@@ -101,9 +101,9 @@
// Dictionaries are natively RKRequestSerializable as Form Encoded
return [self serializedObject:error];
} else {
NSString* string = [self serializedObjectForMIMEType:MIMEType error:error];
NSString *string = [self serializedObjectForMIMEType:MIMEType error:error];
if (string) {
NSData* data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
return [RKRequestSerialization serializationWithData:data MIMEType:MIMEType];
}
}
@@ -125,7 +125,7 @@
}
} else if ([value isKindOfClass:[NSDecimalNumber class]]) {
// Precision numbers are serialized as strings to work around Javascript notation limits
transformedValue = [(NSDecimalNumber*)value stringValue];
transformedValue = [(NSDecimalNumber *)value stringValue];
} else if ([value isKindOfClass:orderedSetClass]) {
// NSOrderedSets are not natively serializable, so let's just turn it into an NSArray
transformedValue = [value array];

View File

@@ -29,6 +29,6 @@
/**
* Returns the resource path to send requests for a given object and HTTP method
*/
- (NSString*)resourcePathForObject:(NSObject*)object method:(RKRequestMethod)method;
- (NSString *)resourcePathForObject:(NSObject *)object method:(RKRequestMethod)method;
@end

View File

@@ -65,14 +65,14 @@
- (NSString *)stringWithContentsOfResource:(NSString *)name withExtension:(NSString *)extension encoding:(NSStringEncoding)encoding
{
NSError* error = nil;
NSError *error = nil;
NSString *resourcePath = [self pathForResource:name ofType:extension];
if (! resourcePath) {
RKLogWarning(@"%@ Failed to locate Resource with name '%@' and extension '%@': File Not Found.", self, resourcePath, extension);
return nil;
}
NSString* fixtureData = [NSString stringWithContentsOfFile:resourcePath encoding:encoding error:&error];
NSString *fixtureData = [NSString stringWithContentsOfFile:resourcePath encoding:encoding error:&error];
if (fixtureData == nil && error) {
RKLogWarning(@"Failed to read ");
}
@@ -95,9 +95,9 @@
- (id)parsedObjectWithContentsOfResource:(NSString *)name withExtension:(NSString *)extension
{
NSError* error = nil;
NSString* resourceContents = [self stringWithContentsOfResource:name withExtension:extension encoding:NSUTF8StringEncoding];
NSString* MIMEType = [self MIMETypeForResource:name withExtension:extension];
NSError *error = nil;
NSString *resourceContents = [self stringWithContentsOfResource:name withExtension:extension encoding:NSUTF8StringEncoding];
NSString *MIMEType = [self MIMETypeForResource:name withExtension:extension];
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:MIMEType];
if (! parser) {
RKLogError(@"%@ Unable to parse Resource with name '%@' and extension '%@': failed to find parser registered to handle MIME Type '%@'", self, name, extension, MIMEType);

View File

@@ -30,8 +30,8 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions)
{
va_list args;
va_start(args, firstKey);
NSMutableArray* keys = [NSMutableArray array];
NSMutableArray* values = [NSMutableArray array];
NSMutableArray *keys = [NSMutableArray array];
NSMutableArray *values = [NSMutableArray array];
for (id key = firstKey; key != nil; key = va_arg(args, id)) {
id value = va_arg(args, id);
[keys addObject:key];
@@ -84,13 +84,13 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions)
return queryComponents;
}
- (void)URLEncodePart:(NSMutableArray*)parts path:(NSString*)path value:(id)value
- (void)URLEncodePart:(NSMutableArray *)parts path:(NSString *)path value:(id)value
{
NSString *encodedPart = [[value description] stringByAddingURLEncoding];
[parts addObject:[NSString stringWithFormat: @"%@=%@", path, encodedPart]];
}
- (void)URLEncodeParts:(NSMutableArray*)parts path:(NSString*)inPath
- (void)URLEncodeParts:(NSMutableArray *)parts path:(NSString *)inPath
{
[self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
NSString *encodedKey = [[key description] stringByAddingURLEncoding];
@@ -116,7 +116,7 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions)
- (NSString *)stringWithURLEncodedEntries
{
NSMutableArray* parts = [NSMutableArray array];
NSMutableArray *parts = [NSMutableArray array];
[self URLEncodeParts:parts path:nil];
return [parts componentsJoinedByString:@"&"];
}

View File

@@ -32,12 +32,12 @@
when given a resourcePath of /contacts and a dictionary of parameters containing foo=bar and color=red,
will return /contacts?foo=bar&amp;color=red
*NOTE* - Assumes that the resource path does not already contain any query parameters.
*NOTE *- Assumes that the resource path does not already contain any query parameters.
@param queryParameters A dictionary of query parameters to be URL encoded and appended to the resource path
@return A new resource path with the query parameters appended
*/
- (NSString *)stringByAppendingQueryParameters:(NSDictionary *)queryParameters;
- (NSString *)appendQueryParams:(NSDictionary*)queryParams DEPRECATED_ATTRIBUTE;
- (NSString *)appendQueryParams:(NSDictionary *)queryParams DEPRECATED_ATTRIBUTE;
/**
Convenience method for generating a path against the properties of an object. Takes

View File

@@ -69,44 +69,44 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions)
return [self queryParametersUsingEncoding:NSUTF8StringEncoding];
}
- (NSDictionary*)queryParametersUsingEncoding:(NSStringEncoding)encoding
- (NSDictionary *)queryParametersUsingEncoding:(NSStringEncoding)encoding
{
return [self queryParametersUsingArrays:NO encoding:encoding];
}
// TODO: Eliminate...
- (NSDictionary*)queryParametersUsingArrays:(BOOL)shouldUseArrays encoding:(NSStringEncoding)encoding
- (NSDictionary *)queryParametersUsingArrays:(BOOL)shouldUseArrays encoding:(NSStringEncoding)encoding
{
NSString *stringToParse = self;
NSRange chopRange = [stringToParse rangeOfString:@"?"];
if (chopRange.length > 0) {
chopRange.location += 1; // we want inclusive chopping up *through* "?"
chopRange.location += 1; // we want inclusive chopping up *through *"?"
if (chopRange.location < [stringToParse length])
stringToParse = [stringToParse substringFromIndex:chopRange.location];
}
NSCharacterSet* delimiterSet = [NSCharacterSet characterSetWithCharactersInString:@"&;"];
NSMutableDictionary* pairs = [NSMutableDictionary dictionary];
NSScanner* scanner = [[[NSScanner alloc] initWithString:stringToParse] autorelease];
NSCharacterSet *delimiterSet = [NSCharacterSet characterSetWithCharactersInString:@"&;"];
NSMutableDictionary *pairs = [NSMutableDictionary dictionary];
NSScanner *scanner = [[[NSScanner alloc] initWithString:stringToParse] autorelease];
while (![scanner isAtEnd]) {
NSString* pairString = nil;
NSString *pairString = nil;
[scanner scanUpToCharactersFromSet:delimiterSet intoString:&pairString];
[scanner scanCharactersFromSet:delimiterSet intoString:NULL];
NSArray* kvPair = [pairString componentsSeparatedByString:@"="];
NSArray *kvPair = [pairString componentsSeparatedByString:@"="];
if (!shouldUseArrays) {
if (kvPair.count == 2) {
NSString* key = [[kvPair objectAtIndex:0]
NSString *key = [[kvPair objectAtIndex:0]
stringByReplacingPercentEscapesUsingEncoding:encoding];
NSString* value = [[kvPair objectAtIndex:1]
NSString *value = [[kvPair objectAtIndex:1]
stringByReplacingPercentEscapesUsingEncoding:encoding];
[pairs setObject:value forKey:key];
}
}
else {
if (kvPair.count == 1 || kvPair.count == 2) {
NSString* key = [[kvPair objectAtIndex:0]
NSString *key = [[kvPair objectAtIndex:0]
stringByReplacingPercentEscapesUsingEncoding:encoding];
NSMutableArray* values = [pairs objectForKey:key];
NSMutableArray *values = [pairs objectForKey:key];
if (nil == values) {
values = [NSMutableArray array];
[pairs setObject:values forKey:key];
@@ -115,7 +115,7 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions)
[values addObject:[NSNull null]];
} else if (kvPair.count == 2) {
NSString* value = [[kvPair objectAtIndex:1]
NSString *value = [[kvPair objectAtIndex:1]
stringByReplacingPercentEscapesUsingEncoding:encoding];
[values addObject:value];
}
@@ -188,7 +188,7 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions)
- (NSString *)MD5
{
// Create pointer to the string as UTF8
const char* ptr = [self UTF8String];
const char *ptr = [self UTF8String];
// Create byte array of unsigned chars
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
@@ -197,7 +197,7 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions)
CC_MD5(ptr, (CC_LONG) strlen(ptr), md5Buffer);
// Convert MD5 value in the buffer to NSString of hex values
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH *2];
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x", md5Buffer[i]];
}

View File

@@ -31,13 +31,13 @@
// the internal caching capabilities from the JSONKit serializer
@implementation RKJSONParserJSONKit
- (NSDictionary*)objectFromString:(NSString*)string error:(NSError**)error
- (NSDictionary *)objectFromString:(NSString *)string error:(NSError **)error
{
RKLogTrace(@"string='%@'", string);
return [string objectFromJSONStringWithParseOptions:JKParseOptionStrict error:error];
}
- (NSString*)stringFromObject:(id)object error:(NSError**)error
- (NSString *)stringFromObject:(id)object error:(NSError **)error
{
return [object JSONStringWithOptions:JKSerializeOptionNone error:error];
}

View File

@@ -10,13 +10,13 @@
@implementation RKXMLParserXMLReader
- (id)objectFromString:(NSString*)string error:(NSError**)error
- (id)objectFromString:(NSString *)string error:(NSError **)error
{
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
return [XMLReader dictionaryForXMLData:data error:error];
}
- (NSString*)stringFromObject:(id)object error:(NSError**)error
- (NSString *)stringFromObject:(id)object error:(NSError **)error
{
return nil;
}

View File

@@ -23,9 +23,9 @@
/**
* Presents an alert dialog with the specified message
*/
void RKAlert(NSString* message);
void RKAlert(NSString *message);
/**
* Presents an alert dialog with the specified message and title
*/
void RKAlertWithTitle(NSString* message, NSString* title);
void RKAlertWithTitle(NSString *message, NSString *title);

View File

@@ -27,13 +27,13 @@
#import "RKAlert.h"
#import "RKLog.h"
void RKAlert(NSString* message) {
void RKAlert(NSString *message) {
RKAlertWithTitle(message, @"Alert");
}
void RKAlertWithTitle(NSString* message, NSString* title) {
void RKAlertWithTitle(NSString *message, NSString *title) {
#if TARGET_OS_IPHONE
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)

View File

@@ -18,7 +18,7 @@
@implementation RKBenchmark
static NSMutableDictionary * __sharedBenchmarks = nil;
static NSMutableDictionary *__sharedBenchmarks = nil;
+ (NSMutableDictionary *)sharedBenchmarks
{

View File

@@ -19,20 +19,20 @@
//
@interface RKCache : NSObject {
NSString* _cachePath;
NSRecursiveLock* _cacheLock;
NSString *_cachePath;
NSRecursiveLock *_cacheLock;
}
@property (nonatomic, readonly) NSString* cachePath;
@property (nonatomic, readonly) NSString *cachePath;
- (id)initWithPath:(NSString*)cachePath subDirectories:(NSArray*)subDirectories;
- (BOOL)hasEntry:(NSString*)cacheKey;
- (void)invalidateEntry:(NSString*)cacheKey;
- (void)invalidateSubDirectory:(NSString*)subDirectory;
- (id)initWithPath:(NSString *)cachePath subDirectories:(NSArray *)subDirectories;
- (BOOL)hasEntry:(NSString *)cacheKey;
- (void)invalidateEntry:(NSString *)cacheKey;
- (void)invalidateSubDirectory:(NSString *)subDirectory;
- (void)invalidateAll;
- (void)writeDictionary:(NSDictionary*)dictionary withCacheKey:(NSString*)cacheKey;
- (void)writeData:(NSData*)data withCacheKey:(NSString*)cacheKey;
- (NSDictionary*)dictionaryForCacheKey:(NSString*)cacheKey ;
- (NSData*)dataForCacheKey:(NSString*)cacheKey;
- (void)writeDictionary:(NSDictionary *)dictionary withCacheKey:(NSString *)cacheKey;
- (void)writeData:(NSData *)data withCacheKey:(NSString *)cacheKey;
- (NSDictionary *)dictionaryForCacheKey:(NSString *)cacheKey ;
- (NSData *)dataForCacheKey:(NSString *)cacheKey;
@end

View File

@@ -27,24 +27,24 @@
@implementation RKCache
- (id)initWithPath:(NSString*)cachePath subDirectories:(NSArray*)subDirectories
- (id)initWithPath:(NSString *)cachePath subDirectories:(NSArray *)subDirectories
{
self = [super init];
if (self) {
_cachePath = [cachePath copy];
_cacheLock = [[NSRecursiveLock alloc] init];
NSFileManager* fileManager = [NSFileManager defaultManager];
NSMutableArray* pathArray = [NSMutableArray arrayWithObject:_cachePath];
for (NSString* subDirectory in subDirectories) {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableArray *pathArray = [NSMutableArray arrayWithObject:_cachePath];
for (NSString *subDirectory in subDirectories) {
[pathArray addObject:[_cachePath stringByAppendingPathComponent:subDirectory]];
}
for (NSString* path in pathArray) {
for (NSString *path in pathArray) {
BOOL isDirectory = NO;
BOOL fileExists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
if (!fileExists) {
NSError* error = nil;
NSError *error = nil;
BOOL created = [fileManager createDirectoryAtPath:path
withIntermediateDirectories:YES
attributes:nil
@@ -73,33 +73,33 @@
[super dealloc];
}
- (NSString*)cachePath
- (NSString *)cachePath
{
return _cachePath;
}
- (NSString*)pathForCacheKey:(NSString*)cacheKey
- (NSString *)pathForCacheKey:(NSString *)cacheKey
{
[_cacheLock lock];
NSString* pathForCacheKey = [_cachePath stringByAppendingPathComponent:cacheKey];
NSString *pathForCacheKey = [_cachePath stringByAppendingPathComponent:cacheKey];
[_cacheLock unlock];
RKLogTrace(@"Found cachePath '%@' for %@", pathForCacheKey, cacheKey);
return pathForCacheKey;
}
- (BOOL)hasEntry:(NSString*)cacheKey
- (BOOL)hasEntry:(NSString *)cacheKey
{
[_cacheLock lock];
BOOL hasEntry = NO;
NSFileManager* fileManager = [NSFileManager defaultManager];
NSString* cachePath = [self pathForCacheKey:cacheKey];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *cachePath = [self pathForCacheKey:cacheKey];
hasEntry = [fileManager fileExistsAtPath:cachePath];
[_cacheLock unlock];
RKLogTrace(@"Determined hasEntry: %@ => %@", cacheKey, hasEntry ? @"YES" : @"NO");
return hasEntry;
}
- (void)writeDictionary:(NSDictionary*)dictionary withCacheKey:(NSString*)cacheKey
- (void)writeDictionary:(NSDictionary *)dictionary withCacheKey:(NSString *)cacheKey
{
if (dictionary) {
[_cacheLock lock];
@@ -114,13 +114,13 @@
}
}
- (void)writeData:(NSData*)data withCacheKey:(NSString*)cacheKey
- (void)writeData:(NSData *)data withCacheKey:(NSString *)cacheKey
{
if (data) {
[_cacheLock lock];
NSString* cachePath = [self pathForCacheKey:cacheKey];
NSString *cachePath = [self pathForCacheKey:cacheKey];
if (cachePath) {
NSError* error = nil;
NSError *error = nil;
BOOL success = [data writeToFile:cachePath options:NSDataWritingAtomic error:&error];
if (success) {
RKLogTrace(@"Wrote cached data to path '%@'", cachePath);
@@ -132,11 +132,11 @@
}
}
- (NSDictionary*)dictionaryForCacheKey:(NSString*)cacheKey
- (NSDictionary *)dictionaryForCacheKey:(NSString *)cacheKey
{
[_cacheLock lock];
NSDictionary* dictionary = nil;
NSString* cachePath = [self pathForCacheKey:cacheKey];
NSDictionary *dictionary = nil;
NSString *cachePath = [self pathForCacheKey:cacheKey];
if (cachePath) {
dictionary = [NSDictionary dictionaryWithContentsOfFile:cachePath];
if (dictionary) {
@@ -151,11 +151,11 @@
return dictionary;
}
- (NSData*)dataForCacheKey:(NSString*)cacheKey
- (NSData *)dataForCacheKey:(NSString *)cacheKey
{
[_cacheLock lock];
NSData* data = nil;
NSString* cachePath = [self pathForCacheKey:cacheKey];
NSData *data = nil;
NSString *cachePath = [self pathForCacheKey:cacheKey];
if (cachePath) {
data = [NSData dataWithContentsOfFile:cachePath];
if (data) {
@@ -168,37 +168,37 @@
return data;
}
- (void)invalidateEntry:(NSString*)cacheKey
- (void)invalidateEntry:(NSString *)cacheKey
{
[_cacheLock lock];
RKLogDebug(@"Invalidating cache entry for '%@'", cacheKey);
NSString* cachePath = [self pathForCacheKey:cacheKey];
NSString *cachePath = [self pathForCacheKey:cacheKey];
if (cachePath) {
NSFileManager* fileManager = [NSFileManager defaultManager];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:cachePath error:NULL];
RKLogTrace(@"Removed cache entry at path '%@' for '%@'", cachePath, cacheKey);
}
[_cacheLock unlock];
}
- (void)invalidateSubDirectory:(NSString*)subDirectory
- (void)invalidateSubDirectory:(NSString *)subDirectory
{
[_cacheLock lock];
if (_cachePath && subDirectory) {
NSString* subDirectoryPath = [_cachePath stringByAppendingPathComponent:subDirectory];
NSString *subDirectoryPath = [_cachePath stringByAppendingPathComponent:subDirectory];
RKLogInfo(@"Invalidating cache at path: %@", subDirectoryPath);
NSFileManager* fileManager = [NSFileManager defaultManager];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDirectory = NO;
BOOL fileExists = [fileManager fileExistsAtPath:subDirectoryPath isDirectory:&isDirectory];
if (fileExists && isDirectory) {
NSError* error = nil;
NSArray* cacheEntries = [fileManager contentsOfDirectoryAtPath:subDirectoryPath error:&error];
NSError *error = nil;
NSArray *cacheEntries = [fileManager contentsOfDirectoryAtPath:subDirectoryPath error:&error];
if (nil == error) {
for (NSString* cacheEntry in cacheEntries) {
NSString* cacheEntryPath = [subDirectoryPath stringByAppendingPathComponent:cacheEntry];
for (NSString *cacheEntry in cacheEntries) {
NSString *cacheEntryPath = [subDirectoryPath stringByAppendingPathComponent:cacheEntry];
[fileManager removeItemAtPath:cacheEntryPath error:&error];
if (nil != error) {
RKLogError(@"Failed to delete cache entry for file: %@", cacheEntryPath);
@@ -217,18 +217,18 @@
[_cacheLock lock];
if (_cachePath) {
RKLogInfo(@"Invalidating cache at path: %@", _cachePath);
NSFileManager* fileManager = [NSFileManager defaultManager];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDirectory = NO;
BOOL fileExists = [fileManager fileExistsAtPath:_cachePath isDirectory:&isDirectory];
if (fileExists && isDirectory) {
NSError* error = nil;
NSArray* cacheEntries = [fileManager contentsOfDirectoryAtPath:_cachePath error:&error];
NSError *error = nil;
NSArray *cacheEntries = [fileManager contentsOfDirectoryAtPath:_cachePath error:&error];
if (nil == error) {
for (NSString* cacheEntry in cacheEntries) {
NSString* cacheEntryPath = [_cachePath stringByAppendingPathComponent:cacheEntry];
for (NSString *cacheEntry in cacheEntries) {
NSString *cacheEntryPath = [_cachePath stringByAppendingPathComponent:cacheEntry];
[fileManager removeItemAtPath:cacheEntryPath error:&error];
if (nil != error) {
RKLogError(@"Failed to delete cache entry for file: %@", cacheEntryPath);

View File

@@ -26,7 +26,7 @@
/**
A subclass of NSDateFormatter that serves as translator between ASP.NET date serializations in JSON
strings and NSDate objects. This is useful for properly mapping these dates from an ASP.NET driven backend.
*NOTE* - DO NOT attempt to use setDateFormat: on this class. It will return invalid results.
*NOTE *- DO NOT attempt to use setDateFormat: on this class. It will return invalid results.
*/
@interface RKDotNetDateFormatter : NSDateFormatter {
NSRegularExpression *dotNetExpression;
@@ -61,7 +61,7 @@
Where 1112715000000 is the number of milliseconds since January 1, 1970 00:00 GMT/UTC, and -0500 represents the
timezone offset from GMT in 24-hour time. Negatives milliseconds are treated as dates before January 1, 1970.
*NOTE* NSDate objects do not have timezones, and you should never change an actual date value based on a
*NOTE *NSDate objects do not have timezones, and you should never change an actual date value based on a
timezone offset. However, timezones are important when presenting dates to the user. Therefore,
If an offset is present in the ASP.NET string (it should be), we actually ignore the offset portion because
we want to store the actual date value in its raw form, without any pollution of timezone information.
@@ -81,7 +81,7 @@
Where 1112715000000 is the number of milliseconds since January 1, 1970 00:00 GMT/UTC, and +0000 is the
timezone offset from GMT in 24-hour time.
*NOTE* GMT (+0000) is assumed otherwise specified via setTimeZone:
*NOTE *GMT (+0000) is assumed otherwise specified via setTimeZone:
@param date An NSDate
@return The ASP.NET style string, /Date(1112715000000-0500)/

View File

@@ -126,7 +126,7 @@ NSTimeInterval secondsFromMilliseconds(NSTimeInterval millisecs) {
NSTimeInterval millisecondsFromSeconds(NSTimeInterval seconds) {
return seconds * 1000.f;
return seconds *1000.f;
}
#endif

View File

@@ -23,7 +23,7 @@
/** @name Error Domain & Codes */
// The error domain for RestKit generated errors
extern NSString* const RKErrorDomain;
extern NSString * const RKErrorDomain;
typedef enum {
RKObjectLoaderRemoteSystemError = 1,
@@ -39,7 +39,7 @@ typedef enum {
The key RestKit generated errors will appear at within an NSNotification
indicating an error
*/
extern NSString* const RKErrorNotificationErrorKey;
extern NSString * const RKErrorNotificationErrorKey;
/**
When RestKit constructs an NSError object from one or more RKErrorMessage
@@ -50,4 +50,4 @@ extern NSString* const RKErrorNotificationErrorKey;
@see RKObjectMappingResult
*/
extern NSString* const RKObjectMapperErrorObjectsKey;
extern NSString * const RKObjectMapperErrorObjectsKey;

View File

@@ -20,7 +20,7 @@
#import "RKErrors.h"
NSString* const RKErrorDomain = @"org.restkit.RestKit.ErrorDomain";
NSString * const RKErrorDomain = @"org.restkit.RestKit.ErrorDomain";
NSString* const RKObjectMapperErrorObjectsKey = @"RKObjectMapperErrorObjectsKey";
NSString* const RKErrorNotificationErrorKey = @"error";
NSString * const RKObjectMapperErrorObjectsKey = @"RKObjectMapperErrorObjectsKey";
NSString * const RKErrorNotificationErrorKey = @"error";

View File

@@ -68,7 +68,7 @@ void RKLogConfigureFromEnvironment(void)
NSString *logComponent = [envVarName stringByReplacingOccurrencesOfString:logComponentPrefix withString:@""];
logComponent = [logComponent stringByReplacingOccurrencesOfString:@"." withString:@"/"];
const char* log_component_c_str = [logComponent cStringUsingEncoding:NSUTF8StringEncoding];
const char *log_component_c_str = [logComponent cStringUsingEncoding:NSUTF8StringEncoding];
int log_level_int = RKLogLevelForString(logLevel, envVarName);
RKLogConfigureByName(log_component_c_str, log_level_int);
}

View File

@@ -23,13 +23,13 @@
*/
/// MIME Type application/json
extern NSString* const RKMIMETypeJSON;
extern NSString * const RKMIMETypeJSON;
/// MIME Type application/x-www-form-urlencoded
extern NSString* const RKMIMETypeFormURLEncoded;
extern NSString * const RKMIMETypeFormURLEncoded;
/// MIME Type application/xml
extern NSString* const RKMIMETypeXML;
extern NSString * const RKMIMETypeXML;
/// MIME Type text/xml
extern NSString* const RKMIMETypeTextXML;
extern NSString * const RKMIMETypeTextXML;

View File

@@ -20,7 +20,7 @@
#import "RKMIMETypes.h"
NSString* const RKMIMETypeJSON = @"application/json";
NSString* const RKMIMETypeFormURLEncoded = @"application/x-www-form-urlencoded";
NSString* const RKMIMETypeXML = @"application/xml";
NSString* const RKMIMETypeTextXML = @"text/xml";
NSString * const RKMIMETypeJSON = @"application/json";
NSString * const RKMIMETypeFormURLEncoded = @"application/x-www-form-urlencoded";
NSString * const RKMIMETypeXML = @"application/xml";
NSString * const RKMIMETypeTextXML = @"text/xml";

View File

@@ -38,7 +38,7 @@ typedef id (^RKMutableBlockDictionaryValueBlock)();
+ (id)valueWithBlock:(RKMutableBlockDictionaryValueBlock)executionBlock
{
RKMutableBlockDictionaryBlockValue* value = [[self new] autorelease];
RKMutableBlockDictionaryBlockValue *value = [[self new] autorelease];
value.executionBlock = executionBlock;
return value;
@@ -119,7 +119,7 @@ typedef id (^RKMutableBlockDictionaryValueBlock)();
- (void)setValueWithBlock:(id (^)())block forKey:(NSString *)key
{
RKMutableBlockDictionaryBlockValue* blockValue = [RKMutableBlockDictionaryBlockValue valueWithBlock:block];
RKMutableBlockDictionaryBlockValue *blockValue = [RKMutableBlockDictionaryBlockValue valueWithBlock:block];
[self setObject:blockValue forKey:key];
}

View File

@@ -57,11 +57,11 @@
Pattern strings should include encoded parameter keys, delimited by a single colon at the
beginning of the key name.
*NOTE 1* - Numerous colon-encoded parameter keys can be joined in a long pattern, but each key must be
*NOTE 1 *- Numerous colon-encoded parameter keys can be joined in a long pattern, but each key must be
separated by at least one unmapped character. For instance, /:key1:key2:key3/ is invalid, whereas
/:key1/:key2/:key3/ is acceptable.
*NOTE 2* - The pattern matcher supports KVM, so :key1.otherKey normally resolves as it would in any other KVM
*NOTE 2 *- The pattern matcher supports KVM, so :key1.otherKey normally resolves as it would in any other KVM
situation, ... otherKey is a sub-key on a the object represented by key1. This presents problems in circumstances where
you might want to build a pattern like /:filename.json, where the dot isn't intended as a sub-key on the filename, but rather
part of the json static string. In these instances, you need to escape the dot with two backslashes, like so:
@@ -79,11 +79,11 @@
matchesPath:tokenizeQueryStrings:parsedArguments: Patterns should include encoded parameter keys,
delimited by a single colon at the beginning of the key name.
*NOTE 1* - Numerous colon-encoded parameter keys can be joined in a long pattern, but each key must be
*NOTE 1 *- Numerous colon-encoded parameter keys can be joined in a long pattern, but each key must be
separated by at least one unmapped character. For instance, /:key1:key2:key3/ is invalid, whereas
/:key1/:key2/:key3/ is acceptable.
*NOTE 2* - The pattern matcher supports KVM, so :key1.otherKey normally resolves as it would in any other KVM
*NOTE 2 *- The pattern matcher supports KVM, so :key1.otherKey normally resolves as it would in any other KVM
situation, ... otherKey is a sub-key on a the object represented by key1. This presents problems in circumstances where
you might want to build a pattern like /:filename.json, where the dot isn't intended as a sub-key on the filename, but rather
part of the json static string. In these instances, you need to escape the dot with two backslashes, like so:

View File

@@ -45,7 +45,7 @@ NSString *RKPathPatternFindAndReplaceParensWithColons(NSString *pattern) {
// NSString's stringByAddingPercentEscapes doesn't do a complete job (it ignores "/?&", among others)
NSString *RKEncodeURLString(NSString *unencodedString) {
NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)unencodedString,
NULL,
@@ -69,7 +69,7 @@ NSString *RKEncodeURLString(NSString *unencodedString) {
- (id)copyWithZone:(NSZone *)zone
{
RKPathMatcher* copy = [[[self class] allocWithZone:zone] init];
RKPathMatcher *copy = [[[self class] allocWithZone:zone] init];
copy.socPattern = self.socPattern;
copy.sourcePath = self.sourcePath;
copy.rootPath = self.rootPath;
@@ -167,9 +167,9 @@ NSString *RKEncodeURLString(NSString *unencodedString) {
{
NSAssert(self.socPattern != NULL, @"Matcher has no established pattern. Instantiate it using matcherWithPattern: before calling pathFromObject:");
NSAssert(object != NULL, @"Object provided is invalid; cannot create a path from a NULL object");
NSString *(^encoderBlock)(NSString* interpolatedString) = nil;
NSString *(^encoderBlock)(NSString *interpolatedString) = nil;
if (addEscapes)
encoderBlock = ^NSString *(NSString* interpolatedString) {
encoderBlock = ^NSString *(NSString *interpolatedString) {
return RKEncodeURLString(interpolatedString);
};
NSString *path = [self.socPattern stringFromObject:object withBlock:encoderBlock];

View File

@@ -66,7 +66,7 @@
return [NSArray arrayWithObject:string];
}
- (NSArray *)searchWithTerms:(NSArray*)searchTerms onProperties:(NSArray *)properties inCollection:(NSArray *)collection compoundSelector:(SEL)selector
- (NSArray *)searchWithTerms:(NSArray *)searchTerms onProperties:(NSArray *)properties inCollection:(NSArray *)collection compoundSelector:(SEL)selector
{
NSPredicate *searchPredicate = nil;

View File

@@ -57,7 +57,7 @@
_awaitingResponse = NO;
}
- (void)tableController:(RKAbstractTableController*)tableController didFailLoadWithError:(NSError *)error
- (void)tableController:(RKAbstractTableController *)tableController didFailLoadWithError:(NSError *)error
{
_awaitingResponse = NO;
}
@@ -88,31 +88,31 @@
- (void)tableController:(RKAbstractTableController *)tableController didLoadTableWithObjectLoader:(RKObjectLoader *)objectLoader
{}
- (void)tableController:(RKAbstractTableController*)tableController willBeginEditing:(id)object atIndexPath:(NSIndexPath*)indexPath
- (void)tableController:(RKAbstractTableController *)tableController willBeginEditing:(id)object atIndexPath:(NSIndexPath *)indexPath
{}
- (void)tableController:(RKAbstractTableController*)tableController didEndEditing:(id)object atIndexPath:(NSIndexPath*)indexPath
- (void)tableController:(RKAbstractTableController *)tableController didEndEditing:(id)object atIndexPath:(NSIndexPath *)indexPath
{}
- (void)tableController:(RKAbstractTableController*)tableController didInsertSection:(RKTableSection*)section atIndex:(NSUInteger)sectionIndex
- (void)tableController:(RKAbstractTableController *)tableController didInsertSection:(RKTableSection *)section atIndex:(NSUInteger)sectionIndex
{}
- (void)tableController:(RKAbstractTableController*)tableController didRemoveSection:(RKTableSection*)section atIndex:(NSUInteger)sectionIndex
- (void)tableController:(RKAbstractTableController *)tableController didRemoveSection:(RKTableSection *)section atIndex:(NSUInteger)sectionIndex
{}
- (void)tableController:(RKAbstractTableController*)tableController didInsertObject:(id)object atIndexPath:(NSIndexPath*)indexPath
- (void)tableController:(RKAbstractTableController *)tableController didInsertObject:(id)object atIndexPath:(NSIndexPath *)indexPath
{}
- (void)tableController:(RKAbstractTableController*)tableController didUpdateObject:(id)object atIndexPath:(NSIndexPath*)indexPath
- (void)tableController:(RKAbstractTableController *)tableController didUpdateObject:(id)object atIndexPath:(NSIndexPath *)indexPath
{}
- (void)tableController:(RKAbstractTableController*)tableController didDeleteObject:(id)object atIndexPath:(NSIndexPath*)indexPath
- (void)tableController:(RKAbstractTableController *)tableController didDeleteObject:(id)object atIndexPath:(NSIndexPath *)indexPath
{}
- (void)tableController:(RKAbstractTableController*)tableController willAddSwipeView:(UIView*)swipeView toCell:(UITableViewCell*)cell forObject:(id)object
- (void)tableController:(RKAbstractTableController *)tableController willAddSwipeView:(UIView *)swipeView toCell:(UITableViewCell *)cell forObject:(id)object
{}
- (void)tableController:(RKAbstractTableController*)tableController willRemoveSwipeView:(UIView*)swipeView fromCell:(UITableViewCell*)cell forObject:(id)object
- (void)tableController:(RKAbstractTableController *)tableController willRemoveSwipeView:(UIView *)swipeView fromCell:(UITableViewCell *)cell forObject:(id)object
{}
- (void)tableController:(RKTableController *)tableController didLoadObjects:(NSArray *)objects inSection:(NSUInteger)sectionIndex

View File

@@ -231,8 +231,8 @@ static RKTestFactory *sharedFactory = nil;
+ (void)clearCacheDirectory
{
NSError* error = nil;
NSString* cachePath = [RKDirectory cachesDirectory];
NSError *error = nil;
NSString *cachePath = [RKDirectory cachesDirectory];
BOOL success = [[NSFileManager defaultManager] removeItemAtPath:cachePath error:&error];
if (success) {
RKLogDebug(@"Cleared cache directory...");

View File

@@ -19,7 +19,7 @@
/**
The name of the notification the receiver is awaiting.
*/
@property (nonatomic, copy) NSString* name;
@property (nonatomic, copy) NSString *name;
/**
The object expected to post the notification the receiver is awaiting.

View File

@@ -86,7 +86,7 @@
}
}
- (void)processNotification:(NSNotification*)notification
- (void)processNotification:(NSNotification *)notification
{
NSAssert([name isEqualToString:notification.name],
@"Received notification (%@) differs from expected notification (%@)",

View File

@@ -46,7 +46,7 @@ NSString * const RKTableControllerDidLoadErrorNotification = @"RKTableController
NSString * const RKTableControllerDidBecomeOnline = @"RKTableControllerDidBecomeOnline";
NSString * const RKTableControllerDidBecomeOffline = @"RKTableControllerDidBecomeOffline";
static NSString * lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey";
static NSString *lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey";
@implementation RKAbstractTableController
@@ -209,7 +209,7 @@ static NSString * lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey"
- (void)setViewController:(UIViewController *)viewController
{
if ([viewController isKindOfClass:[UITableViewController class]]) {
self.tableView = [(UITableViewController*)viewController tableView];
self.tableView = [(UITableViewController *)viewController tableView];
}
}
@@ -1261,7 +1261,7 @@ static NSString * lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey"
}
}
- (void)animationDidStopAddingSwipeView:(NSString *)animationID finished:(NSNumber *)finished context:(void*)context
- (void)animationDidStopAddingSwipeView:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
_animatingCellSwipe = NO;
}

View File

@@ -302,7 +302,7 @@
_sortComparator = Block_copy(sortComparator);
}
- (void)setSectionNameKeyPath:(NSString*)sectionNameKeyPath
- (void)setSectionNameKeyPath:(NSString *)sectionNameKeyPath
{
NSAssert(_sortSelector == nil, @"Attempted to create a sectioned fetchedResultsController when a sortSelector is present");
NSAssert(_sortComparator == nil, @"Attempted to create a sectioned fetchedResultsController when a sortComparator is present");
@@ -311,7 +311,7 @@
_sectionNameKeyPath = sectionNameKeyPath;
}
- (void)setResourcePath:(NSString*)resourcePath
- (void)setResourcePath:(NSString *)resourcePath
{
[_resourcePath release];
_resourcePath = [resourcePath copy];
@@ -354,15 +354,15 @@
id mappableObject = [self objectForRowAtIndexPath:indexPath];
NSAssert(mappableObject, @"Cannot build a tableView cell without an object");
RKTableViewCellMapping* cellMapping = [self.cellMappings cellMappingForObject:mappableObject];
RKTableViewCellMapping *cellMapping = [self.cellMappings cellMappingForObject:mappableObject];
NSAssert(cellMapping, @"Cannot build a tableView cell for object %@: No cell mapping defined for objects of type '%@'", mappableObject, NSStringFromClass([mappableObject class]));
UITableViewCell* cell = [cellMapping mappableObjectForData:self.tableView];
UITableViewCell *cell = [cellMapping mappableObjectForData:self.tableView];
NSAssert(cell, @"Cell mapping failed to dequeue or allocate a tableViewCell for object: %@", mappableObject);
// Map the object state into the cell
RKObjectMappingOperation* mappingOperation = [[RKObjectMappingOperation alloc] initWithSourceObject:mappableObject destinationObject:cell mapping:cellMapping];
NSError* error = nil;
RKObjectMappingOperation *mappingOperation = [[RKObjectMappingOperation alloc] initWithSourceObject:mappableObject destinationObject:cell mapping:cellMapping];
NSError *error = nil;
BOOL success = [mappingOperation performMapping:&error];
[mappingOperation release];
@@ -392,14 +392,14 @@
#pragma mark - UITableViewDataSource methods
- (NSInteger)numberOfSectionsInTableView:(UITableView*)theTableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView
{
NSAssert(theTableView == self.tableView, @"numberOfSectionsInTableView: invoked with inappropriate tableView: %@", theTableView);
RKLogTrace(@"numberOfSectionsInTableView: %d (%@)", [[_fetchedResultsController sections] count], [[_fetchedResultsController sections] valueForKey:@"name"]);
return [[_fetchedResultsController sections] count];
}
- (NSInteger)tableView:(UITableView*)theTableView numberOfRowsInSection:(NSInteger)section
- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"tableView:numberOfRowsInSection: invoked with inappropriate tableView: %@", theTableView);
RKLogTrace(@"%@ numberOfRowsInSection:%d = %d", self, section, self.sectionCount);
@@ -416,19 +416,19 @@
return numberOfRows;
}
- (NSString*)tableView:(UITableView*)theTableView titleForHeaderInSection:(NSInteger)section
- (NSString *)tableView:(UITableView *)theTableView titleForHeaderInSection:(NSInteger)section
{
id <NSFetchedResultsSectionInfo> sectionInfo = [[_fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo name];
}
- (NSString*)tableView:(UITableView*)theTableView titleForFooterInSection:(NSInteger)section
- (NSString *)tableView:(UITableView *)theTableView titleForFooterInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"tableView:titleForFooterInSection: invoked with inappropriate tableView: %@", theTableView);
return nil;
}
- (NSArray*)sectionIndexTitlesForTableView:(UITableView*)theTableView
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)theTableView
{
if (theTableView.style == UITableViewStylePlain && self.showsSectionIndexTitles) {
return [_fetchedResultsController sectionIndexTitles];
@@ -436,7 +436,7 @@
return nil;
}
- (NSInteger)tableView:(UITableView*)theTableView sectionForSectionIndexTitle:(NSString*)title atIndex:(NSInteger)index
- (NSInteger)tableView:(UITableView *)theTableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
if (theTableView.style == UITableViewStylePlain && self.showsSectionIndexTitles) {
return [_fetchedResultsController sectionForSectionIndexTitle:title atIndex:index];
@@ -444,15 +444,15 @@
return 0;
}
- (void)tableView:(UITableView*)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:commitEditingStyle:forRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
if (self.canEditRows && editingStyle == UITableViewCellEditingStyleDelete) {
NSManagedObject* managedObject = [self objectForRowAtIndexPath:indexPath];
RKObjectMapping* mapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[managedObject class]];
NSManagedObject *managedObject = [self objectForRowAtIndexPath:indexPath];
RKObjectMapping *mapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[managedObject class]];
if ([mapping isKindOfClass:[RKManagedObjectMapping class]]) {
RKManagedObjectMapping* managedObjectMapping = (RKManagedObjectMapping*)mapping;
NSString* primaryKeyAttribute = managedObjectMapping.primaryKeyAttribute;
RKManagedObjectMapping *managedObjectMapping = (RKManagedObjectMapping *)mapping;
NSString *primaryKeyAttribute = managedObjectMapping.primaryKeyAttribute;
if ([managedObject valueForKeyPath:primaryKeyAttribute]) {
RKLogTrace(@"About to fire a delete request for managedObject: %@", managedObject);
@@ -461,7 +461,7 @@
RKLogTrace(@"About to locally delete managedObject: %@", managedObject);
[managedObject.managedObjectContext deleteObject:managedObject];
NSError* error = nil;
NSError *error = nil;
[managedObject.managedObjectContext save:&error];
if (error) {
RKLogError(@"Failed to save managedObjectContext after a delete with error: %@", error);
@@ -471,18 +471,18 @@
}
}
- (void)tableView:(UITableView*)theTableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destIndexPath
- (void)tableView:(UITableView *)theTableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destIndexPath
{
NSAssert(theTableView == self.tableView, @"tableView:moveRowAtIndexPath:toIndexPath: invoked with inappropriate tableView: %@", theTableView);
}
- (BOOL)tableView:(UITableView*)theTableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- (BOOL)tableView:(UITableView *)theTableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:canEditRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
return self.canEditRows && [self isOnline] && !([self isHeaderIndexPath:indexPath] || [self isFooterIndexPath:indexPath] || [self isEmptyItemIndexPath:indexPath]);
}
- (BOOL)tableView:(UITableView*)theTableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- (BOOL)tableView:(UITableView *)theTableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:canMoveRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
return self.canMoveRows && !([self isHeaderIndexPath:indexPath] || [self isFooterIndexPath:indexPath] || [self isEmptyItemIndexPath:indexPath]);
@@ -490,23 +490,23 @@
#pragma mark - UITableViewDelegate methods
- (CGFloat)tableView:(UITableView*)theTableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)theTableView heightForHeaderInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"heightForHeaderInSection: invoked with inappropriate tableView: %@", theTableView);
return _heightForHeaderInSection;
}
- (CGFloat)tableView:(UITableView*)theTableView heightForFooterInSection:(NSInteger)sectionIndex
- (CGFloat)tableView:(UITableView *)theTableView heightForFooterInSection:(NSInteger)sectionIndex
{
NSAssert(theTableView == self.tableView, @"heightForFooterInSection: invoked with inappropriate tableView: %@", theTableView);
return 0;
}
- (UIView*)tableView:(UITableView*)theTableView viewForHeaderInSection:(NSInteger)section
- (UIView *)tableView:(UITableView *)theTableView viewForHeaderInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"viewForHeaderInSection: invoked with inappropriate tableView: %@", theTableView);
if (_onViewForHeaderInSection) {
NSString* sectionTitle = [self tableView:self.tableView titleForHeaderInSection:section];
NSString *sectionTitle = [self tableView:self.tableView titleForHeaderInSection:section];
if (sectionTitle) {
return _onViewForHeaderInSection(section, sectionTitle);
}
@@ -514,7 +514,7 @@
return nil;
}
- (UIView*)tableView:(UITableView*)theTableView viewForFooterInSection:(NSInteger)sectionIndex
- (UIView *)tableView:(UITableView *)theTableView viewForFooterInSection:(NSInteger)sectionIndex
{
NSAssert(theTableView == self.tableView, @"viewForFooterInSection: invoked with inappropriate tableView: %@", theTableView);
return nil;
@@ -568,7 +568,7 @@
#pragma mark - NSFetchedResultsControllerDelegate methods
- (void)controllerWillChangeContent:(NSFetchedResultsController*)controller
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
RKLogTrace(@"Beginning updates for fetchedResultsController (%@). Current section count = %d (resource path: %@)", controller, [[controller sections] count], _resourcePath);
@@ -578,7 +578,7 @@
_isEmptyBeforeAnimation = [self isEmpty];
}
- (void)controller:(NSFetchedResultsController*)controller
- (void)controller:(NSFetchedResultsController *)controller
didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex
forChangeType:(NSFetchedResultsChangeType)type
@@ -611,7 +611,7 @@
}
}
- (void)controller:(NSFetchedResultsController*)controller
- (void)controller:(NSFetchedResultsController *)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
@@ -620,8 +620,8 @@
if (_sortSelector) return;
NSIndexPath* adjIndexPath = [self indexPathForFetchedResultsIndexPath:indexPath];
NSIndexPath* adjNewIndexPath = [self indexPathForFetchedResultsIndexPath:newIndexPath];
NSIndexPath *adjIndexPath = [self indexPathForFetchedResultsIndexPath:indexPath];
NSIndexPath *adjNewIndexPath = [self indexPathForFetchedResultsIndexPath:newIndexPath];
switch (type) {
case NSFetchedResultsChangeInsert:
@@ -655,7 +655,7 @@
}
}
- (void)controllerDidChangeContent:(NSFetchedResultsController*)controller
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
RKLogTrace(@"Ending updates for fetchedResultsController (%@). New section count = %d (resource path: %@)",
controller, [[controller sections] count], _resourcePath);
@@ -677,10 +677,10 @@
#pragma mark - UITableViewDataSource methods
- (UITableViewCell *)tableView:(UITableView*)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:cellForRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
UITableViewCell* cell = [self cellForObjectAtIndexPath:indexPath];
UITableViewCell *cell = [self cellForObjectAtIndexPath:indexPath];
RKLogTrace(@"%@ cellForRowAtIndexPath:%@ = %@", self, indexPath, cell);
return cell;

View File

@@ -46,7 +46,7 @@ typedef void(^RKFormBlock)();
*/
@property (nonatomic, readonly) id object;
// The table view we are bound to. not retained.
@property (nonatomic, readonly) RKTableController* tableController;
@property (nonatomic, readonly) RKTableController *tableController;
//@property (nonatomic, assign) id delegate;
@property (nonatomic, copy) RKFormBlock onSubmit;
@@ -82,7 +82,7 @@ typedef void(^RKFormBlock)();
- (void)addRowMappingAttribute:(NSString *)attributeKeyPath toKeyPath:(NSString *)controlKeyPath onControl:(UIControl *)control;
- (void)addRowMappingAttribute:(NSString *)attributeKeyPath toKeyPath:(NSString *)controlKeyPath onControl:(UIControl *)control usingBlock:(void (^)(RKControlTableItem *tableItem))block;
// TODO: Should there be a flavor that accepts UIView* and yields an RKTableItem? This would avoid needing to cast to (UIControl *)
// TODO: Should there be a flavor that accepts UIView *and yields an RKTableItem? This would avoid needing to cast to (UIControl *)
- (void)addRowMappingAttribute:(NSString *)attributeKeyPath toKeyPath:(NSString *)cellKeyPath onCellWithClass:(Class)cellClass;
- (void)addRowMappingAttribute:(NSString *)attributeKeyPath toKeyPath:(NSString *)cellKeyPath onCellWithClass:(Class)cellClass usingBlock:(void (^)(RKTableItem *tableItem))block;

View File

@@ -52,7 +52,7 @@
[tableItem.cellMapping addDefaultMappings];
}
// TODO: WTF? _objects is declared @protected but using _objects here fails to build...
[(NSMutableArray*)self.objects addObject:tableItem];
[(NSMutableArray *)self.objects addObject:tableItem];
}
- (UIControl *)controlWithType:(RKFormControlType)controlType

View File

@@ -30,8 +30,8 @@ typedef enum {
@protocol RKRefreshTriggerProtocol <NSObject>
@optional
- (NSDate*)pullToRefreshDataSourceLastUpdated:(UIGestureRecognizer*)recognizer;
- (BOOL)pullToRefreshDataSourceIsLoading:(UIGestureRecognizer*)recognizer;
- (NSDate *)pullToRefreshDataSourceLastUpdated:(UIGestureRecognizer *)recognizer;
- (BOOL)pullToRefreshDataSourceIsLoading:(UIGestureRecognizer *)recognizer;
@end
@interface RKRefreshGestureRecognizer : UIGestureRecognizer

View File

@@ -159,9 +159,9 @@
#pragma mark - Static Tables
- (NSArray*)objectsWithHeaderAndFooters:(NSArray *)objects forSection:(NSUInteger)sectionIndex
- (NSArray *)objectsWithHeaderAndFooters:(NSArray *)objects forSection:(NSUInteger)sectionIndex
{
NSMutableArray* mutableObjects = [objects mutableCopy];
NSMutableArray *mutableObjects = [objects mutableCopy];
if (sectionIndex == 0) {
if ([self.headerItems count] > 0) {
[mutableObjects insertObjects:self.headerItems atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.headerItems.count)]];
@@ -184,7 +184,7 @@
// Clear any existing error state from the table
self.error = nil;
RKTableSection* section = [self sectionAtIndex:sectionIndex];
RKTableSection *section = [self sectionAtIndex:sectionIndex];
section.objects = [self objectsWithHeaderAndFooters:objects forSection:sectionIndex];
for (NSUInteger index = 0; index < [section.objects count]; index++) {
if ([self.delegate respondsToSelector:@selector(tableController:didInsertObject:atIndexPath:)]) {
@@ -236,7 +236,7 @@
NSAssert(tableItems, @"Cannot load a nil collection of table items");
NSAssert(sectionIndex < self.sectionCount, @"Cannot load table items into a section that does not exist");
NSAssert(cellMapping, @"Cannot load table items without a cell mapping");
for (RKTableItem* tableItem in tableItems) {
for (RKTableItem *tableItem in tableItems) {
tableItem.cellMapping = cellMapping;
}
[self loadTableItems:tableItems inSection:sectionIndex];
@@ -291,12 +291,12 @@
#pragma mark - UITableViewDataSource methods
- (void)tableView:(UITableView*)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:commitEditingStyle:forRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
if (self.canEditRows) {
if (editingStyle == UITableViewCellEditingStyleDelete) {
RKTableSection* section = [self.sections objectAtIndex:indexPath.section];
RKTableSection *section = [self.sections objectAtIndex:indexPath.section];
[section removeObjectAtIndex:indexPath.row];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
@@ -305,21 +305,21 @@
}
}
- (void)tableView:(UITableView*)theTableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destIndexPath
- (void)tableView:(UITableView *)theTableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destIndexPath
{
NSAssert(theTableView == self.tableView, @"tableView:moveRowAtIndexPath:toIndexPath: invoked with inappropriate tableView: %@", theTableView);
if (self.canMoveRows) {
if (sourceIndexPath.section == destIndexPath.section) {
RKTableSection* section = [self.sections objectAtIndex:sourceIndexPath.section];
RKTableSection *section = [self.sections objectAtIndex:sourceIndexPath.section];
[section moveObjectAtIndex:sourceIndexPath.row toIndex:destIndexPath.row];
} else {
[self.tableView beginUpdates];
RKTableSection* sourceSection = [self.sections objectAtIndex:sourceIndexPath.section];
RKTableSection *sourceSection = [self.sections objectAtIndex:sourceIndexPath.section];
id object = [[sourceSection objectAtIndex:sourceIndexPath.row] retain];
[sourceSection removeObjectAtIndex:sourceIndexPath.row];
RKTableSection* destinationSection = nil;
RKTableSection *destinationSection = nil;
if (destIndexPath.section < [self sectionCount]) {
destinationSection = [self.sections objectAtIndex:destIndexPath.section];
} else {
@@ -415,7 +415,7 @@
- (RKTableSection *)sectionWithHeaderTitle:(NSString *)title
{
for (RKTableSection* section in _sections) {
for (RKTableSection *section in _sections) {
if ([section.headerTitle isEqualToString:title]) {
return section;
}
@@ -431,17 +431,17 @@
- (UITableViewCell *)cellForObjectAtIndexPath:(NSIndexPath *)indexPath
{
RKTableSection* section = [self sectionAtIndex:indexPath.section];
RKTableSection *section = [self sectionAtIndex:indexPath.section];
id mappableObject = [section objectAtIndex:indexPath.row];
RKTableViewCellMapping* cellMapping = [self.cellMappings cellMappingForObject:mappableObject];
RKTableViewCellMapping *cellMapping = [self.cellMappings cellMappingForObject:mappableObject];
NSAssert(cellMapping, @"Cannot build a tableView cell for object %@: No cell mapping defined for objects of type '%@'", mappableObject, NSStringFromClass([mappableObject class]));
UITableViewCell* cell = [cellMapping mappableObjectForData:self.tableView];
UITableViewCell *cell = [cellMapping mappableObjectForData:self.tableView];
NSAssert(cell, @"Cell mapping failed to dequeue or allocate a tableViewCell for object: %@", mappableObject);
// Map the object state into the cell
RKObjectMappingOperation* mappingOperation = [[RKObjectMappingOperation alloc] initWithSourceObject:mappableObject destinationObject:cell mapping:cellMapping];
NSError* error = nil;
RKObjectMappingOperation *mappingOperation = [[RKObjectMappingOperation alloc] initWithSourceObject:mappableObject destinationObject:cell mapping:cellMapping];
NSError *error = nil;
BOOL success = [mappingOperation performMapping:&error];
[mappingOperation release];
// NOTE: If there is no mapping work performed, but no error is generated then
@@ -460,44 +460,44 @@
- (id)objectForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(indexPath, @"Cannot lookup object with a nil indexPath");
RKTableSection* section = [self sectionAtIndex:indexPath.section];
RKTableSection *section = [self sectionAtIndex:indexPath.section];
return [section objectAtIndex:indexPath.row];
}
#pragma mark - UITableViewDataSource methods
- (NSString*)tableView:(UITableView*)theTableView titleForHeaderInSection:(NSInteger)section
- (NSString *)tableView:(UITableView *)theTableView titleForHeaderInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"tableView:titleForHeaderInSection: invoked with inappropriate tableView: %@", theTableView);
return [[_sections objectAtIndex:section] headerTitle];
}
- (NSString*)tableView:(UITableView*)theTableView titleForFooterInSection:(NSInteger)section
- (NSString *)tableView:(UITableView *)theTableView titleForFooterInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"tableView:titleForFooterInSection: invoked with inappropriate tableView: %@", theTableView);
return [[_sections objectAtIndex:section] footerTitle];
}
- (BOOL)tableView:(UITableView*)theTableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
- (BOOL)tableView:(UITableView *)theTableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:canEditRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
return self.canEditRows;
}
- (BOOL)tableView:(UITableView*)theTableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
- (BOOL)tableView:(UITableView *)theTableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
NSAssert(theTableView == self.tableView, @"tableView:canMoveRowAtIndexPath: invoked with inappropriate tableView: %@", theTableView);
return self.canMoveRows;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView*)theTableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView
{
NSAssert(theTableView == self.tableView, @"numberOfSectionsInTableView: invoked with inappropriate tableView: %@", theTableView);
RKLogTrace(@"%@ numberOfSectionsInTableView = %d", self, self.sectionCount);
return self.sectionCount;
}
- (NSInteger)tableView:(UITableView*)theTableView numberOfRowsInSection:(NSInteger)section
- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section
{
NSAssert(theTableView == self.tableView, @"tableView:numberOfRowsInSection: invoked with inappropriate tableView: %@", theTableView);
RKLogTrace(@"%@ numberOfRowsInSection:%d = %d", self, section, self.sectionCount);

View File

@@ -88,7 +88,7 @@
Return a new array of RKTableItem instances given a nil terminated list of strings.
Each table item will have the text property set to the string provided.
*/
+ (NSArray*)tableItemsFromStrings:(NSString *)firstString, ... NS_REQUIRES_NIL_TERMINATION;
+ (NSArray *)tableItemsFromStrings:(NSString *)firstString, ... NS_REQUIRES_NIL_TERMINATION;
/**
Returns a new table item
@@ -122,7 +122,7 @@
For example:
NSArray* tableItems = [NSArray arrayWithObjects:[MyTableItem tableItemWithText:@"Foo"
NSArray *tableItems = [NSArray arrayWithObjects:[MyTableItem tableItemWithText:@"Foo"
usingBlock:^(RKTableItem *tableItem) {
[(MyTableItem *)tableItem setURL:@"app://whatever"];
}], ...];

View File

@@ -30,13 +30,13 @@
@synthesize URL = _URL;
@synthesize userData = _userData;
+ (NSArray*)tableItemsFromStrings:(NSString*)firstString, ...
+ (NSArray *)tableItemsFromStrings:(NSString *)firstString, ...
{
va_list args;
va_start(args, firstString);
NSMutableArray* tableItems = [NSMutableArray array];
for (NSString* string = firstString; string != nil; string = va_arg(args, NSString*)) {
RKTableItem* tableItem = [RKTableItem new];
NSMutableArray *tableItems = [NSMutableArray array];
for (NSString *string = firstString; string != nil; string = va_arg(args, NSString *)) {
RKTableItem *tableItem = [RKTableItem new];
tableItem.text = string;
[tableItems addObject:tableItem];
[tableItem release];
@@ -53,7 +53,7 @@
+ (id)tableItemUsingBlock:(void (^)(RKTableItem *))block
{
RKTableItem* tableItem = [self tableItem];
RKTableItem *tableItem = [self tableItem];
block(tableItem);
return tableItem;
}
@@ -73,9 +73,9 @@
}];
}
+ (id)tableItemWithText:(NSString *)text detailText:(NSString *)detailText image:(UIImage*)image
+ (id)tableItemWithText:(NSString *)text detailText:(NSString *)detailText image:(UIImage *)image
{
RKTableItem* tableItem = [self new];
RKTableItem *tableItem = [self new];
tableItem.text = text;
tableItem.detailText = detailText;
tableItem.image = image;
@@ -85,7 +85,7 @@
+ (id)tableItemWithText:(NSString *)text usingBlock:(void (^)(RKTableItem *))block
{
RKTableItem* tableItem = [[self new] autorelease];
RKTableItem *tableItem = [[self new] autorelease];
tableItem.text = text;
block(tableItem);
return tableItem;
@@ -93,7 +93,7 @@
+ (id)tableItemWithText:(NSString *)text URL:(NSString *)URL
{
RKTableItem* tableItem = [self tableItem];
RKTableItem *tableItem = [self tableItem];
tableItem.text = text;
tableItem.URL = URL;
return tableItem;
@@ -138,7 +138,7 @@
[super dealloc];
}
- (NSString*)description
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p text=%@, detailText=%@, image=%p>", NSStringFromClass([self class]), self, self.text, self.detailText, self.image];
}

View File

@@ -30,27 +30,27 @@
}
// Basics
@property (nonatomic, assign) RKTableController* tableController;
@property (nonatomic, readonly) UITableView* tableView;
@property (nonatomic, assign) RKTableController *tableController;
@property (nonatomic, readonly) UITableView *tableView;
// Object Mapping Table Stuff
@property (nonatomic, retain) NSArray* objects;
@property (nonatomic, retain) RKTableViewCellMappings* cellMappings;
@property (nonatomic, retain) NSArray *objects;
@property (nonatomic, retain) RKTableViewCellMappings *cellMappings;
// Header & Footer Views, etc.
@property (nonatomic, retain) NSString* headerTitle;
@property (nonatomic, retain) NSString* footerTitle;
@property (nonatomic, retain) NSString *headerTitle;
@property (nonatomic, retain) NSString *footerTitle;
@property (nonatomic, assign) CGFloat headerHeight;
@property (nonatomic, assign) CGFloat footerHeight;
@property (nonatomic, retain) UIView* headerView;
@property (nonatomic, retain) UIView* footerView;
@property (nonatomic, retain) UIView *headerView;
@property (nonatomic, retain) UIView *footerView;
// number of cells in the section
@property (nonatomic, readonly) NSUInteger rowCount;
+ (id)section;
+ (id)sectionUsingBlock:(void (^)(RKTableSection *))block;
+ (id)sectionForObjects:(NSArray*)objects withMappings:(RKTableViewCellMappings*)cellMappings;
+ (id)sectionForObjects:(NSArray *)objects withMappings:(RKTableViewCellMappings *)cellMappings;
- (id)objectAtIndex:(NSUInteger)rowIndex;
- (void)insertObject:(id)object atIndex:(NSUInteger)index;

View File

@@ -46,7 +46,7 @@
+ (id)sectionUsingBlock:(void (^)(RKTableSection *))block
{
RKTableSection* section = [self section];
RKTableSection *section = [self section];
block(section);
return section;
}
@@ -85,7 +85,7 @@
- (void)setObjects:(NSArray *)objects
{
if (! [objects isMemberOfClass:[NSMutableArray class]]) {
NSMutableArray* mutableObjects = [objects mutableCopy];
NSMutableArray *mutableObjects = [objects mutableCopy];
[_objects release];
_objects = mutableObjects;
} else {
@@ -105,16 +105,16 @@
return [_objects objectAtIndex:rowIndex];
}
- (UITableView*)tableView
- (UITableView *)tableView
{
return _tableController.tableView;
}
- (void)insertObject:(id)object atIndex:(NSUInteger)index
{
[(NSMutableArray*)_objects insertObject:object atIndex:index];
[(NSMutableArray *)_objects insertObject:object atIndex:index];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:index
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index
inSection:[_tableController indexForSection:self]];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:_tableController.defaultRowAnimation];
@@ -127,9 +127,9 @@
- (void)removeObjectAtIndex:(NSUInteger)index
{
id object = [self objectAtIndex:index];
[(NSMutableArray*)_objects removeObjectAtIndex:index];
[(NSMutableArray *)_objects removeObjectAtIndex:index];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:index
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index
inSection:[_tableController indexForSection:self]];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:_tableController.defaultRowAnimation];
@@ -141,9 +141,9 @@
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)object
{
[(NSMutableArray*)_objects replaceObjectAtIndex:index withObject:object];
[(NSMutableArray *)_objects replaceObjectAtIndex:index withObject:object];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:index
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index
inSection:[_tableController indexForSection:self]];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:_tableController.defaultRowAnimation];

View File

@@ -26,9 +26,9 @@
typedef void(^RKTableViewCellForObjectAtIndexPathBlock)(UITableViewCell *cell, id object, NSIndexPath *indexPath);
typedef CGFloat(^RKTableViewHeightOfCellForObjectAtIndexPathBlock)(id object, NSIndexPath *indexPath);
typedef void(^RKTableViewAccessoryButtonTappedForObjectAtIndexPathBlock)(UITableViewCell *cell, id object, NSIndexPath *indexPath);
typedef NSString*(^RKTableViewTitleForDeleteButtonForObjectAtIndexPathBlock)(UITableViewCell *cell, id object, NSIndexPath *indexPath);
typedef NSString *(^RKTableViewTitleForDeleteButtonForObjectAtIndexPathBlock)(UITableViewCell *cell, id object, NSIndexPath *indexPath);
typedef UITableViewCellEditingStyle(^RKTableViewEditingStyleForObjectAtIndexPathBlock)(UITableViewCell *cell, id object, NSIndexPath *indexPath);
typedef NSIndexPath*(^RKTableViewTargetIndexPathForMoveBlock)(UITableViewCell *cell, id object, NSIndexPath *sourceIndexPath, NSIndexPath *destIndexPath);
typedef NSIndexPath *(^RKTableViewTargetIndexPathForMoveBlock)(UITableViewCell *cell, id object, NSIndexPath *sourceIndexPath, NSIndexPath *destIndexPath);
typedef void(^RKTableViewAnonymousBlock)();
typedef void(^RKTableViewCellBlock)(UITableViewCell *cell);
@@ -69,7 +69,7 @@ typedef void(^RKTableViewCellBlock)(UITableViewCell *cell);
@default @"GGImageButtonTableViewCell"
@see cellClass
*/
@property (nonatomic, assign) NSString* cellClassName;
@property (nonatomic, assign) NSString *cellClassName;
/**
A reuse identifier for cells created using this mapping. These cells will be
@@ -80,7 +80,7 @@ typedef void(^RKTableViewCellBlock)(UITableViewCell *cell);
@default NSStringFromClass(self.objectClass)
*/
@property (nonatomic, retain) NSString* reuseIdentifier;
@property (nonatomic, retain) NSString *reuseIdentifier;
/**
A Boolean value that determines whether the cell mapping manages basic cell

Some files were not shown because too many files have changed in this diff Show More