diff --git a/Code/CoreData/CoreData.h b/Code/CoreData/CoreData.h index 9a4fc306..592f8d7b 100644 --- a/Code/CoreData/CoreData.h +++ b/Code/CoreData/CoreData.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/30/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/CoreData/NSEntityDescription+RKAdditions.h b/Code/CoreData/NSEntityDescription+RKAdditions.h index 1f08ae3f..4ad13d84 100644 --- a/Code/CoreData/NSEntityDescription+RKAdditions.h +++ b/Code/CoreData/NSEntityDescription+RKAdditions.h @@ -18,7 +18,7 @@ extern NSString * const RKEntityDescriptionPrimaryKeyAttributeUserInfoKey; /** The substitution variable used in predicateForPrimaryKeyAttribute. - + **Value**: @"PRIMARY_KEY_VALUE" @see predicateForPrimaryKeyAttribute */ @@ -47,21 +47,21 @@ extern NSString * const RKEntityDescriptionPrimaryKeyAttributeValuePredicateSubs /** Returns a cached predicate specifying that the primary key attribute is equal to the $PRIMARY_KEY_VALUE substitution variable. - + This predicate is cached to avoid parsing overhead during object mapping operations and must be evaluated using [NSPredicate predicateWithSubstitutionVariables:] - - @return A cached predicate specifying the value of the primary key attribute is equal to the $PRIMARY_KEY_VALUE + + @return A cached predicate specifying the value of the primary key attribute is equal to the $PRIMARY_KEY_VALUE substitution variable. */ - (NSPredicate *)predicateForPrimaryKeyAttribute; /** Returns a predicate specifying that the value of the primary key attribute is equal to a given - value. This predicate is constructed by evaluating the cached predicate returned by the + value. This predicate is constructed by evaluating the cached predicate returned by the predicateForPrimaryKeyAttribute with a dictionary of substitution variables specifying that $PRIMARY_KEY_VALUE is equal to the given value. - + @return A predicate speciying that the value of the primary key attribute is equal to a given value. */ - (NSPredicate *)predicateForPrimaryKeyAttributeWithValue:(id)value; diff --git a/Code/CoreData/NSEntityDescription+RKAdditions.m b/Code/CoreData/NSEntityDescription+RKAdditions.m index 44184a48..5cc8257b 100644 --- a/Code/CoreData/NSEntityDescription+RKAdditions.m +++ b/Code/CoreData/NSEntityDescription+RKAdditions.m @@ -35,7 +35,7 @@ static char primaryKeyAttributeKey, primaryKeyPredicateKey; // Fall back to the userInfo dictionary if (! primaryKeyAttribute) { primaryKeyAttribute = [self.userInfo valueForKey:RKEntityDescriptionPrimaryKeyAttributeUserInfoKey]; - + // If we have loaded from the user info, ensure we have a predicate if (! [self predicateForPrimaryKeyAttribute]) { [self setPredicateForPrimaryKeyAttribute:primaryKeyAttribute]; @@ -50,7 +50,7 @@ static char primaryKeyAttributeKey, primaryKeyPredicateKey; objc_setAssociatedObject(self, &primaryKeyAttributeKey, primaryKeyAttribute, - OBJC_ASSOCIATION_RETAIN); + OBJC_ASSOCIATION_RETAIN); [self setPredicateForPrimaryKeyAttribute:primaryKeyAttribute]; } diff --git a/Code/CoreData/NSManagedObject+ActiveRecord.m b/Code/CoreData/NSManagedObject+ActiveRecord.m index 172d330a..aea45b82 100644 --- a/Code/CoreData/NSManagedObject+ActiveRecord.m +++ b/Code/CoreData/NSManagedObject+ActiveRecord.m @@ -361,8 +361,8 @@ RK_FIX_CATEGORY_BUG(NSManagedObject_ActiveRecord) NSUInteger count = [context countForFetchRequest:request error:&error]; [self handleErrors:error]; - - return [NSNumber numberWithUnsignedInteger:count]; + + return [NSNumber numberWithUnsignedInteger:count]; } + (NSNumber *)numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm; diff --git a/Code/CoreData/RKEntityByAttributeCache.h b/Code/CoreData/RKEntityByAttributeCache.h index d8bb3060..9abf9361 100644 --- a/Code/CoreData/RKEntityByAttributeCache.h +++ b/Code/CoreData/RKEntityByAttributeCache.h @@ -10,19 +10,19 @@ /** Instances of RKEntityByAttributeCache provide an in-memory caching mechanism - for managed objects instances of an entity in a managed object context with - the value of one of the object's attributes acting as the cache key. When loaded, - the cache will retrieve all instances of an entity from the store and build a + for managed objects instances of an entity in a managed object context with + the value of one of the object's attributes acting as the cache key. When loaded, + the cache will retrieve all instances of an entity from the store and build a dictionary mapping values for the given cache key attribute to the managed object ID for all objects matching the value. The cache can then be used to quickly retrieve objects by attribute value for the cache key without executing another fetch request against the managed object context. This can provide a large performance improvement when a large number of objects are being retrieved using a particular attribute as the key. - + RKEntityByAttributeCache instances are used by the RKEntityCache to provide caching for multiple entities at once. - + @see RKEntityCache */ @interface RKEntityByAttributeCache : NSObject @@ -33,7 +33,7 @@ /** Initializes the receiver with a given entity, attribute, and managed object context. - + @param entity The Core Data entity description for the managed objects being cached. @param attributeName The name of an attribute within the cached entity that acts as the cache key. @param managedObjectContext The managed object context the cache retrieves the cached @@ -74,7 +74,7 @@ /** Loads the cache by finding all instances of the configured entity and building - an association between the value of the cached attribute's value and the + an association between the value of the cached attribute's value and the managed object ID for the object. */ - (void)load; @@ -103,7 +103,7 @@ /** Returns the total number of cached objects with a given value for the attribute acting as the cache key. - + @param attributeValue The value for the cache key attribute to retrieve a count of the objects with a matching value. @return The number of objects in the cache with the given value for the cache @@ -119,9 +119,9 @@ - (NSUInteger)countOfAttributeValues; /** - Returns a Boolean value that indicates whether a given object is present + Returns a Boolean value that indicates whether a given object is present in the cache. - + @param object An object. @return YES if object is present in the cache, otherwise NO. */ @@ -130,17 +130,17 @@ /** Returns a Boolean value that indicates whether one of more objects is present in the cache with a given value of the cache key attribute. - + @param attributeValue The value with which to check the cache for objects with a matching value. - @return YES if one or more objects with the given value for the cache key + @return YES if one or more objects with the given value for the cache key attribute is present in the cache, otherwise NO. */ - (BOOL)containsObjectWithAttributeValue:(id)attributeValue; /** Returns the first object with a matching value for the cache key attribute. - + @param attributeValue A value for the cache key attribute. @return An object with the value of attribute matching attributeValue or nil. */ @@ -148,9 +148,9 @@ /** Returns the collection of objects with a matching value for the cache key attribute. - + @param attributeValue A value for the cache key attribute. - @return An array of objects with the value of attribute matching attributeValue or + @return An array of objects with the value of attribute matching attributeValue or an empty array. */ - (NSArray *)objectsWithAttributeValue:(id)attributeValue; @@ -161,18 +161,18 @@ /** Adds a managed object to the cache. - + The object must be an instance of the cached entity. - + @param object The managed object to add to the cache. */ - (void)addObject:(NSManagedObject *)object; /** Removes a managed object from the cache. - + The object must be an instance of the cached entity. - + @param object The managed object to remove from the cache. */ - (void)removeObject:(NSManagedObject *)object; diff --git a/Code/CoreData/RKEntityByAttributeCache.m b/Code/CoreData/RKEntityByAttributeCache.m index 191efbc9..0cb20307 100644 --- a/Code/CoreData/RKEntityByAttributeCache.m +++ b/Code/CoreData/RKEntityByAttributeCache.m @@ -39,15 +39,15 @@ _attribute = [attributeName retain]; _managedObjectContext = [context retain]; _monitorsContextForChanges = YES; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(managedObjectContextDidChange:) name:NSManagedObjectContextObjectsDidChangeNotification object:context]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(managedObjectContextDidSave:) - name:NSManagedObjectContextDidSaveNotification + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(managedObjectContextDidSave:) + name:NSManagedObjectContextDidSaveNotification object:context]; #if TARGET_OS_IPHONE [[NSNotificationCenter defaultCenter] addObserver:self @@ -56,19 +56,19 @@ object:nil]; #endif } - + return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - + [_entity release]; [_attribute release]; [_managedObjectContext release]; [_attributeValuesToObjectIDs release]; - + [super dealloc]; } @@ -92,18 +92,18 @@ if ([attributeValue isKindOfClass:[NSString class]] || [attributeValue isEqual:[NSNull null]]) { return NO; } - + Class attributeType = [[RKObjectPropertyInspector sharedInspector] typeForProperty:self.attribute ofEntity:self.entity]; return [attributeType instancesRespondToSelector:@selector(stringValue)]; } - (void)load { - RKLogInfo(@"Loading entity cache for Entity '%@' by attribute '%@'", self.entity.name, self.attribute); + RKLogInfo(@"Loading entity cache for Entity '%@' by attribute '%@'", self.entity.name, self.attribute); NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:self.entity]; [fetchRequest setResultType:NSManagedObjectIDResultType]; - + NSError *error = nil; NSArray *objectIDs = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error]; if (error) { @@ -111,7 +111,7 @@ return; } [fetchRequest release]; - + self.attributeValuesToObjectIDs = [NSMutableDictionary dictionaryWithCapacity:[objectIDs count]]; for (NSManagedObjectID *objectID in objectIDs) { NSError *error = nil; @@ -119,7 +119,7 @@ if (! object && error) { RKLogError(@"Failed to retrieve managed object with ID %@: %@", objectID, error); } - + [self addObject:object]; } } @@ -160,7 +160,7 @@ RKLogError(@"Failed to retrieve managed object with ID %@. Error %@\n%@", objectID, [error localizedDescription], [error userInfo]); return nil; } - + return object; } @@ -174,10 +174,10 @@ NSManagedObject *object = [self objectWithID:objectID]; if (object) [objects addObject:object]; } - + return objects; } - + return [NSArray array]; } @@ -197,7 +197,7 @@ } else { objectIDs = [NSMutableArray arrayWithObject:objectID]; } - + if (nil == self.attributeValuesToObjectIDs) self.attributeValuesToObjectIDs = [NSMutableDictionary dictionary]; [self.attributeValuesToObjectIDs setValue:objectIDs forKey:attributeValue]; } else { @@ -241,22 +241,22 @@ - (void)managedObjectContextDidChange:(NSNotification *)notification { if (self.monitorsContextForChanges == NO) return; - + NSDictionary *userInfo = notification.userInfo; NSSet *insertedObjects = [userInfo objectForKey:NSInsertedObjectsKey]; NSSet *updatedObjects = [userInfo objectForKey:NSUpdatedObjectsKey]; NSSet *deletedObjects = [userInfo objectForKey:NSDeletedObjectsKey]; RKLogTrace(@"insertedObjects=%@, updatedObjects=%@, deletedObjects=%@", insertedObjects, updatedObjects, deletedObjects); - + NSMutableSet *objectsToAdd = [NSMutableSet setWithSet:insertedObjects]; [objectsToAdd unionSet:updatedObjects]; - + for (NSManagedObject *object in objectsToAdd) { if ([object.entity isEqual:self.entity]) { [self addObject:object]; } } - + for (NSManagedObject *object in deletedObjects) { if ([object.entity isEqual:self.entity]) { [self removeObject:object]; diff --git a/Code/CoreData/RKEntityCache.h b/Code/CoreData/RKEntityCache.h index a7fe18dc..282dab78 100644 --- a/Code/CoreData/RKEntityCache.h +++ b/Code/CoreData/RKEntityCache.h @@ -9,14 +9,14 @@ #import @class RKEntityByAttributeCache; - + /** - Instances of RKInMemoryEntityCache provide an in-memory caching mechanism for + Instances of RKInMemoryEntityCache provide an in-memory caching mechanism for objects in a Core Data managed object context. Managed objects can be cached by - attribute for fast retrieval without repeatedly hitting the Core Data persistent store. + attribute for fast retrieval without repeatedly hitting the Core Data persistent store. This can provide a substantial speed advantage over issuing fetch requests in cases where repeated look-ups of the same data are performed using a small set - of attributes as the query key. Internally, the cache entries are maintained as + of attributes as the query key. Internally, the cache entries are maintained as references to the NSManagedObjectID of corresponding cached objects. */ @interface RKEntityCache : NSObject @@ -27,7 +27,7 @@ /** Initializes the receiver with a managed object context containing the entity instances to be cached. - + @param context The managed object context containing objects to be cached. @returns self, initialized with context. */ @@ -44,7 +44,7 @@ /** Caches all instances of an entity using the value for an attribute as the cache key. - + @param entity The entity to cache all instances of. @param attributeName The attribute to cache the instances by. */ @@ -52,7 +52,7 @@ /** Returns a Boolean value indicating if all instances of an entity have been cached by a given attribute name. - + @param entity The entity to check the cache status of. @param attributeName The attribute to check the cache status with. @return YES if the cache has been loaded with instances with the given attribute, else NO. @@ -61,7 +61,7 @@ /** Retrieves the first cached instance of a given entity where the specified attribute matches the given value. - + @param entity The entity to search the cache for instances of. @param attributeName The attribute to search the cache for matches with. @param attributeValue The value of the attribute to return a match for. @@ -72,7 +72,7 @@ /** Retrieves all cached instances of a given entity where the specified attribute matches the given value. - + @param entity The entity to search the cache for instances of. @param attributeName The attribute to search the cache for matches with. @param attributeValue The value of the attribute to return a match for. @@ -87,7 +87,7 @@ /** Retrieves the underlying entity attribute cache for a given entity and attribute. - + @param entity The entity to retrieve the entity attribute cache object for. @param attributeName The attribute to retrieve the entity attribute cache object for. @return The entity attribute cache for the given entity and attribute, or nil if none was found. @@ -96,11 +96,11 @@ /** Retrieves all entity attributes caches for a given entity. - + @param entity The entity to retrieve the collection of entity attribute caches for. @return An array of entity attribute cache objects for the given entity or an empty array if none were found. */ -- (NSArray *)attributeCachesForEntity:(NSEntityDescription *)entity; +- (NSArray *)attributeCachesForEntity:(NSEntityDescription *)entity; ///----------------------------------------------------------------------------- // @name Managing the Cache @@ -109,7 +109,7 @@ /** Flushes the entity cache by sending a flush message to each entity attribute cache contained within the receiver. - + @see [RKEntityByAttributeCache flush] */ - (void)flush; @@ -117,7 +117,7 @@ /** Adds a given object to all entity attribute caches for the object's entity contained within the receiver. - + @param object The object to add to the appropriate entity attribute caches. */ - (void)addObject:(NSManagedObject *)object; @@ -125,7 +125,7 @@ /** Removed a given object from all entity attribute caches for the object's entity contained within the receiver. - + @param object The object to remove from the appropriate entity attribute caches. */ - (void)removeObject:(NSManagedObject *)object; diff --git a/Code/CoreData/RKEntityCache.m b/Code/CoreData/RKEntityCache.m index 26845ca6..01d72fe2 100644 --- a/Code/CoreData/RKEntityCache.m +++ b/Code/CoreData/RKEntityCache.m @@ -26,7 +26,7 @@ _managedObjectContext = [context retain]; _attributeCaches = [[NSMutableSet alloc] init]; } - + return self; } @@ -73,7 +73,7 @@ if (attributeCache) { return [attributeCache objectWithAttributeValue:attributeValue]; } - + return nil; } @@ -85,7 +85,7 @@ if (attributeCache) { return [attributeCache objectsWithAttributeValue:attributeValue]; } - + return [NSSet set]; } @@ -98,7 +98,7 @@ return cache; } } - + return nil; } @@ -111,7 +111,7 @@ [set addObject:cache]; } } - + return [NSSet setWithSet:set]; } diff --git a/Code/CoreData/RKFetchRequestManagedObjectCache.m b/Code/CoreData/RKFetchRequestManagedObjectCache.m index 56ba0521..4ef30182 100644 --- a/Code/CoreData/RKFetchRequestManagedObjectCache.m +++ b/Code/CoreData/RKFetchRequestManagedObjectCache.m @@ -28,7 +28,7 @@ NSAssert(primaryKeyAttribute, @"Cannot find existing managed object instance without mapping that defines a primaryKeyAttribute"); NSAssert(primaryKeyValue, @"Cannot find existing managed object by primary key without a value"); NSAssert(managedObjectContext, @"Cannot find existing managed object with a context"); - + id searchValue = primaryKeyValue; Class type = [[RKObjectPropertyInspector sharedInspector] typeForProperty:primaryKeyAttribute ofEntity:entity]; if (type && ([type isSubclassOfClass:[NSString class]] && NO == [primaryKeyValue isKindOfClass:[NSString class]])) { @@ -38,7 +38,7 @@ searchValue = [NSNumber numberWithDouble:[(NSString *)primaryKeyValue doubleValue]]; } } - + // Use cached predicate if primary key matches NSPredicate *predicate = nil; if ([entity.primaryKeyAttribute isEqualToString:primaryKeyAttribute]) { @@ -54,7 +54,7 @@ NSArray *objects = [NSManagedObject executeFetchRequest:fetchRequest inContext:managedObjectContext]; RKLogDebug(@"Found objects '%@' using fetchRequest '%@'", objects, fetchRequest); [fetchRequest release]; - + NSManagedObject *object = nil; if ([objects count] > 0) { object = [objects objectAtIndex:0]; diff --git a/Code/CoreData/RKInMemoryManagedObjectCache.m b/Code/CoreData/RKInMemoryManagedObjectCache.m index 68cc7980..01d59326 100644 --- a/Code/CoreData/RKInMemoryManagedObjectCache.m +++ b/Code/CoreData/RKInMemoryManagedObjectCache.m @@ -28,7 +28,7 @@ static NSString * const RKInMemoryObjectManagedObjectCacheThreadDictionaryKey = contextDictionary = [NSMutableDictionary dictionaryWithCapacity:1]; [[[NSThread currentThread] threadDictionary] setObject:contextDictionary forKey:RKInMemoryObjectManagedObjectCacheThreadDictionaryKey]; } - NSNumber *hashNumber = [NSNumber numberWithUnsignedInteger:[managedObjectContext hash]]; + NSNumber *hashNumber = [NSNumber numberWithUnsignedInteger:[managedObjectContext hash]]; RKEntityCache *entityCache = [contextDictionary objectForKey:hashNumber]; if (! entityCache) { RKLogInfo(@"Creating thread-local entity cache for managed object context: %@", managedObjectContext); @@ -36,7 +36,7 @@ static NSString * const RKInMemoryObjectManagedObjectCacheThreadDictionaryKey = [contextDictionary setObject:entityCache forKey:hashNumber]; [entityCache release]; } - + return entityCache; } @@ -52,7 +52,7 @@ static NSString * const RKInMemoryObjectManagedObjectCacheThreadDictionaryKey = RKEntityByAttributeCache *attributeCache = [entityCache attributeCacheForEntity:entity attribute:primaryKeyAttribute]; RKLogTrace(@"Cached %ld objects", (long) [attributeCache count]); } - + return [entityCache objectForEntity:entity withAttribute:primaryKeyAttribute value:primaryKeyValue]; } diff --git a/Code/CoreData/RKManagedObjectCaching.h b/Code/CoreData/RKManagedObjectCaching.h index 9e6b1a34..64fe4a50 100644 --- a/Code/CoreData/RKManagedObjectCaching.h +++ b/Code/CoreData/RKManagedObjectCaching.h @@ -38,21 +38,21 @@ /** Tells the receiver that an object was fetched and should be added to the cache. - + @param object The object that was fetched from a managed object context. */ - (void)didFetchObject:(NSManagedObject *)object; /** Tells the receiver that an object was created and should be added to the cache. - + @param object The object that was created in a managed object context. */ - (void)didCreateObject:(NSManagedObject *)object; /** Tells the receiver that an object was deleted and should be removed to the cache. - + @param object The object that was deleted from a managed object context. */ - (void)didDeleteObject:(NSManagedObject *)object; diff --git a/Code/CoreData/RKManagedObjectLoader.h b/Code/CoreData/RKManagedObjectLoader.h index 4713a14b..5a8d46e2 100644 --- a/Code/CoreData/RKManagedObjectLoader.h +++ b/Code/CoreData/RKManagedObjectLoader.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 2/13/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,14 +29,14 @@ */ @interface RKManagedObjectLoader : RKObjectLoader { RKManagedObjectStore *_objectStore; - NSManagedObjectID* _targetObjectID; + NSManagedObjectID* _targetObjectID; NSMutableSet* _managedObjectKeyPaths; BOOL _deleteObjectOnFailure; } /** A reference to a RestKit managed object store for interacting with Core Data - + @see RKManagedObjectStore */ @property (nonatomic, retain) RKManagedObjectStore* objectStore; diff --git a/Code/CoreData/RKManagedObjectLoader.m b/Code/CoreData/RKManagedObjectLoader.m index 346c294a..bc65db07 100644 --- a/Code/CoreData/RKManagedObjectLoader.m +++ b/Code/CoreData/RKManagedObjectLoader.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 2/13/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,7 +46,7 @@ if (self) { _objectStore = [objectStore retain]; } - + return self; } @@ -55,22 +55,22 @@ if (self) { _managedObjectKeyPaths = [[NSMutableSet alloc] init]; } - + return self; } - + - (void)dealloc { [_targetObjectID release]; _targetObjectID = nil; _deleteObjectOnFailure = NO; [_managedObjectKeyPaths release]; [_objectStore release]; - + [super dealloc]; } - (void)reset { - [super reset]; + [super reset]; [_targetObjectID release]; _targetObjectID = nil; } @@ -88,16 +88,16 @@ // Overload the target object reader to return a thread-local copy of the target object - (id)targetObject { if ([NSThread isMainThread] == NO && _targetObjectID) { - return [self.objectStore objectWithID:_targetObjectID]; + return [self.objectStore objectWithID:_targetObjectID]; } - + return _targetObject; } - (void)setTargetObject:(NSObject*)targetObject { [_targetObject release]; - _targetObject = nil; - _targetObject = [targetObject retain]; + _targetObject = nil; + _targetObject = [targetObject retain]; [_targetObjectID release]; _targetObjectID = nil; @@ -105,7 +105,7 @@ - (BOOL)prepareURLRequest { // TODO: Can we just do this if the object hasn't been saved already??? - + // NOTE: There is an important sequencing issue here. You MUST save the // managed object context before retaining the objectID or you will run // into an error where the object context cannot be saved. We do this @@ -116,7 +116,7 @@ [self.objectStore save:nil]; _targetObjectID = [[(NSManagedObject*)self.targetObject objectID] retain]; } - + return [super prepareURLRequest]; } @@ -125,7 +125,7 @@ if (fetchRequest) { return [NSManagedObject objectsWithFetchRequest:fetchRequest]; } - + return nil; } @@ -134,7 +134,7 @@ RKLogDebug(@"Skipping cleanup of objects via managed object cache: only used for GET requests."); return; } - + if ([self.URL isKindOfClass:[RKURL class]]) { NSArray *results = [result asCollection]; NSArray *cachedObjects = [self cachedObjects]; @@ -146,7 +146,7 @@ } } else { RKLogWarning(@"Unable to perform cleanup of server-side object deletions: unable to determine resource path."); - } + } } // NOTE: We are on the background thread here, be mindful of Core Data's threading needs @@ -155,9 +155,9 @@ if (_targetObjectID && self.targetObject && self.method == RKRequestMethodDELETE) { NSManagedObject* backgroundThreadObject = [self.objectStore objectWithID:_targetObjectID]; RKLogInfo(@"Deleting local object %@ due to DELETE request", backgroundThreadObject); - [[self.objectStore managedObjectContextForCurrentThread] deleteObject:backgroundThreadObject]; + [[self.objectStore managedObjectContextForCurrentThread] deleteObject:backgroundThreadObject]; } - + // If the response was successful, save the store... if ([self.response isSuccessful]) { [self deleteCachedObjectsMissingFromResult:result]; @@ -171,14 +171,14 @@ [invocation setSelector:@selector(informDelegateOfError:)]; [invocation setArgument:&error atIndex:2]; [invocation invokeOnMainThread]; - + dispatch_async(dispatch_get_main_queue(), ^{ [self finalizeLoad:success]; }); return; } } - + NSDictionary* dictionary = [result asDictionary]; NSMethodSignature* signature = [self methodSignatureForSelector:@selector(informDelegateOfObjectLoadWithResultDictionary:)]; RKManagedObjectThreadSafeInvocation* invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature]; @@ -193,7 +193,7 @@ // Overloaded to handle deleting an object orphaned by a failed postObject: - (void)handleResponseError { [super handleResponseError]; - + if (_targetObjectID) { if (_deleteObjectOnFailure) { RKLogInfo(@"Error response encountered: Deleting existing managed object with ID: %@", _targetObjectID); diff --git a/Code/CoreData/RKManagedObjectMapping.h b/Code/CoreData/RKManagedObjectMapping.h index 8490805b..876ab23c 100644 --- a/Code/CoreData/RKManagedObjectMapping.h +++ b/Code/CoreData/RKManagedObjectMapping.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/31/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,7 +75,7 @@ /** Returns a dictionary containing Core Data relationships and attribute pairs containing - the primary key for + the primary key for */ @property (nonatomic, readonly) NSDictionary *relationshipsAndPrimaryKeyAttributes; @@ -85,18 +85,18 @@ @property (nonatomic, readonly) RKManagedObjectStore *objectStore; /** - Instructs RestKit to automatically connect a relationship of the object being mapped by looking up + Instructs RestKit to automatically connect a relationship of the object being mapped by looking up the related object by primary key. - + For example, given a Project object associated with a User, where the 'user' relationship is specified by a userID property on the managed object: - + [mapping connectRelationship:@"user" withObjectForPrimaryKeyAttribute:@"userID"]; - + Will hydrate the 'user' association on the managed object with the object in the local object graph having the primary key specified in the managed object's userID property. - + In effect, this approach allows foreign key relationships between managed objects to be automatically maintained from the server to the underlying Core Data object graph. */ @@ -105,7 +105,7 @@ /** Connects relationships using the primary key values contained in the specified attribute. This method is a short-cut for repeated invocation of `connectRelationship:withObjectForPrimaryKeyAttribute:`. - + @see connectRelationship:withObjectForPrimaryKeyAttribute: */ - (void)connectRelationshipsWithObjectsForPrimaryKeyAttributes:(NSString *)firstRelationshipName, ... NS_REQUIRES_NIL_TERMINATION; diff --git a/Code/CoreData/RKManagedObjectMapping.m b/Code/CoreData/RKManagedObjectMapping.m index 81f9df07..9ca88cb8 100644 --- a/Code/CoreData/RKManagedObjectMapping.m +++ b/Code/CoreData/RKManagedObjectMapping.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/31/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -69,7 +69,7 @@ [self addObserver:self forKeyPath:@"entity" options:NSKeyValueObservingOptionInitial context:nil]; [self addObserver:self forKeyPath:@"primaryKeyAttribute" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:nil]; } - + return self; } @@ -78,7 +78,7 @@ if (self) { _relationshipToPrimaryKeyMappings = [[NSMutableDictionary alloc] init]; } - + return self; } @@ -131,16 +131,16 @@ return [desc defaultValue]; } -- (id)mappableObjectForData:(id)mappableData { +- (id)mappableObjectForData:(id)mappableData { NSAssert(mappableData, @"Mappable data cannot be nil"); id object = nil; id primaryKeyValue = nil; NSString* primaryKeyAttribute; - + 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 @@ -151,8 +151,8 @@ break; } } - - // Get the primary key value out of the mappable data (if any) + + // Get the primary key value out of the mappable data (if any) if ([primaryKeyAttributeMapping isMappingForKeyOfNestedDictionary]) { RKLogDebug(@"Detected use of nested dictionary key as primaryKey attribute..."); primaryKeyValue = [[mappableData allKeys] lastObject]; @@ -163,16 +163,16 @@ } else { RKLogWarning(@"Unable to find source attribute for primaryKeyAttribute '%@': unable to find existing object instances by primary key.", primaryKeyAttribute); } - } + } } - + // If we have found the primary key attribute & value, try to find an existing instance to update if (primaryKeyAttribute && primaryKeyValue && NO == [primaryKeyValue isEqual:[NSNull null]]) { - object = [self.objectStore.cacheStrategy findInstanceOfEntity:entity - withPrimaryKeyAttribute:primaryKeyAttribute - value:primaryKeyValue + object = [self.objectStore.cacheStrategy findInstanceOfEntity:entity + withPrimaryKeyAttribute:primaryKeyAttribute + value:primaryKeyValue inManagedObjectContext:[self.objectStore managedObjectContextForCurrentThread]]; - + if (object && [self.objectStore.cacheStrategy respondsToSelector:@selector(didFetchObject:)]) { [self.objectStore.cacheStrategy didFetchObject:object]; } @@ -184,7 +184,7 @@ if (primaryKeyAttribute && primaryKeyValue && ![primaryKeyValue isEqual:[NSNull null]]) { [object setValue:primaryKeyValue forKey:primaryKeyAttribute]; } - + if ([self.objectStore.cacheStrategy respondsToSelector:@selector(didCreateObject:)]) { [self.objectStore.cacheStrategy didCreateObject:object]; } @@ -197,7 +197,7 @@ if (! propertyClass) { propertyClass = [[RKObjectPropertyInspector sharedInspector] typeForProperty:propertyName ofEntity:self.entity]; } - + return propertyClass; } diff --git a/Code/CoreData/RKManagedObjectMappingOperation.h b/Code/CoreData/RKManagedObjectMappingOperation.h index c7f68649..14391d58 100644 --- a/Code/CoreData/RKManagedObjectMappingOperation.h +++ b/Code/CoreData/RKManagedObjectMappingOperation.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/31/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ Enhances the object mapping operation process with Core Data specific logic */ @interface RKManagedObjectMappingOperation : RKObjectMappingOperation { - + } @end diff --git a/Code/CoreData/RKManagedObjectMappingOperation.m b/Code/CoreData/RKManagedObjectMappingOperation.m index 6f10b628..8f26f9e9 100644 --- a/Code/CoreData/RKManagedObjectMappingOperation.m +++ b/Code/CoreData/RKManagedObjectMappingOperation.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/31/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,7 @@ primaryKeyAttribute = (NSString*)primaryKeyObject; } NSAssert(primaryKeyAttribute, @"Cannot connect relationship without primaryKeyAttribute"); - + RKObjectRelationshipMapping* relationshipMapping = [self.objectMapping mappingForRelationship:relationshipName]; RKObjectMappingDefinition *mapping = relationshipMapping.mapping; NSAssert(mapping, @"Attempted to connect relationship for keyPath '%@' without a relationship mapping defined."); @@ -69,7 +69,7 @@ id relatedObject = nil; if ([valueOfLocalPrimaryKeyAttribute conformsToProtocol:@protocol(NSFastEnumeration)]) { RKLogTrace(@"Connecting has-many relationship at keyPath '%@' to object with primaryKey attribute '%@'", relationshipName, primaryKeyAttributeOfRelatedObject); - + // Implemented for issue 284 - https://github.com/RestKit/RestKit/issues/284 relatedObject = [NSMutableSet set]; NSObject *cache = [[(RKManagedObjectMapping*)[self objectMapping] objectStore] cacheStrategy]; @@ -81,12 +81,12 @@ } } else { RKLogTrace(@"Connecting has-one relationship at keyPath '%@' to object with primaryKey attribute '%@'", relationshipName, primaryKeyAttributeOfRelatedObject); - + // Normal foreign key NSObject *cache = [[(RKManagedObjectMapping*)[self objectMapping] objectStore] cacheStrategy]; relatedObject = [cache findInstanceOfEntity:objectMapping.entity withPrimaryKeyAttribute:primaryKeyAttributeOfRelatedObject value:valueOfLocalPrimaryKeyAttribute inManagedObjectContext:[[(RKManagedObjectMapping*)[self objectMapping] objectStore] managedObjectContextForCurrentThread]]; } - if (relatedObject) { + if (relatedObject) { RKLogDebug(@"Connected relationship '%@' to object with primary key value '%@': %@", relationshipName, valueOfLocalPrimaryKeyAttribute, relatedObject); } else { RKLogDebug(@"Failed to find instance of '%@' to connect relationship '%@' with primary key value '%@'", [[objectMapping entity] name], relationshipName, valueOfLocalPrimaryKeyAttribute); @@ -115,7 +115,7 @@ } - (BOOL)performMapping:(NSError **)error { - BOOL success = [super performMapping:error]; + BOOL success = [super performMapping:error]; if ([self.objectMapping isKindOfClass:[RKManagedObjectMapping class]]) { /** NOTE: Processing the pending changes here ensures that the managed object context generates observable diff --git a/Code/CoreData/RKManagedObjectSeeder.h b/Code/CoreData/RKManagedObjectSeeder.h index 56a8787e..3c1cf4db 100644 --- a/Code/CoreData/RKManagedObjectSeeder.h +++ b/Code/CoreData/RKManagedObjectSeeder.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 3/4/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/CoreData/RKManagedObjectSeeder.m b/Code/CoreData/RKManagedObjectSeeder.m index 98d9de92..32372403 100644 --- a/Code/CoreData/RKManagedObjectSeeder.m +++ b/Code/CoreData/RKManagedObjectSeeder.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 3/4/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; + (void)generateSeedDatabaseWithObjectManager:(RKObjectManager*)objectManager fromFiles:(NSString*)firstFileName, ... { RKManagedObjectSeeder* seeder = [RKManagedObjectSeeder objectSeederWithObjectManager:objectManager]; - + va_list args; va_start(args, firstFileName); NSMutableArray* fileNames = [NSMutableArray array]; @@ -52,12 +52,12 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; [fileNames addObject:fileName]; } va_end(args); - + // Seed the files for (NSString* fileName in fileNames) { [seeder seedObjectsFromFile:fileName withObjectMapping:nil]; } - + [seeder finalizeSeedingAndExit]; } @@ -69,16 +69,16 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; self = [self init]; if (self) { _manager = [manager retain]; - + // If the user hasn't configured an object store, set one up for them if (nil == _manager.objectStore) { _manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:RKDefaultSeedDatabaseFileName]; } - + // Delete any existing persistent store [_manager.objectStore deletePersistentStore]; } - + return self; } @@ -99,7 +99,7 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; [fileNames addObject:fileName]; } va_end(args); - + for (NSString* fileName in fileNames) { [self seedObjectsFromFile:fileName withObjectMapping:nil]; } @@ -112,14 +112,14 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; - (void)seedObjectsFromFile:(NSString *)fileName withObjectMapping:(RKObjectMapping *)nilOrObjectMapping bundle:(NSBundle *)nilOrBundle { 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]; - + if (payload) { NSString* MIMEType = [fileName MIMETypeForPathExtension]; if (MIMEType == nil) { @@ -128,9 +128,9 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; } id parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:MIMEType]; NSAssert1(parser, @"Could not find a parser for the MIME Type '%@'", MIMEType); - id parsedData = [parser objectFromString:payload error:&error]; + id parsedData = [parser objectFromString:payload error:&error]; NSAssert(parsedData, @"Cannot perform object load without data for mapping"); - + RKObjectMappingProvider* mappingProvider = nil; if (nilOrObjectMapping) { mappingProvider = [[RKObjectMappingProvider new] autorelease]; @@ -138,24 +138,24 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; } else { mappingProvider = _manager.mappingProvider; } - + 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]; NSAssert1([mappedObjects isKindOfClass:[NSArray class]], @"Expected an NSArray of objects, got %@", mappedObjects); - + // Inform the delegate if (self.delegate) { for (NSManagedObject* object in mappedObjects) { [self.delegate didSeedObject:object fromFile:fileName]; } } - + RKLogInfo(@"Seeded %lu objects from %@...", (unsigned long) [mappedObjects count], [NSString stringWithFormat:@"%@", fileName]); } else { RKLogError(@"Unable to read file %@: %@", fileName, [error localizedDescription]); @@ -168,15 +168,15 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; if (! success) { 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]; 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.", + @"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); - + exit(1); } diff --git a/Code/CoreData/RKManagedObjectStore.h b/Code/CoreData/RKManagedObjectStore.h index cb887b6d..5fc35267 100644 --- a/Code/CoreData/RKManagedObjectStore.h +++ b/Code/CoreData/RKManagedObjectStore.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/22/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/CoreData/RKManagedObjectStore.m b/Code/CoreData/RKManagedObjectStore.m index abd23647..02bba589 100644 --- a/Code/CoreData/RKManagedObjectStore.m +++ b/Code/CoreData/RKManagedObjectStore.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/22/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -68,7 +68,7 @@ static RKManagedObjectStore *defaultObjectStore = nil; [objectStore retain]; [defaultObjectStore release]; defaultObjectStore = objectStore; - + [NSManagedObjectContext setDefaultContext:objectStore.primaryManagedObjectContext]; } @@ -134,12 +134,12 @@ static RKManagedObjectStore *defaultObjectStore = nil; [self createPersistentStoreCoordinator]; self.primaryManagedObjectContext = [[self newManagedObjectContext] autorelease]; - + _cacheStrategy = [RKInMemoryManagedObjectCache new]; // Ensure there is a search word observer [RKSearchWordObserver sharedObserver]; - + // Hydrate the defaultObjectStore if (! defaultObjectStore) { [RKManagedObjectStore setDefaultObjectStore:self]; @@ -207,7 +207,7 @@ static RKManagedObjectStore *defaultObjectStore = nil; _cacheStrategy = nil; [primaryManagedObjectContext release]; primaryManagedObjectContext = nil; - + [super dealloc]; } @@ -218,7 +218,7 @@ static RKManagedObjectStore *defaultObjectStore = nil; - (BOOL)save:(NSError **)error { NSManagedObjectContext* moc = [self managedObjectContextForCurrentThread]; NSError *localError = nil; - + @try { if (![moc save:&localError]) { if (self.delegate != nil && [self.delegate respondsToSelector:@selector(managedObjectStore:didFailToSaveContext:error:exception:)]) { @@ -239,9 +239,9 @@ static RKManagedObjectStore *defaultObjectStore = nil; NSValidationErrorKey:\t\t\t%@\n \ NSValidationErrorPredicate:\t%@\n \ NSValidationErrorObject:\n%@\n", - [subUserInfo valueForKey:@"NSLocalizedDescription"], - [subUserInfo valueForKey:@"NSValidationErrorKey"], - [subUserInfo valueForKey:@"NSValidationErrorPredicate"], + [subUserInfo valueForKey:@"NSLocalizedDescription"], + [subUserInfo valueForKey:@"NSValidationErrorKey"], + [subUserInfo valueForKey:@"NSValidationErrorPredicate"], [subUserInfo valueForKey:@"NSValidationErrorObject"]); } } @@ -250,18 +250,18 @@ static RKManagedObjectStore *defaultObjectStore = nil; NSLocalizedDescription:\t\t%@\n \ NSValidationErrorKey:\t\t\t%@\n \ NSValidationErrorPredicate:\t%@\n \ - NSValidationErrorObject:\n%@\n", + NSValidationErrorObject:\n%@\n", [userInfo valueForKey:@"NSLocalizedDescription"], - [userInfo valueForKey:@"NSValidationErrorKey"], - [userInfo valueForKey:@"NSValidationErrorPredicate"], + [userInfo valueForKey:@"NSValidationErrorKey"], + [userInfo valueForKey:@"NSValidationErrorPredicate"], [userInfo valueForKey:@"NSValidationErrorObject"]); } } - + if (error) { *error = localError; } - + return NO; } } @@ -273,7 +273,7 @@ static RKManagedObjectStore *defaultObjectStore = nil; @throw; } } - + return YES; } @@ -283,7 +283,7 @@ static RKManagedObjectStore *defaultObjectStore = nil; [managedObjectContext setUndoManager:nil]; [managedObjectContext setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy]; managedObjectContext.managedObjectStore = self; - + return managedObjectContext; } @@ -351,20 +351,20 @@ static RKManagedObjectStore *defaultObjectStore = nil; } [self createPersistentStoreCoordinator]; - + // Recreate the MOC self.primaryManagedObjectContext = [[self newManagedObjectContext] autorelease]; } - (void)deletePersistentStore { - [self deletePersistentStoreUsingSeedDatabaseName:nil]; + [self deletePersistentStoreUsingSeedDatabaseName:nil]; } - (NSManagedObjectContext *)managedObjectContextForCurrentThread { if ([NSThread isMainThread]) { return self.primaryManagedObjectContext; } - + // Background threads leverage thread-local storage NSManagedObjectContext* managedObjectContext = [self threadLocalObjectForKey:RKManagedObjectStoreThreadDictionaryContextKey]; if (!managedObjectContext) { @@ -380,7 +380,7 @@ static RKManagedObjectStore *defaultObjectStore = nil; name:NSManagedObjectContextDidSaveNotification object:managedObjectContext]; } - + return managedObjectContext; } diff --git a/Code/CoreData/RKManagedObjectThreadSafeInvocation.h b/Code/CoreData/RKManagedObjectThreadSafeInvocation.h index 36660fa2..8d259715 100644 --- a/Code/CoreData/RKManagedObjectThreadSafeInvocation.h +++ b/Code/CoreData/RKManagedObjectThreadSafeInvocation.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/12/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/CoreData/RKManagedObjectThreadSafeInvocation.m b/Code/CoreData/RKManagedObjectThreadSafeInvocation.m index a81c172d..615a0ae4 100644 --- a/Code/CoreData/RKManagedObjectThreadSafeInvocation.m +++ b/Code/CoreData/RKManagedObjectThreadSafeInvocation.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/12/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,10 +29,10 @@ } - (void)setManagedObjectKeyPaths:(NSSet*)keyPaths forArgument:(NSInteger)index { - if (nil == _argumentKeyPaths) { + if (nil == _argumentKeyPaths) { _argumentKeyPaths = [[NSMutableDictionary alloc] init]; } - + NSNumber* argumentIndex = [NSNumber numberWithInteger:index]; [_argumentKeyPaths setObject:keyPaths forKey:argumentIndex]; } @@ -51,14 +51,14 @@ [collection addObject:subObject]; } } - + [argument setValue:collection forKeyPath:keyPath]; [collection release]; } } } -- (void)deserializeManagedObjectIDsForArgument:(id)argument withKeyPaths:(NSSet*)keyPaths { +- (void)deserializeManagedObjectIDsForArgument:(id)argument withKeyPaths:(NSSet*)keyPaths { for (NSString* keyPath in keyPaths) { id value = [argument valueForKeyPath:keyPath]; if ([value isKindOfClass:[NSManagedObjectID class]]) { @@ -77,7 +77,7 @@ [collection addObject:subObject]; } } - + [argument setValue:collection forKeyPath:keyPath]; [collection release]; } @@ -85,7 +85,7 @@ } - (void)serializeManagedObjects { - for (NSNumber* argumentIndex in _argumentKeyPaths) { + for (NSNumber* argumentIndex in _argumentKeyPaths) { NSSet* managedKeyPaths = [_argumentKeyPaths objectForKey:argumentIndex]; id argument = nil; [self getArgument:&argument atIndex:[argumentIndex intValue]]; @@ -96,7 +96,7 @@ } - (void)deserializeManagedObjects { - for (NSNumber* argumentIndex in _argumentKeyPaths) { + for (NSNumber* argumentIndex in _argumentKeyPaths) { NSSet* managedKeyPaths = [_argumentKeyPaths objectForKey:argumentIndex]; id argument = nil; [self getArgument:&argument atIndex:[argumentIndex intValue]]; diff --git a/Code/CoreData/RKObjectMappingProvider+CoreData.h b/Code/CoreData/RKObjectMappingProvider+CoreData.h index 8db36f2d..3cb5e474 100644 --- a/Code/CoreData/RKObjectMappingProvider+CoreData.h +++ b/Code/CoreData/RKObjectMappingProvider+CoreData.h @@ -45,7 +45,7 @@ typedef NSFetchRequest *(^RKObjectMappingProviderFetchRequestBlock)(NSString *re /** Retrieves the NSFetchRequest object that will retrieve cached objects for a given resourcePath. - + @param resourcePath A resourcePath to retrieve the fetch request for. @return An NSFetchRequest object for fetching objects for the given resource path or nil. */ diff --git a/Code/CoreData/RKObjectPropertyInspector+CoreData.h b/Code/CoreData/RKObjectPropertyInspector+CoreData.h index 101d6f03..c04d05dc 100644 --- a/Code/CoreData/RKObjectPropertyInspector+CoreData.h +++ b/Code/CoreData/RKObjectPropertyInspector+CoreData.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/14/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/CoreData/RKObjectPropertyInspector+CoreData.m b/Code/CoreData/RKObjectPropertyInspector+CoreData.m index e57f5083..98425ab0 100644 --- a/Code/CoreData/RKObjectPropertyInspector+CoreData.m +++ b/Code/CoreData/RKObjectPropertyInspector+CoreData.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/14/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,7 +38,7 @@ RK_FIX_CATEGORY_BUG(RKObjectPropertyInspector_CoreData) if (propertyNamesAndTypes) { return propertyNamesAndTypes; } - + propertyNamesAndTypes = [NSMutableDictionary dictionary]; for (NSString* name in [entity attributesByName]) { NSAttributeDescription* attributeDescription = [[entity attributesByName] valueForKey:name]; @@ -63,7 +63,7 @@ RK_FIX_CATEGORY_BUG(RKObjectPropertyInspector_CoreData) } } } - + for (NSString* name in [entity relationshipsByName]) { NSRelationshipDescription* relationshipDescription = [[entity relationshipsByName] valueForKey:name]; if ([relationshipDescription isToMany]) { @@ -74,7 +74,7 @@ RK_FIX_CATEGORY_BUG(RKObjectPropertyInspector_CoreData) [propertyNamesAndTypes setValue:destinationClass forKey:name]; } } - + [_cachedPropertyNamesAndTypes setObject:propertyNamesAndTypes forKey:[entity name]]; RKLogDebug(@"Cached property names and types for Entity '%@': %@", entity, propertyNamesAndTypes); return propertyNamesAndTypes; diff --git a/Code/CoreData/RKSearchableManagedObject.h b/Code/CoreData/RKSearchableManagedObject.h index 31f8197f..1b77767e 100644 --- a/Code/CoreData/RKSearchableManagedObject.h +++ b/Code/CoreData/RKSearchableManagedObject.h @@ -28,7 +28,7 @@ that are searchable using the RKManagedObjectSearchEngine interface. The collection of search words is maintained by the RKSearchWordObserver singleton at managed object context save time. - + @see RKSearchWord @see RKSearchWordObserver @see RKManagedObjectSearchEngine @@ -44,9 +44,9 @@ build the set of search words for entities with the type of the receiver. Subclasses must provide an implementation for indexing to occur as the base implementation returns an empty array. - + @warning *NOTE*: May only include attributes property names, not key paths. - + @return An array of attribute names containing searchable textual content for entities with the type of the receiver. @see RKSearchWordObserver @see searchWords @@ -58,10 +58,10 @@ ///----------------------------------------------------------------------------- /** - A predicate that will search for the specified text with the specified mode. Mode can be + A predicate that will search for the specified text with the specified mode. Mode can be configured to be RKSearchModeAnd or RKSearchModeOr. - - @return A predicate that will search for the specified text with the specified mode. + + @return A predicate that will search for the specified text with the specified mode. @see RKSearchMode */ @@ -79,7 +79,7 @@ /** Rebuilds the set of tokenized search words associated with the receiver by processing the searchable attributes and tokenizing the contents into RKSearchWord instances. - + @see [RKSearchableManagedObject searchableAttributes] */ - (void)refreshSearchWords; @@ -90,28 +90,28 @@ /** Adds a search word object to the receiver's set of search words. - + @param searchWord The search word to be added to the set of search words. */ - (void)addSearchWordsObject:(RKSearchWord *)searchWord; /** Removes a search word object from the receiver's set of search words. - + @param searchWord The search word to be removed from the receiver's set of search words. */ - (void)removeSearchWordsObject:(RKSearchWord *)searchWord; /** Adds a set of search word objects to the receiver's set of search words. - + @param searchWords The set of search words to be added to receiver's the set of search words. */ - (void)addSearchWords:(NSSet *)searchWords; /** Removes a set of search word objects from the receiver's set of search words. - + @param searchWords The set of search words to be removed from receiver's the set of search words. */ - (void)removeSearchWords:(NSSet *)searchWords; diff --git a/Code/CoreData/RKSearchableManagedObject.m b/Code/CoreData/RKSearchableManagedObject.m index 97822e00..9e6a56a4 100644 --- a/Code/CoreData/RKSearchableManagedObject.m +++ b/Code/CoreData/RKSearchableManagedObject.m @@ -35,7 +35,7 @@ return [NSArray array]; } -+ (NSPredicate *)predicateForSearchWithText:(NSString *)searchText searchMode:(RKSearchMode)mode ++ (NSPredicate *)predicateForSearchWithText:(NSString *)searchText searchMode:(RKSearchMode)mode { if (searchText == nil) { return nil; @@ -58,9 +58,9 @@ RKLogTrace(@"Generating search words for searchable attribute: %@", searchableAttribute); NSArray *attributeValueWords = [RKManagedObjectSearchEngine tokenizedNormalizedString:attributeValue]; for (NSString *word in attributeValueWords) { - if (word && [word length] > 0) { - RKSearchWord *searchWord = [RKSearchWord findFirstByAttribute:RKSearchWordPrimaryKeyAttribute - withValue:word + if (word && [word length] > 0) { + RKSearchWord *searchWord = [RKSearchWord findFirstByAttribute:RKSearchWordPrimaryKeyAttribute + withValue:word inContext:self.managedObjectContext]; if (! searchWord) { searchWord = [RKSearchWord createInContext:self.managedObjectContext]; diff --git a/Code/Network/NSData+RKAdditions.h b/Code/Network/NSData+RKAdditions.h index 825cdcd9..b33524a5 100644 --- a/Code/Network/NSData+RKAdditions.h +++ b/Code/Network/NSData+RKAdditions.h @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 4/4/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ /** Returns a string of the MD5 sum of the receiver. - + @return A new string containing the MD5 sum of the receiver. */ - (NSString *)MD5; diff --git a/Code/Network/NSData+RKAdditions.m b/Code/Network/NSData+RKAdditions.m index de64b2e9..567b332d 100644 --- a/Code/Network/NSData+RKAdditions.m +++ b/Code/Network/NSData+RKAdditions.m @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 4/4/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Network/NSDictionary+RKRequestSerialization.h b/Code/Network/NSDictionary+RKRequestSerialization.h index 4612bc1e..a2b55051 100644 --- a/Code/Network/NSDictionary+RKRequestSerialization.h +++ b/Code/Network/NSDictionary+RKRequestSerialization.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/28/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,11 +23,11 @@ /* Extends NSDictionary to enable usage as the params of an RKRequest. - + This category provides for the serialization of the receiving NSDictionary into a URL - encoded string representation (MIME Type application/x-www-form-urlencoded). This + encoded string representation (MIME Type application/x-www-form-urlencoded). This enables NSDictionary objects to act as the params for an RKRequest. - + @see RKRequestSerializable @see [RKRequest params] @class NSDictionary (RKRequestSerialization) diff --git a/Code/Network/NSDictionary+RKRequestSerialization.m b/Code/Network/NSDictionary+RKRequestSerialization.m index a4139dfd..991da1b6 100644 --- a/Code/Network/NSDictionary+RKRequestSerialization.m +++ b/Code/Network/NSDictionary+RKRequestSerialization.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/28/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Network/Network.h b/Code/Network/Network.h index 7591b471..46162f2e 100644 --- a/Code/Network/Network.h +++ b/Code/Network/Network.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/30/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Network/RKClient.h b/Code/Network/RKClient.h index c0bab362..92b3f195 100644 --- a/Code/Network/RKClient.h +++ b/Code/Network/RKClient.h @@ -230,7 +230,7 @@ /** The run loop mode under which the underlying NSURLConnection is performed - + *Default*: NSRunLoopCommonModes */ @property (nonatomic, copy) NSString *runLoopMode; diff --git a/Code/Network/RKClient.m b/Code/Network/RKClient.m index f34882d1..9a04860a 100644 --- a/Code/Network/RKClient.m +++ b/Code/Network/RKClient.m @@ -141,7 +141,7 @@ NSString *RKPathAppendQueryParams(NSString *resourcePath, NSDictionary *queryPar object:nil]; // Configure observers - [self addObserver:self forKeyPath:@"reachabilityObserver" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; + [self addObserver:self forKeyPath:@"reachabilityObserver" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; [self addObserver:self forKeyPath:@"baseURL" options:NSKeyValueObservingOptionNew context:nil]; [self addObserver:self forKeyPath:@"requestQueue" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld | NSKeyValueObservingOptionInitial context:nil]; } diff --git a/Code/Network/RKNotifications.h b/Code/Network/RKNotifications.h index 74fb98ef..a96c480b 100644 --- a/Code/Network/RKNotifications.h +++ b/Code/Network/RKNotifications.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/24/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ /** Request Auditing - + RKClient exposes a set of NSNotifications that can be used to audit the request/response cycle of your application. This is useful for doing things like generating automatic logging for all your requests or sending the response diff --git a/Code/Network/RKNotifications.m b/Code/Network/RKNotifications.m index fc1ae7c5..75e9b4ee 100644 --- a/Code/Network/RKNotifications.m +++ b/Code/Network/RKNotifications.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/24/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Network/RKOAuthClient.h b/Code/Network/RKOAuthClient.h index a43e14af..4d026c9c 100644 --- a/Code/Network/RKOAuthClient.h +++ b/Code/Network/RKOAuthClient.h @@ -4,13 +4,13 @@ // // Created by Rodrigo Garcia on 7/20/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,7 +52,7 @@ typedef enum RKOAuthClientErrors { */ RKOAuthClientErrorUnsupportedGrantType = 3005, /** - The requested scope is invalid, unknown, malformed, or exceeds the scope + The requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner. */ RKOAuthClientErrorInvalidScope = 3006, @@ -73,13 +73,13 @@ typedef enum RKOAuthClientErrors { /** An OAuth client implementation that conforms to RKRequestDelegate to handle the authentication involved with the OAuth 2 authorization code flow. - + RKOAuthClient sets up a pre-configured RKRequest and RKResponse handler to give easy access to retrieving an access token and handling errors through RKOAuthClientDelegate. - + **Example**: - + RKOAuthClient *oauthClient; oauthClient = [RKClientOAuth clientWithClientID:@"YOUR_CLIENT_ID" secret:@"YOUR_CLIENT_SECRET" @@ -88,13 +88,13 @@ typedef enum RKOAuthClientErrors { oauthClient.authorizationURL = @"https://foursquare.com/oauth2/authenticate"; oauthClient.callbackURL = @"https://example.com/callback"; [oauthClient validateAuthorizationCode]; - + From here, errors and the access token are returned through the implementation of RKOAuthClientDelegate specified. - + For more information on the OAuth 2 implementation, see http://tools.ietf.org/html/draft-ietf-oauth-v2-22 - + @see RKOAuthClientDelegate */ @interface RKOAuthClient : NSObject { @@ -114,7 +114,7 @@ typedef enum RKOAuthClientErrors { /** Initialize a new RKOAuthClient with OAuth client credentials. - + @param clientID The ID of your application obtained from the OAuth provider. @param secret Confidential key obtained from the OAuth provider that is used to sign requests sent to the authentication server. @@ -139,11 +139,11 @@ typedef enum RKOAuthClientErrors { /** A delegate that must conform to the RKOAuthClientDelegate protocol. - + The delegate will get callbacks such as successful access token acquisitions as well as any errors that are encountered. Reference the RKOAuthClientDelegate for more information. - + @see RKOAuthClientDelegate. */ @property (nonatomic, assign) id delegate; @@ -199,7 +199,7 @@ typedef enum RKOAuthClientErrors { Fire a request to the authentication server to validate the authorization code that has been set on the authorizationCode property. All responses are handled by the delegate. - + @see RKOAuthClientDelegate */ - (void)validateAuthorizationCode; @@ -211,7 +211,7 @@ typedef enum RKOAuthClientErrors { The delegate of an RKOAuthClient object must adopt the RKOAuthClientDelegate protocol. The protocol defines all methods relating to obtaining an accessToken and handling any errors along the way. It optionally provides - callbacks for many different OAuth2 exceptions that may occur during the + callbacks for many different OAuth2 exceptions that may occur during the authorization code flow. */ @protocol RKOAuthClientDelegate @@ -223,7 +223,7 @@ typedef enum RKOAuthClientErrors { /** Sent when a new access token has been acquired - + @param client A reference to the RKOAuthClient that triggered the callback @param token A string of the access token acquired from the authentication server. @@ -237,7 +237,7 @@ typedef enum RKOAuthClientErrors { /** Sent when an access token request has failed due an invalid authorization code - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback @@ -248,7 +248,7 @@ typedef enum RKOAuthClientErrors { /** Sent to the delegate when the OAuth client encounters any error. - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback @@ -257,7 +257,7 @@ typedef enum RKOAuthClientErrors { /** Sent when the client isn't authorized to perform the requested action - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback @@ -268,7 +268,7 @@ typedef enum RKOAuthClientErrors { Sent when an error is encountered with the OAuth client such as an unknown client, there is no client authentication included, or an unsupported authentication method was used. - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback @@ -277,7 +277,7 @@ typedef enum RKOAuthClientErrors { /** Sent when the request sent to the authentication server is invalid - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback @@ -286,7 +286,7 @@ typedef enum RKOAuthClientErrors { /** Sent when the grant type specified isn't supported by the authentication server - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback @@ -296,17 +296,17 @@ typedef enum RKOAuthClientErrors { /** Sent when the requested scope is invalid, unknown, malformed, or exceeds the scope granted by the resource owner. - + @param client A reference to the RKOAuthClient that triggered the callback @param error An NSError object containing the RKOAuthClientError that triggered the callback */ - (void)OAuthClient:(RKOAuthClient *)client didFailWithInvalidScopeError:(NSError *)error; -/** +/** Sent to the delegate when an authorization code flow request failed due to a loading error somewhere within the RKRequest call - + @param client A reference to the RKOAuthClient that triggered the callback @param request A reference to the RKRequest that failed @param error An NSError object containing the RKOAuthClientError that triggered diff --git a/Code/Network/RKOAuthClient.m b/Code/Network/RKOAuthClient.m index 36c306ca..7642f4d9 100644 --- a/Code/Network/RKOAuthClient.m +++ b/Code/Network/RKOAuthClient.m @@ -4,13 +4,13 @@ // // Created by Rodrigo Garcia on 7/20/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,7 +45,7 @@ _clientID = [clientID copy]; _clientSecret = [secret copy]; } - + return self; } @@ -53,7 +53,7 @@ [_clientID release]; [_clientSecret release]; [_accessToken release]; - + [super dealloc]; } @@ -71,28 +71,28 @@ - (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response { NSError *error = nil; NSString *errorResponse = nil; - + //Use the parsedBody answer in NSDictionary - + NSDictionary* oauthResponse = (NSDictionary *) [response parsedBody:&error]; if ([oauthResponse isKindOfClass:[NSDictionary class]]) { - + //Check the if an access token comes in the response _accessToken = [[oauthResponse objectForKey:@"access_token"] copy]; errorResponse = [oauthResponse objectForKey:@"error"]; - - if (_accessToken) { - // W00T We got an accessToken + + if (_accessToken) { + // W00T We got an accessToken [self.delegate OAuthClient:self didAcquireAccessToken:_accessToken]; - + return; } else if (errorResponse) { // Heads-up! There is an error in the response // The possible errors are defined in the OAuth2 Protocol - + RKOAuthClientErrorCode errorCode = RKOAuthClientErrorUnknown; NSString *errorDescription = [oauthResponse objectForKey:@"error_description"]; - + if ([errorResponse isEqualToString:@"invalid_grant"]) { errorCode = RKOAuthClientErrorInvalidGrant; } @@ -111,42 +111,42 @@ else if([errorResponse isEqualToString:@"invalid_scope"]){ errorCode = RKOAuthClientErrorInvalidScope; } - + NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys: errorDescription, NSLocalizedDescriptionKey, nil]; NSError *error = [NSError errorWithDomain:RKErrorDomain code:errorCode userInfo:userInfo]; - - + + // Inform the delegate of what happened if ([self.delegate respondsToSelector:@selector(OAuthClient:didFailWithError:)]) { [self.delegate OAuthClient:self didFailWithError:error]; } - + // Invalid grant if (errorCode == RKOAuthClientErrorInvalidGrant && [self.delegate respondsToSelector:@selector(OAuthClient:didFailWithInvalidGrantError:)]) { [self.delegate OAuthClient:self didFailWithInvalidGrantError:error]; } - + // Unauthorized client if (errorCode == RKOAuthClientErrorUnauthorizedClient && [self.delegate respondsToSelector:@selector(OAuthClient:didFailWithUnauthorizedClientError:)]) { [self.delegate OAuthClient:self didFailWithUnauthorizedClientError:error]; } - + // Invalid client if (errorCode == RKOAuthClientErrorInvalidClient && [self.delegate respondsToSelector:@selector(OAuthClient:didFailWithInvalidClientError:)]) { [self.delegate OAuthClient:self didFailWithInvalidClientError:error]; } - + // Invalid request if (errorCode == RKOAuthClientErrorInvalidRequest && [self.delegate respondsToSelector:@selector(OAuthClient:didFailWithInvalidRequestError:)]) { [self.delegate OAuthClient:self didFailWithInvalidRequestError:error]; } - + // Unsupported grant type if (errorCode == RKOAuthClientErrorUnsupportedGrantType && [self.delegate respondsToSelector:@selector(OAuthClient:didFailWithUnsupportedGrantTypeError:)]) { [self.delegate OAuthClient:self didFailWithUnsupportedGrantTypeError:error]; } - + // Invalid scope if (errorCode == RKOAuthClientErrorInvalidScope && [self.delegate respondsToSelector:@selector(OAuthClient:didFailWithInvalidScopeError:)]) { [self.delegate OAuthClient:self didFailWithInvalidScopeError:error]; @@ -169,7 +169,7 @@ if ([self.delegate respondsToSelector:@selector(OAuthClient:didFailLoadingRequest:withError:)]) { [self.delegate OAuthClient:self didFailLoadingRequest:request withError:clientError]; } - + if ([self.delegate respondsToSelector:@selector(OAuthClient:didFailWithError:)]) { [self.delegate OAuthClient:self didFailWithError:clientError]; } diff --git a/Code/Network/RKParams.h b/Code/Network/RKParams.h index c20e98f3..0fcc609b 100644 --- a/Code/Network/RKParams.h +++ b/Code/Network/RKParams.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/3/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,27 +25,27 @@ /** This helper class implements the RKRequestSerializable protocol to provide support for creating the multi-part request body for RKRequest objects. - + RKParams enables simple support for file uploading from NSData objects and files stored locally. RKParams will serialize these objects into a multi-part form representation that is suitable for submission to a remote web server for processing. After creating the RKParams object, use [RKClient post:params:delegate:] as the example below does. - + **Example**: - + RKParams *params = [RKParams params]; NSData *imageData = UIImagePNGRepresentation([_imageView image]); [params setData:imageData MIMEType:@"image/png" forParam:@"image1"]; - + UIImage *image = [UIImage imageNamed:@"RestKit.png"]; imageData = UIImagePNGRepresentation(image); [params setData:imageData MIMEType:@"image/png" forParam:@"image2"]; - + [_client post:@"/RKParamsExample" params:params delegate:self]; - + It is also used internally by RKRequest for its OAuth1 implementation. - + */ @interface RKParams : NSInputStream { @private @@ -65,7 +65,7 @@ /** Creates and returns an RKParams object that is ready for population. - + @return An RKParams object to be populated. */ + (RKParams *)params; @@ -73,7 +73,7 @@ /** Creates and returns an RKParams object created from a dictionary of key/value pairs. - + @param dictionary NSDictionary of key/value pairs to add as RKParamsAttachment objects. @return An RKParams object with the key/value pairs of the dictionary. @@ -82,7 +82,7 @@ /** Initalize an RKParams object from a dictionary of key/value pairs - + @param dictionary NSDictionary of key/value pairs to add as RKParamsAttachment objects. @return An RKParams object with the key/value pairs of the dictionary. @@ -112,7 +112,7 @@ /** Creates a new RKParamsAttachment for a named parameter with the data contained in the file at the given path and adds it to the attachments array. - + @param filePath String of the path to the file to be attached @param param Key name of the attachment to add @return the new RKParamsAttachment that was added to the attachments array @@ -122,9 +122,9 @@ /** Creates a new RKParamsAttachment for a named parameter with the data given and adds it to the attachments array. - + A default MIME type of application/octet-stream will be used. - + @param data NSData object of the data to be attached @param param Key name of the attachment to add @return the new RKParamsAttachment that was added to the attachments array @@ -134,7 +134,7 @@ /** Creates a new RKParamsAttachment for a named parameter with the data given and the MIME type specified and adds it to the attachments array. - + @param data NSData object of the data to be attached @param MIMEType String of the MIME type of the data @param param Key name of the attachment to add @@ -145,10 +145,10 @@ /** Creates a new RKParamsAttachment and sets the value for a named parameter to a data object with the specified MIME Type and attachment file name. - + @bug **DEPRECATED**: Use [RKParams setData:MIMEType:forParam:] and set the fileName on the returned RKParamsAttachment instead. - + @param data NSData object of the data to be attached @param MIMEType String of the MIME type of the data @param fileName String of the attachment file name @@ -161,10 +161,10 @@ Creates a new RKParamsAttachment and sets the value for a named parameter to the data contained in a file at the given path with the specified MIME Type and attachment file name. - + @bug **DEPRECATED**: Use [RKParams setFile:forParam:] and set the MIMEType and fileName on the returned RKParamsAttachment instead. - + @param filePath String of the path to the file to be attached @param MIMEType String of the MIME type of the data @param fileName String of the attachment file name @@ -176,18 +176,18 @@ /** Get the dictionary of params which are plain text as specified by [RFC 5849](http://tools.ietf.org/html/rfc5849#section-3.4.1.3). - + This is largely used for RKClient's OAuth1 implementation. - + The params in this dictionary include those where: - + - The entity-body is single-part. - The entity-body follows the encoding requirements of the "application/x-www-form-urlencoded" content-type as defined by [W3C.REC-html40-19980424]. - The HTTP request entity-header includes the "Content-Type" header field set to "application/x-www-form-urlencoded". - + @return NSDictionary of key/values extracting from the RKParamsAttachment objects that meet the plain text criteria */ diff --git a/Code/Network/RKParams.m b/Code/Network/RKParams.m index f1a38a3d..8b90fc86 100644 --- a/Code/Network/RKParams.m +++ b/Code/Network/RKParams.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/3/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,14 +55,14 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; _footer = [[[NSString stringWithFormat:@"--%@--\r\n", kRKStringBoundary] dataUsingEncoding:NSUTF8StringEncoding] retain]; _footerLength = [_footer length]; } - + return self; } - (void)dealloc { [_attachments release]; [_footer release]; - + [super dealloc]; } @@ -77,7 +77,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; [self setValue:value forParam:key]; } } - + return self; } @@ -85,7 +85,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; RKParamsAttachment *attachment = [[RKParamsAttachment alloc] initWithName:param value:value]; [_attachments addObject:attachment]; [attachment release]; - + return attachment; } @@ -103,7 +103,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; RKParamsAttachment *attachment = [[RKParamsAttachment alloc] initWithName:param file:filePath]; [_attachments addObject:attachment]; [attachment release]; - + return attachment; } @@ -113,7 +113,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; RKParamsAttachment *attachment = [[RKParamsAttachment alloc] initWithName:param data:data]; [_attachments addObject:attachment]; [attachment release]; - + return attachment; } @@ -125,7 +125,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; if (MIMEType != nil) { attachment.MIMEType = MIMEType; } - + return attachment; } @@ -139,7 +139,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; if (fileName) { attachment.fileName = fileName; } - + return attachment; } @@ -153,7 +153,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; if (fileName) { attachment.fileName = fileName; } - + return attachment; } @@ -176,13 +176,13 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; - (NSInputStream *)HTTPBodyStream { // Open each of our attachments [_attachments makeObjectsPerformSelector:@selector(open)]; - + // Calculate the length of the stream - _length = _footerLength; + _length = _footerLength; for (RKParamsAttachment *attachment in _attachments) { _length += [attachment length]; } - + return (NSInputStream*)self; } @@ -191,7 +191,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)maxLength { NSUInteger bytesSentInThisRead = 0, bytesRead; NSUInteger lengthOfAttachments = (_length - _footerLength); - + // Proxy the read through to our attachments _streamStatus = NSStreamStatusReading; while (_bytesDelivered < _length && bytesSentInThisRead < maxLength && _currentPart < [_attachments count]) { @@ -199,28 +199,28 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; _currentPart ++; continue; } - + bytesSentInThisRead += bytesRead; _bytesDelivered += bytesRead; } - + // If we have sent all the attachments data, begin emitting the boundary footer if ((_bytesDelivered >= lengthOfAttachments) && (bytesSentInThisRead < maxLength)) { NSUInteger footerBytesSent, footerBytesRemaining, bytesRemainingInBuffer; - + // Calculate our position in the stream & buffer footerBytesSent = _bytesDelivered - lengthOfAttachments; footerBytesRemaining = _footerLength - footerBytesSent; bytesRemainingInBuffer = maxLength - bytesSentInThisRead; - + // Send the entire footer back if there is room - bytesRead = (footerBytesRemaining < bytesRemainingInBuffer) ? footerBytesRemaining : bytesRemainingInBuffer; + bytesRead = (footerBytesRemaining < bytesRemainingInBuffer) ? footerBytesRemaining : bytesRemainingInBuffer; [_footer getBytes:buffer + bytesSentInThisRead range:NSMakeRange(footerBytesSent, bytesRead)]; - + bytesSentInThisRead += bytesRead; _bytesDelivered += bytesRead; } - + return bytesSentInThisRead; } @@ -240,9 +240,9 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; - (void)close { if (_streamStatus != NSStreamStatusClosed) { _streamStatus = NSStreamStatusClosed; - - RKLogTrace(@"RKParams stream closed. Releasing self."); - + + RKLogTrace(@"RKParams stream closed. Releasing self."); + #if TARGET_OS_IPHONE // NOTE: When we are assigned to the URL request, we get // retained. We release ourselves here to ensure the retain @@ -261,7 +261,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; if (_streamStatus != NSStreamStatusClosed && _bytesDelivered >= _length) { _streamStatus = NSStreamStatusAtEnd; } - + return _streamStatus; } @@ -274,7 +274,7 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY"; for (RKParamsAttachment *attachment in self.attachments) { [attachmentsMD5 appendString:[attachment MD5]]; } - + return [attachmentsMD5 MD5]; } diff --git a/Code/Network/RKParamsAttachment.h b/Code/Network/RKParamsAttachment.h index 81103b7c..4b8c932a 100644 --- a/Code/Network/RKParamsAttachment.h +++ b/Code/Network/RKParamsAttachment.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/6/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,14 +24,14 @@ Models an individual part of a multi-part MIME document. These attachments are stacked together within the RKParams document to allow for uploading files via HTTP. - + Typically, interactions with the RKParamsAttachment are accomplished through the RKParams class and there shouldn't be much need to deal directly with this class. */ @interface RKParamsAttachment : NSObject { NSString *_name; - NSString *_fileName; + NSString *_fileName; NSString *_MIMEType; @private @@ -39,7 +39,7 @@ NSData *_body; NSInputStream *_bodyStream; NSData *_MIMEHeader; - NSUInteger _MIMEHeaderLength; + NSUInteger _MIMEHeaderLength; NSUInteger _bodyLength; NSUInteger _length; NSUInteger _delivered; @@ -53,7 +53,7 @@ /** Returns a newly initialized attachment with a given parameter name and value. - + @param name The parameter name of this attachment in the multi-part document. @param value A value that is used to create the attachment body @return An initialized attachment with the given name and value. @@ -63,7 +63,7 @@ /** Returns a newly initialized attachment with a given parameter name and the data stored in an NSData object. - + @param name The parameter name of this attachment in the multi-part document. @param data The data that is used to create the attachment body. @return An initialized attachment with the given name and data. @@ -73,7 +73,7 @@ /** Returns a newly initialized attachment with a given parameter name and the data stored on disk at the given file path. - + @param name The parameter name of this attachment in the multi-part document. @param filePath The complete path of a file to use its data contents as the attachment body. @@ -95,7 +95,7 @@ /** The MIME type of the attached file in the MIME stream. MIME Type will be auto-detected from the file extension of the attached file. - + **Default**: nil */ @property (nonatomic, retain) NSString *MIMEType; @@ -112,7 +112,7 @@ /** The name of the attached file in the MIME stream - + **Default**: The name of the file attached or nil if there is not one. */ @property (nonatomic, retain) NSString *fileName; @@ -130,14 +130,14 @@ /** The length of the entire attachment including the MIME header and the body. - + @return Unsigned integer of the MIME header and the body. */ - (NSUInteger)length; /** Calculate and return an MD5 checksum for the body of this attachment. - + This works for simple values, NSData structures in memory, or by efficiently streaming a file and calculating an MD5. */ @@ -150,12 +150,12 @@ /** Read the attachment body in a streaming fashion for NSInputStream. - + @param buffer A data buffer. The buffer must be large enough to contain the number of bytes specified by len. @param len The maximum number of bytes to read. @return A number indicating the outcome of the operation: - + - A positive number indicates the number of bytes read; - 0 indicates that the end of the buffer was reached; - A negative number means that the operation failed. diff --git a/Code/Network/RKParamsAttachment.m b/Code/Network/RKParamsAttachment.m index fb06dcbb..324c4a7d 100644 --- a/Code/Network/RKParamsAttachment.m +++ b/Code/Network/RKParamsAttachment.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/6/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,7 @@ extern NSString* const kRKStringBoundary; self.name = name; self.fileName = name; } - + return self; } @@ -57,13 +57,13 @@ extern NSString* const kRKStringBoundary; _body = [[(NSString*)value dataUsingEncoding:NSUTF8StringEncoding] retain]; } else { _body = [[[NSString stringWithFormat:@"%@", value] dataUsingEncoding:NSUTF8StringEncoding] retain]; - } - + } + _bodyStream = [[NSInputStream alloc] initWithData:_body]; _bodyLength = [_body length]; _value = [value retain]; } - + return self; } @@ -74,7 +74,7 @@ extern NSString* const kRKStringBoundary; _bodyStream = [[NSInputStream alloc] initWithData:data]; _bodyLength = [data length]; } - + return self; } @@ -85,10 +85,10 @@ extern NSString* const kRKStringBoundary; _filePath = [filePath retain]; _fileName = [[filePath lastPathComponent] retain]; NSString *MIMEType = [filePath MIMETypeForPathExtension]; - if (! MIMEType) MIMEType = @"application/octet-stream"; + if (! MIMEType) MIMEType = @"application/octet-stream"; _MIMEType = [MIMEType retain]; _bodyStream = [[NSInputStream alloc] initWithFileAtPath:filePath]; - + NSError* error; NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error]; if (attributes) { @@ -98,13 +98,13 @@ extern NSString* const kRKStringBoundary; RKLogError(@"Encountered an error while determining file size: %@", error); } } - + return self; } - (void)dealloc { [_value release]; - [_name release]; + [_name release]; [_body release]; [_filePath release]; [_fileName release]; @@ -131,24 +131,24 @@ extern NSString* const kRKStringBoundary; if (self.fileName && self.MIMEType) { // Typical for file attachments _MIMEHeader = [[[NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"; " - @"filename=\"%@\"\r\nContent-Type: %@\r\n\r\n", + @"filename=\"%@\"\r\nContent-Type: %@\r\n\r\n", [self MIMEBoundary], self.name, self.fileName, self.MIMEType] dataUsingEncoding:NSUTF8StringEncoding] retain]; } else if (self.MIMEType) { // Typical for data values _MIMEHeader = [[[NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n" - @"Content-Type: %@\r\n\r\n", + @"Content-Type: %@\r\n\r\n", [self MIMEBoundary], self.name, self.MIMEType] dataUsingEncoding:NSUTF8StringEncoding] retain]; } else { // Typical for raw values - _MIMEHeader = [[[NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n", - [self MIMEBoundary], self.name] + _MIMEHeader = [[[NSString stringWithFormat:@"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n", + [self MIMEBoundary], self.name] dataUsingEncoding:NSUTF8StringEncoding] retain]; } - + // Calculate lengths _MIMEHeaderLength = [_MIMEHeader length]; _length = _MIMEHeaderLength + _bodyLength + 2; // \r\n is the + 2 - + // Open the stream [_bodyStream open]; } @@ -159,50 +159,50 @@ extern NSString* const kRKStringBoundary; - (NSUInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)maxLength { NSUInteger sent = 0, read; - + // We are done with the read if (_delivered >= _length) { return 0; } - + // First we send back the MIME headers if (_delivered < _MIMEHeaderLength && sent < maxLength) { NSUInteger headerBytesRemaining, bytesRemainingInBuffer; - + headerBytesRemaining = _MIMEHeaderLength - _delivered; bytesRemainingInBuffer = maxLength; - + // Send the entire header if there is room read = (headerBytesRemaining < bytesRemainingInBuffer) ? headerBytesRemaining : bytesRemainingInBuffer; [_MIMEHeader getBytes:buffer range:NSMakeRange(_delivered, read)]; - + sent += read; _delivered += sent; } - + // Read the attachment body out of our underlying stream while (_delivered >= _MIMEHeaderLength && _delivered < (_length - 2) && sent < maxLength) { if ((read = [_bodyStream read:(buffer + sent) maxLength:(maxLength - sent)]) == 0) { break; } - + sent += read; _delivered += read; } - - // Append the \r\n + + // Append the \r\n if (_delivered >= (_length - 2) && sent < maxLength) { if (_delivered == (_length - 2)) { *(buffer + sent) = '\r'; sent ++; _delivered ++; } - + *(buffer + sent) = '\n'; sent ++; _delivered ++; } - + return sent; } @@ -210,7 +210,7 @@ extern NSString* const kRKStringBoundary; if (_body) { return [_body MD5]; } else if (_filePath) { - CFStringRef fileAttachmentMD5 = FileMD5HashCreateWithPath((CFStringRef)_filePath, + CFStringRef fileAttachmentMD5 = FileMD5HashCreateWithPath((CFStringRef)_filePath, FileHashDefaultChunkSizeForReadingData); return [(NSString *)fileAttachmentMD5 autorelease]; } else { diff --git a/Code/Network/RKReachabilityObserver.h b/Code/Network/RKReachabilityObserver.h index aa0c959b..41807083 100755 --- a/Code/Network/RKReachabilityObserver.h +++ b/Code/Network/RKReachabilityObserver.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/14/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,13 +64,13 @@ typedef enum { /** Provides a notification based interface for monitoring changes to network status. - + When initialized, creates an SCReachabilityReg and schedules it for callback notifications on the main dispatch queue. As notifications are intercepted from SystemConfiguration, the observer will update its state and emit `[RKReachabilityDidChangeNotifications](RKReachabilityDidChangeNotification)` to inform listeners about state changes. - + Portions of this software are derived from the Apple Reachability code sample: http://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_m.html */ @@ -79,7 +79,7 @@ typedef enum { SCNetworkReachabilityRef _reachabilityRef; BOOL _reachabilityDetermined; BOOL _monitoringLocalWiFi; - SCNetworkReachabilityFlags _reachabilityFlags; + SCNetworkReachabilityFlags _reachabilityFlags; } ///----------------------------------------------------------------------------- @@ -90,12 +90,12 @@ typedef enum { Creates and returns a RKReachabilityObserver instance observing reachability changes to the hostname or IP address referenced in a given string. The observer will monitor the ability to reach the specified remote host and emit - notifications when its reachability status changes. - + notifications when its reachability status changes. + The hostNameOrIPAddress will be introspected to determine if it contains an IP address encoded into a string or a DNS name. The observer will be configured appropriately based on the contents of the string. - + @bug Note that iOS 5 has known issues with hostname based reachability @param hostNameOrIPAddress An NSString containing a hostname or IP address to be observed. @@ -107,7 +107,7 @@ typedef enum { /** Creates and returns a reachabilityObserverForInternet instance observing the reachability to the Internet in general. - + @return A reachability observer targeting INADDR_ANY or nil if it could not be observed. */ @@ -117,7 +117,7 @@ typedef enum { Creates and returns a reachabilityObserverForInternet instance observing the reachability to the Internet via the local WiFi interface. Internet access available via the WWAN (3G, Edge, etc) will not be considered reachable. - + @return A reachability observer targeting IN_LINKLOCALNETNUM or nil if it could not be observed. */ @@ -126,7 +126,7 @@ typedef enum { /** Creates and returns a RKReachabilityObserver instance observing reachability changes to the sockaddr address provided. - + @param address A socket address to determine reachability for. @return A reachability observer targeting the given socket address or nil if it could not be observed. @@ -135,8 +135,8 @@ typedef enum { /** Creates and returns a RKReachabilityObserver instance observing reachability - changes to the IP address provided. - + changes to the IP address provided. + @param internetAddress A 32-bit integer representation of an IP address @return A reachability observer targeting the given IP address or nil if it could not be observed. @@ -147,12 +147,12 @@ typedef enum { Returns a RKReachabilityObserver instance observing reachability changes to the hostname or IP address referenced in a given string. The observer will monitor the ability to reach the specified remote host and emit notifications when its - reachability status changes. - + reachability status changes. + The hostNameOrIPAddress will be introspected to determine if it contains an IP address encoded into a string or a DNS name. The observer will be configured appropriately based on the contents of the string. - + @bug Note that iOS 5 has known issues with hostname based reachability @param hostNameOrIPAddress An NSString containing a hostname or IP address to be observed. @@ -164,7 +164,7 @@ typedef enum { /** Returns a RKReachabilityObserver instance observing reachability changes to the sockaddr address provided. - + @param address A socket address to determine reachability for. @return A reachability observer targeting the given socket address or nil if it could not be observed. @@ -188,13 +188,13 @@ typedef enum { /** Current state of determining reachability - + When initialized, RKReachabilityObserver instances are in an indeterminate state to indicate that reachability status has not been yet established. After the first callback is processed by the observer, the observer will answer YES for reachabilityDetermined and networkStatus will return a determinate response. - + @return YES if reachability has been determined */ @property (nonatomic, readonly, getter=isReachabilityDetermined) BOOL reachabilityDetermined; @@ -202,26 +202,26 @@ typedef enum { /** Current network status as determined by examining the state of the currently cached reachabilityFlags - + @return Status of the network as RKReachabilityNetworkStatus */ @property (nonatomic, readonly) RKReachabilityNetworkStatus networkStatus; /** Current state of the local WiFi interface's reachability - + When the local WiFi interface is being monitored, only three reachability states are possible: - + - RKReachabilityIndeterminate - RKReachabilityNotReachable - RKReachabilityReachableViaWiFi - + If the device has connectivity through a WWAN connection only it will consider the network not reachable. - + @see reachabilityObserverForLocalWifi - + @return YES if the reachability observer is monitoring the local WiFi interface */ @property (nonatomic, readonly, getter=isMonitoringLocalWiFi) BOOL monitoringLocalWiFi; @@ -229,13 +229,13 @@ typedef enum { /** The reachability flags as of the last invocation of the reachability callback - + Each time the reachability callback is invoked with an asynchronous update of reachability status the flags are cached and made accessible via the reachabilityFlags method. - + Flags can also be directly obtained via [RKReachabilityObserver getFlags] - + @see getFlags @return The most recently cached reachability flags reflecting current network status. @@ -245,7 +245,7 @@ typedef enum { /** Acquires the current network reachability flags, answering YES if successfully acquired; answering NO otherwise. - + Beware! The System Configuration framework operates synchronously by default. See Technical Q&A QA1693, Synchronous Networking On The Main Thread. Asking for flags blocks the current thread and potentially kills your @@ -261,7 +261,7 @@ typedef enum { /** Returns YES when the Internet is reachable (via WiFi or WWAN) - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if called before reachability is determined */ @@ -269,7 +269,7 @@ typedef enum { /** Returns YES when we the network is reachable via WWAN - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if called before reachability is determined */ @@ -277,7 +277,7 @@ typedef enum { /** Returns YES when we the network is reachable via WiFi - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if called before reachability is determined */ @@ -285,7 +285,7 @@ typedef enum { /** Returns YES when WWAN may be available, but not active until a connection has been established. - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if called before reachability is determined */ @@ -293,7 +293,7 @@ typedef enum { /** Returns YES if a dynamic, on-demand connection is available - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if called before reachability is determined */ @@ -301,7 +301,7 @@ typedef enum { /** Returns YES if user intervention is required to initiate a connection - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if called before reachability is determined */ @@ -309,7 +309,7 @@ typedef enum { /** Returns a string representation of the currently cached reachabilityFlags for inspection - + @return A string containing single character representations of the bits in an SCNetworkReachabilityFlags */ diff --git a/Code/Network/RKReachabilityObserver.m b/Code/Network/RKReachabilityObserver.m index c19a1b43..6d1d1be8 100755 --- a/Code/Network/RKReachabilityObserver.m +++ b/Code/Network/RKReachabilityObserver.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/14/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,10 +49,10 @@ NSString* const RKReachabilityWasDeterminedNotification = @"RKReachabilityWasDet static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - + RKReachabilityObserver *observer = (RKReachabilityObserver *) info; observer.reachabilityFlags = flags; - + [pool release]; } @@ -105,24 +105,24 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach // http://www.opensource.apple.com/source/bootp/bootp-89/IPConfiguration.bproj/linklocal.c // _monitoringLocalWiFi = address->sa_len == sizeof(struct sockaddr_in) && address->sa_family == AF_INET && IN_LINKLOCAL(ntohl(((const struct sockaddr_in *)address)->sin_addr.s_addr)); - + // Save the IP address char str[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, &((const struct sockaddr_in *)address)->sin_addr, str, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &((const struct sockaddr_in *)address)->sin_addr, str, INET_ADDRSTRLEN); _host = [[NSString alloc] initWithCString:str encoding:NSUTF8StringEncoding]; - + if (_monitoringLocalWiFi) { RKLogInfo(@"Reachability observer initialized for Local Wifi"); - } else if (address->sa_len == sizeof(struct sockaddr_in) && address->sa_family == AF_INET) { + } else if (address->sa_len == sizeof(struct sockaddr_in) && address->sa_family == AF_INET) { RKLogInfo(@"Reachability observer initialized with IP address: %@.", _host); } - + // We can immediately determine reachability to an IP address dispatch_async(dispatch_get_main_queue(), ^{ // Obtain the flags after giving other objects a chance to observe us [self getFlags]; }); - + // Schedule the observer [self scheduleObserver]; } @@ -134,23 +134,23 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach // Determine if the string contains a hostname or IP address struct sockaddr_in sa; char *hostNameOrIPAddressCString = (char *) [hostNameOrIPAddress UTF8String]; - int result = inet_pton(AF_INET, hostNameOrIPAddressCString, &(sa.sin_addr)); + int result = inet_pton(AF_INET, hostNameOrIPAddressCString, &(sa.sin_addr)); if (result != 0) { // IP Address struct sockaddr_in remote_saddr; - + bzero(&remote_saddr, sizeof(struct sockaddr_in)); remote_saddr.sin_len = sizeof(struct sockaddr_in); remote_saddr.sin_family = AF_INET; inet_aton(hostNameOrIPAddressCString, &(remote_saddr.sin_addr)); - + return [self initWithAddress:(struct sockaddr *) &remote_saddr]; } - + // Hostname - self = [self init]; + self = [self init]; if (self) { - _host = [hostNameOrIPAddress retain]; + _host = [hostNameOrIPAddress retain]; _reachabilityRef = SCNetworkReachabilityCreateWithName(CFAllocatorGetDefault(), hostNameOrIPAddressCString); RKLogInfo(@"Reachability observer initialized with hostname %@", hostNameOrIPAddress); if (_reachabilityRef == NULL) { @@ -161,7 +161,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach [self scheduleObserver]; } } - + return self; } @@ -174,7 +174,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach CFRelease(_reachabilityRef); } [_host release]; - + [super dealloc]; } @@ -190,29 +190,29 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach case RKReachabilityIndeterminate: return @"RKReachabilityIndeterminate"; break; - + case RKReachabilityNotReachable: return @"RKReachabilityNotReachable"; break; - + case RKReachabilityReachableViaWiFi: return @"RKReachabilityReachableViaWiFi"; - break; - + break; + case RKReachabilityReachableViaWWAN: return @"RKReachabilityReachableViaWWAN"; break; - + default: break; } - + return nil; } - (NSString *)reachabilityFlagsDescription { return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c", - #if TARGET_OS_IPHONE + #if TARGET_OS_IPHONE (_reachabilityFlags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', #else // If we are not on iOS, always output a dash for WWAN @@ -231,14 +231,14 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach - (RKReachabilityNetworkStatus)networkStatus { NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef"); RKReachabilityNetworkStatus status = RKReachabilityNotReachable; - + if (!self.reachabilityDetermined) { RKLogTrace(@"Reachability observer %@ has not yet established reachability. networkStatus = %@", self, @"RKReachabilityIndeterminate"); return RKReachabilityIndeterminate; } - + RKLogTrace(@"Reachability Flags: %@\n", [self reachabilityFlagsDescription]); - + // If we are observing WiFi, we are only reachable via WiFi when flags are direct if (self.isMonitoringLocalWiFi) { if ((_reachabilityFlags & kSCNetworkReachabilityFlagsReachable) && (_reachabilityFlags & kSCNetworkReachabilityFlagsIsDirect)) { @@ -279,9 +279,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach status = RKReachabilityNotReachable; } } - + RKLogTrace(@"Reachability observer %@ determined networkStatus = %@", self, [self stringFromNetworkStatus:status]); - return status; + return status; } #pragma Reachability Flag Introspection @@ -301,7 +301,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach - (BOOL)isConnectionRequired { [self validateIntrospection]; BOOL required = (_reachabilityFlags & kSCNetworkReachabilityFlagsConnectionRequired); - + RKLogDebug(@"Reachability observer %@ determined isConnectionRequired = %d", self, required); return required; } @@ -319,9 +319,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach - (BOOL)isConnectionOnDemand { [self validateIntrospection]; return ((_reachabilityFlags & kSCNetworkReachabilityFlagsConnectionRequired) && - (_reachabilityFlags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | + (_reachabilityFlags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand))); - + } - (BOOL)isInterventionRequired { @@ -339,7 +339,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach RKLogWarning(@"%@: SCNetworkReachabilitySetCallback() failed: %s", self, SCErrorString(SCError())); return; } - + if (! SCNetworkReachabilitySetDispatchQueue(_reachabilityRef, dispatch_get_main_queue())) { RKLogWarning("%@: SCNetworkReachabilitySetDispatchQueue() failed: %s", self, SCErrorString(SCError())); return; @@ -357,26 +357,26 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach RKLogDebug(@"%@: Failed to unschedule reachability observer %@: reachability reference is nil.", self, _reachabilityRef); } } - + - (void)setReachabilityFlags:(SCNetworkReachabilityFlags)reachabilityFlags { // Save the reachability flags _reachabilityFlags = reachabilityFlags; - + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedInt:reachabilityFlags] forKey:RKReachabilityFlagsUserInfoKey]; - + if (! self.reachabilityDetermined) { _reachabilityDetermined = YES; - RKLogInfo(@"Network availability has been determined for reachability observer %@", self); + RKLogInfo(@"Network availability has been determined for reachability observer %@", self); [[NSNotificationCenter defaultCenter] postNotificationName:RKReachabilityWasDeterminedNotification object:self userInfo:userInfo]; } - + // Post a notification to notify the client that the network reachability changed. [[NSNotificationCenter defaultCenter] postNotificationName:RKReachabilityDidChangeNotification object:self userInfo:userInfo]; } - (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%d reachabilityFlags=%@>", - NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO", + return [NSString stringWithFormat:@"<%@: %p host=%@ isReachabilityDetermined=%@ isMonitoringLocalWiFi=%d reachabilityFlags=%@>", + NSStringFromClass([self class]), self, self.host, self.isReachabilityDetermined ? @"YES" : @"NO", self.isMonitoringLocalWiFi ? @"YES" : @"NO", [self reachabilityFlagsDescription]]; } diff --git a/Code/Network/RKRequest.h b/Code/Network/RKRequest.h index 6ef38031..5bee8482 100644 --- a/Code/Network/RKRequest.h +++ b/Code/Network/RKRequest.h @@ -167,7 +167,7 @@ typedef void(^RKRequestDidFailLoadWithErrorBlock)(NSError *error); RKRequestDidLoadResponseBlock _onDidLoadResponse; RKRequestDidFailLoadWithErrorBlock _onDidFailLoadWithError; - + #if TARGET_OS_IPHONE RKRequestBackgroundPolicy _backgroundPolicy; UIBackgroundTaskIdentifier _backgroundTaskIdentifier; diff --git a/Code/Network/RKRequest.m b/Code/Network/RKRequest.m index d02af246..20d4b276 100644 --- a/Code/Network/RKRequest.m +++ b/Code/Network/RKRequest.m @@ -552,13 +552,13 @@ RKRequestMethod RKRequestMethodTypeFromName(NSString *methodName) { [self didFinishLoad:[self loadResponseFromCache]]; } else { 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]]; 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]; } } diff --git a/Code/Network/RKRequestCache.h b/Code/Network/RKRequestCache.h index 127d67d4..b2bb9374 100644 --- a/Code/Network/RKRequestCache.h +++ b/Code/Network/RKRequestCache.h @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 4/4/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,9 +50,9 @@ extern NSString * const RKRequestCacheSessionCacheDirectory; */ extern NSString * const RKRequestCachePermanentCacheDirectory; -/** +/** @constant RKRequestCache Header Keys - + Constants for accessing cache specific X-RESTKIT headers used to store cache metadata within the cache entry. */ @@ -82,7 +82,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Initializes the receiver with a cache at a given path and storage policy. - + @param cachePath The path to store cached data in. @param storagePolicy The storage policy to use for cached data. @return An initialized request cache object. @@ -100,7 +100,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Returns the cache path for the specified request. - + @param request An RKRequest object to determine the cache path. @return A string of the cache path for the specified request. */ @@ -108,7 +108,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Determine if a response exists for a request. - + @param request An RKRequest object that is looking for cached content. @return A boolean value for if a response exists in the cache. */ @@ -121,7 +121,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Store a request's response in the cache. - + @param response The response to be stored in the cache. @param request The request that retrieved the response. */ @@ -129,7 +129,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Set the cache date for a request. - + @param date The date the response for a request was cached. @param request The request to store the cache date for. */ @@ -141,7 +141,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Returns a dictionary of cached headers for a cached request. - + @param request The request to retrieve cached headers for. @return An NSDictionary of the cached headers that were stored for the specified request. @@ -150,7 +150,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Returns an ETag for a request if it is stored in the cached headers. - + @param request The request that an ETag is to be determined for. @return A string of the ETag value stored for the specified request. */ @@ -158,7 +158,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Returns the date of the cached request. - + @param request The request that needs a cache date returned. @return A date object for the cached request. */ @@ -166,7 +166,7 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Returns the cached response for a given request. - + @param request The request used to find the cached response. @return An RKResponse object that was cached for a given request. */ @@ -183,14 +183,14 @@ extern NSString * const RKRequestCacheURLHeadersKey; /** Invalidate the cache for a given request. - + @param request The request that needs its cache invalidated. */ - (void)invalidateRequest:(RKRequest *)request; /** Invalidate any caches that fall under the given storage policy. - + @param storagePolicy The RKRequestCacheStorePolicy used to determine which caches need to be invalidated. */ diff --git a/Code/Network/RKRequestCache.m b/Code/Network/RKRequestCache.m index 36dc5d94..94e8bc57 100644 --- a/Code/Network/RKRequestCache.m +++ b/Code/Network/RKRequestCache.m @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 4/4/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Network/RKRequestQueue.h b/Code/Network/RKRequestQueue.h index 018b828d..b8da091c 100644 --- a/Code/Network/RKRequestQueue.h +++ b/Code/Network/RKRequestQueue.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 12/1/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,7 +46,7 @@ /** Creates and returns a new request queue. - + @return An autoreleased RKRequestQueue object. */ + (id)requestQueue; @@ -54,7 +54,7 @@ /** Returns a new retained request queue with the given name. If there is already an existing queue with the given name, nil will be returned. - + @param name A symbolic name for the queue. @return A new retained RKRequestQueue with the given name or nil if one already exists with the given name. @@ -69,7 +69,7 @@ /** Returns queue with the specified name. If no queue is found with the name provided, a new queue will be initialized and returned. - + @param name A symbolic name for the queue. @return An existing RKRequestQueue with the given name or a new queue if none currently exist. @@ -82,7 +82,7 @@ /** A symbolic name for the queue. - + Used to return existing queue references via [RKRequestQueue requestQueueWithName:] */ @@ -90,7 +90,7 @@ /** Determine if a queue exists with a given name. - + @param name The queue name to search against. @return YES when there is a queue with the given name. */ @@ -103,7 +103,7 @@ /** The delegate to inform when the request queue state machine changes. - + If the object implements the RKRequestQueueDelegate protocol, it will receive request lifecycle event messages. */ @@ -116,14 +116,14 @@ /** The number of concurrent requests supported by this queue. - + **Default**: 5 concurrent requests */ @property (nonatomic) NSUInteger concurrentRequestsLimit; /** Request timeout value used by the queue. - + **Default**: 5 minutes (300 seconds) */ @property (nonatomic, assign) NSUInteger requestTimeout; @@ -135,21 +135,21 @@ /** Add an asynchronous request to the queue and send it as as soon as possible. - + @param request The request to be added to the queue. */ - (void)addRequest:(RKRequest *)request; /** Cancel a request that is in progress. - + @param request The request to be cancelled. */ - (void)cancelRequest:(RKRequest *)request; /** Cancel all requests with a given delegate. - + @param delegate The delegate assigned to the requests to be cancelled. */ - (void)cancelRequestsWithDelegate:(id)delegate; @@ -173,7 +173,7 @@ /** Determine if a given request is currently in this queue. - + @param request The request to check the queue for. @return YES if the specified request is in this queue. */ @@ -192,7 +192,7 @@ /** Sets the flag that determines if new load requests are allowed to reach the network. - + Because network requests tend to slow down performance, this property can be used to temporarily delay them. All requests made while suspended are queued, and when suspended becomes false again they are executed. @@ -207,10 +207,10 @@ #if TARGET_OS_IPHONE /** Sets the flag for showing the network activity indicatory. - + When YES, this queue will spin the network activity in the menu bar when it is processing requests. - + **Default**: NO */ @property (nonatomic) BOOL showsNetworkActivityIndicatorWhenBusy; @@ -223,10 +223,10 @@ /** Returns the global queue - + @bug **DEPRECATED** in v0.9.4: All RKClient instances now own their own individual request queues. - + @see [RKClient requestQueue] @return Global request queue. */ @@ -234,10 +234,10 @@ /** Sets the global queue - + @bug **DEPRECATED** in v0.9.4: All RKClient instances now own their own individual request queues. - + @see [RKClient requestQueue] @param requestQueue The request queue to assign as the global queue. */ @@ -258,28 +258,28 @@ /** Sent when the queue transitions from an empty state to processing requests. - - @param queue The queue that began processing requests. + + @param queue The queue that began processing requests. */ - (void)requestQueueDidBeginLoading:(RKRequestQueue *)queue; /** Sent when queue transitions from a processing state to an empty start. - + @param queue The queue that finished processing requests. */ - (void)requestQueueDidFinishLoading:(RKRequestQueue *)queue; /** Sent when the queue has been suspended and request processing has been halted. - + @param queue The request queue that has been suspended. */ - (void)requestQueueWasSuspended:(RKRequestQueue *)queue; /** Sent when the queue has been unsuspended and request processing has resumed. - + @param queue The request queue that has resumed processing. */ - (void)requestQueueWasUnsuspended:(RKRequestQueue *)queue; @@ -291,7 +291,7 @@ /** Sent before queue sends a request. - + @param queue The queue that will process the request. @param request The request to be processed. */ @@ -299,7 +299,7 @@ /** Sent after queue has sent a request. - + @param queue The queue that processed the request. @param request The processed request. */ @@ -307,7 +307,7 @@ /** Sent when queue received a response for a request. - + @param queue The queue that received the response. @param response The response that was received. */ @@ -315,7 +315,7 @@ /** Sent when queue has canceled a request. - + @param queue The queue that cancelled the request. @param request The cancelled request. */ @@ -323,7 +323,7 @@ /** Sent when an attempted request fails. - + @param queue The queue in which the request failed from. @param request The failed request. @param error An NSError object containing the RKRestKitError that caused the @@ -337,7 +337,7 @@ /** A category on UIApplication to allow for jointly managing the network activity indicator. - + Adopted from 'iOS Recipes' book: http://pragprog.com/book/cdirec/ios-recipes */ @interface UIApplication (RKNetworkActivity) diff --git a/Code/Network/RKRequestQueue.m b/Code/Network/RKRequestQueue.m index 131b4604..9ddbd5d4 100644 --- a/Code/Network/RKRequestQueue.m +++ b/Code/Network/RKRequestQueue.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 12/1/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -72,25 +72,25 @@ static const NSTimeInterval kFlushDelay = 0.3; + (id)newRequestQueueWithName:(NSString*)name { if (RKRequestQueueInstances == nil) { - RKRequestQueueInstances = [NSMutableArray new]; + RKRequestQueueInstances = [NSMutableArray new]; } - + if ([self requestQueueExistsWithName:name]) { return nil; } - + RKRequestQueue* queue = [self new]; queue.name = name; [RKRequestQueueInstances addObject:[NSValue valueWithNonretainedObject:queue]]; - + return queue; } + (id)requestQueueWithName:(NSString *)name { if (RKRequestQueueInstances == nil) { - RKRequestQueueInstances = [NSMutableArray new]; + RKRequestQueueInstances = [NSMutableArray new]; } - + // Find existing reference NSArray *requestQueueInstances = [RKRequestQueueInstances copy]; RKRequestQueue *namedQueue = nil; @@ -102,13 +102,13 @@ static const NSTimeInterval kFlushDelay = 0.3; } } [requestQueueInstances release]; - + if (namedQueue == nil) { namedQueue = [self requestQueue]; namedQueue.name = name; [RKRequestQueueInstances addObject:[NSValue valueWithNonretainedObject:namedQueue]]; } - + return namedQueue; } @@ -125,10 +125,10 @@ static const NSTimeInterval kFlushDelay = 0.3; } [requestQueueInstances release]; } - + return queueExists; } - + - (id)init { if ((self = [super init])) { _requests = [[NSMutableArray alloc] init]; @@ -170,7 +170,7 @@ static const NSTimeInterval kFlushDelay = 0.3; - (void)dealloc { RKLogDebug(@"Queue instance is being deallocated: %@", self); [[NSNotificationCenter defaultCenter] removeObserver:self]; - + [self removeFromNamedQueues]; [_queueTimer invalidate]; @@ -187,8 +187,8 @@ static const NSTimeInterval kFlushDelay = 0.3; } - (NSString*)description { - return [NSString stringWithFormat:@"<%@: %p name=%@ suspended=%@ requestCount=%d loadingCount=%d/%d>", - NSStringFromClass([self class]), self, self.name, self.suspended ? @"YES" : @"NO", + return [NSString stringWithFormat:@"<%@: %p name=%@ suspended=%@ requestCount=%d loadingCount=%d/%d>", + NSStringFromClass([self class]), self, self.name, self.suspended ? @"YES" : @"NO", self.count, self.loadingCount, self.concurrentRequestsLimit]; } @@ -267,7 +267,7 @@ static const NSTimeInterval kFlushDelay = 0.3; [self performSelectorOnMainThread:@selector(loadNextInQueue) withObject:nil waitUntilDone:NO]; return; } - + // Make sure that the Request Queue does not fire off any requests until the Reachability state has been determined. if (self.suspended) { _queueTimer = nil; @@ -279,7 +279,7 @@ static const NSTimeInterval kFlushDelay = 0.3; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; _queueTimer = nil; - + @synchronized(self) { RKRequest* request = [self nextRequest]; while (request && self.loadingCount < _concurrentRequestsLimit) { @@ -501,7 +501,7 @@ static const NSTimeInterval kFlushDelay = 0.3; if ([_delegate respondsToSelector:@selector(requestQueue:didFailRequest:withError:)]) { [_delegate requestQueue:self didFailRequest:request withError:error]; } - + [self removeLoadingRequest:request]; [self loadNextInQueue]; } diff --git a/Code/Network/RKRequestSerializable.h b/Code/Network/RKRequestSerializable.h index 4e7e9602..9e29552b 100644 --- a/Code/Network/RKRequestSerializable.h +++ b/Code/Network/RKRequestSerializable.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/3/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,10 +22,10 @@ This protocol is implemented by objects that can be serialized into a representation suitable for transmission over a REST request. Suitable serializations are x-www-form-urlencoded and multipart/form-data. - + @warning One of the following methods MUST be implemented for your serializable implementation to be complete: - + - (NSData *)HTTPBody - If you are allowing serialization of a small in-memory data structure, implement HTTPBody as it is much simpler. - (NSInputStream *)HTTPBodyStream - This provides support for streaming a large @@ -41,7 +41,7 @@ /** The value of the Content-Type header for the HTTP Body representation of the serialization. - + @return A string value of the Content-Type header for the HTTP body. */ - (NSString *)HTTPHeaderValueForContentType; @@ -55,7 +55,7 @@ /** An NSData representing the HTTP Body serialization of the object implementing the protocol. - + @return An NSData object respresenting the HTTP body serialization. */ - (NSData *)HTTPBody; @@ -63,7 +63,7 @@ /** Returns an input stream for reading the serialization as a stream used to provide support for handling large HTTP payloads. - + @return An input stream for reading the serialization as a stream. */ - (NSInputStream *)HTTPBodyStream; @@ -75,7 +75,7 @@ /** Returns the length of the HTTP Content-Length header. - + @return Unsigned integer length of the HTTP Content-Length header. */ - (NSUInteger)HTTPHeaderValueForContentLength; @@ -83,7 +83,7 @@ /** The value of the Content-Type header for the HTTP Body representation of the serialization. - + @bug **DEPRECATED** in v0.9.4: Implement [RKRequestSerializable HTTPHeaderValueForContentType] instead. @return A string value of the Content-Type header for the HTTP body. diff --git a/Code/Network/RKRequestSerialization.h b/Code/Network/RKRequestSerialization.h index 5fbc5593..62317f28 100644 --- a/Code/Network/RKRequestSerialization.h +++ b/Code/Network/RKRequestSerialization.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/18/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ A simple implementation of the RKRequestSerializable protocol suitable for wrapping a MIME Type string and HTTP Body into a format that can be sent as the params of an RKRequest. - + @see RKRequestSerializable */ @interface RKRequestSerialization : NSObject { @@ -40,7 +40,7 @@ /** Creates and returns a new serialization enclosing an NSData object with the specified MIME type. - + @param data An NSData object to initialize the serialization with. @param MIMEType A string of the MIME type of the provided data. @return An autoreleased RKRequestSerialization object with the data and MIME @@ -51,7 +51,7 @@ /** Returns a new serialization enclosing an NSData object with the specified MIME type. - + @param data An NSData object to initialize the serialization with. @param MIMEType A string of the MIME type of the provided data. @return An RKRequestSerialization object with the data and MIME type set. diff --git a/Code/Network/RKRequestSerialization.m b/Code/Network/RKRequestSerialization.m index 839e51c3..f00c12d2 100644 --- a/Code/Network/RKRequestSerialization.m +++ b/Code/Network/RKRequestSerialization.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/18/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,13 +28,13 @@ - (id)initWithData:(NSData *)data MIMEType:(NSString *)MIMEType { NSAssert(data, @"Cannot create a request serialization without Data"); NSAssert(MIMEType, @"Cannot create a request serialization without a MIME Type"); - + self = [super init]; if (self) { _data = [data retain]; _MIMEType = [MIMEType retain]; } - + return self; } @@ -45,7 +45,7 @@ - (void)dealloc { [_data release]; [_MIMEType release]; - + [super dealloc]; } diff --git a/Code/Network/RKRequest_Internals.h b/Code/Network/RKRequest_Internals.h index b89dd5dd..1184188d 100644 --- a/Code/Network/RKRequest_Internals.h +++ b/Code/Network/RKRequest_Internals.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/31/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Network/RKResponse.h b/Code/Network/RKResponse.h index 90269759..6d81d44f 100644 --- a/Code/Network/RKResponse.h +++ b/Code/Network/RKResponse.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/28/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,7 @@ /** Initializes a new response object for a REST request. - + @param request The request that the response being created belongs to. @return An RKResponse object with the request parameter set. */ @@ -48,7 +48,7 @@ /** Initializes a new response object from a cached request. - + @param request The request that the response being created belongs to. @param body The data of the body of the response. @param headers A dictionary of the response's headers. @@ -58,7 +58,7 @@ /** Initializes a response object from the results of a synchronous request. - + @param request The request that the response being created belongs to. @param URLResponse The response from the NSURLConnection call containing the headers and HTTP status code. @@ -153,7 +153,7 @@ /** Returns the response body parsed as JSON into an object - + @param error An NSError to populate if something goes wrong while parsing the body JSON into an object. */ @@ -171,14 +171,14 @@ /** Determines if there is an error object and uses it's localized message - + @return A string of the localized error message. */ - (NSString *)failureErrorDescription; /** Indicates whether the response was loaded from RKCache - + @return YES if the response was loaded from the cache */ - (BOOL)wasLoadedFromCache; @@ -191,62 +191,62 @@ /** Indicates that the connection failed to reach the remote server. The details of the failure are available on the failureError reader. - + @return YES if the connection failed to reach the remote server. */ - (BOOL)isFailure; /** Indicates an invalid HTTP response code less than 100 or greater than 600 - + @return YES if the HTTP response code is less than 100 or greater than 600 */ - (BOOL)isInvalid; /** Indicates an informational HTTP response code between 100 and 199 - + @return YES if the HTTP response code is between 100 and 199 */ - (BOOL)isInformational; /** Indicates an HTTP response code between 200 and 299. - + Confirms that the server received, understood, accepted and processed the request successfully. - + @return YES if the HTTP response code is between 200 and 299 */ - (BOOL)isSuccessful; /** Indicates an HTTP response code between 300 and 399. - + This class of status code indicates that further action needs to be taken by the user agent in order to fulfil the request. The action required may be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. - + @return YES if the HTTP response code is between 300 and 399. */ - (BOOL)isRedirection; /** Indicates an HTTP response code between 400 and 499. - + This status code is indented for cases in which the client seems to have erred. - + @return YES if the HTTP response code is between 400 and 499. */ - (BOOL)isClientError; /** Indicates an HTTP response code between 500 and 599. - + This state code occurs when the server failed to fulfill an apparently valid request. - + @return YES if the HTTP response code is between 500 and 599. */ - (BOOL)isServerError; @@ -258,7 +258,7 @@ /** Indicates that the response is either a server or a client error. - + @return YES if the response is either a server or client error, with a response code between 400 and 599. */ @@ -266,91 +266,91 @@ /** Indicates an HTTP response code of 200. - + @return YES if the response is 200 OK. */ - (BOOL)isOK; /** Indicates an HTTP response code of 201. - + @return YES if the response is 201 Created. */ - (BOOL)isCreated; /** Indicates an HTTP response code of 204. - + @return YES if the response is 204 No Content. */ - (BOOL)isNoContent; /** Indicates an HTTP response code of 304. - + @return YES if the response is 304 Not Modified. */ - (BOOL)isNotModified; /** Indicates an HTTP response code of 401. - + @return YES if the response is 401 Unauthorized. */ - (BOOL)isUnauthorized; /** Indicates an HTTP response code of 403. - + @return YES if the response is 403 Forbidden. */ - (BOOL)isForbidden; /** Indicates an HTTP response code of 404. - + @return YES if the response is 404 Not Found. */ - (BOOL)isNotFound; /** Indicates an HTTP response code of 409. - + @return YES if the response is 409 Conflict. */ - (BOOL)isConflict; /** Indicates an HTTP response code of 410. - + @return YES if the response is 410 Gone. */ - (BOOL)isGone; /** Indicates an HTTP response code of 422. - + @return YES if the response is 422 Unprocessable Entity. */ - (BOOL)isUnprocessableEntity; /** Indicates an HTTP response code of 301, 302, 303 or 307. - + @return YES if the response requires a redirect to finish processing. */ - (BOOL)isRedirect; /** Indicates an empty HTTP response code of 201, 204, or 304 - + @return YES if the response body is empty. */ - (BOOL)isEmpty; /** Indicates an HTTP response code of 503 - + @return YES if the response is 503 Service Unavailable. */ - (BOOL)isServiceUnavailable; @@ -367,28 +367,28 @@ /** True when the server turned an HTML response. - + @return YES when the MIME type is text/html. */ - (BOOL)isHTML; /** True when the server turned an XHTML response - + @return YES when the MIME type is application/xhtml+xml. */ - (BOOL)isXHTML; /** True when the server turned an XML response - + @return YES when the MIME type is application/xml. */ - (BOOL)isXML; /** True when the server turned an JSON response - + @return YES when the MIME type is application/json. */ - (BOOL)isJSON; diff --git a/Code/Network/RKResponse.m b/Code/Network/RKResponse.m index a17cbb9a..21ac3da4 100644 --- a/Code/Network/RKResponse.m +++ b/Code/Network/RKResponse.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/28/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -104,21 +104,21 @@ return __VA_ARGS__; - (BOOL)isServerTrusted:(SecTrustRef)trust { BOOL proceed = NO; - + if (_request.disableCertificateValidation) { proceed = YES; } else if ([_request.additionalRootCertificates count] > 0 ) { CFArrayRef rootCerts = (CFArrayRef)[_request.additionalRootCertificates allObjects]; SecTrustResultType result; OSStatus returnCode; - + if (rootCerts && CFArrayGetCount(rootCerts)) { // this could fail, but the trust evaluation will proceed (it's likely to fail, of course) SecTrustSetAnchorCertificates(trust, rootCerts); } - + returnCode = SecTrustEvaluate(trust, &result); - + if (returnCode == errSecSuccess) { proceed = (result == kSecTrustResultProceed || result == kSecTrustResultConfirm || result == kSecTrustResultUnspecified); if (result == kSecTrustResultRecoverableTrustFailure) { @@ -127,7 +127,7 @@ return __VA_ARGS__; } } } - + return proceed; } @@ -135,7 +135,7 @@ return __VA_ARGS__; - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { RKResponseIgnoreDelegateIfCancelled(); RKLogDebug(@"Received authentication challenge"); - + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { SecTrustRef trust = [[challenge protectionSpace] serverTrust]; if ([self isServerTrusted:trust]) { @@ -145,7 +145,7 @@ return __VA_ARGS__; } return; } - + if ([challenge previousFailureCount] == 0) { NSURLCredential *newCredential; newCredential=[NSURLCredential credentialWithUser:[NSString stringWithFormat:@"%@", _request.username] @@ -167,17 +167,17 @@ return __VA_ARGS__; // see whether the client settings allow validation here if (_request.disableCertificateValidation || [_request.additionalRootCertificates count] > 0) { return YES; - } else { + } else { return NO; - } + } } - + // Handle non-SSL challenges BOOL hasCredentials = [self hasCredentials]; if (! hasCredentials) { RKLogWarning(@"Received an authentication challenge without any credentials to satisfy the request."); } - + return hasCredentials; } @@ -239,7 +239,7 @@ return __VA_ARGS__; - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite { RKResponseIgnoreDelegateIfCancelled(); [_request invalidateTimeoutTimer]; - + if ([[_request delegate] respondsToSelector:@selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) { [[_request delegate] request:_request didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; } @@ -254,11 +254,11 @@ return __VA_ARGS__; } - (NSString *)bodyEncodingName { - return [_httpURLResponse textEncodingName]; + return [_httpURLResponse textEncodingName]; } - (NSStringEncoding)bodyEncoding { - CFStringEncoding cfEncoding = kCFStringEncodingInvalidId; + CFStringEncoding cfEncoding = kCFStringEncodingInvalidId; NSString *textEncodingName = [self bodyEncodingName]; if (textEncodingName) { cfEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef) textEncodingName); diff --git a/Code/Network/RKURL.h b/Code/Network/RKURL.h index efc531e8..8fca84ac 100644 --- a/Code/Network/RKURL.h +++ b/Code/Network/RKURL.h @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 10/18/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,19 +24,19 @@ framework. RKURL is immutable, but provides numerous methods for constructing new RKURL instances where the received becomes the baseURL of the RKURL instance. - + Instances of RKURL are aware of: - + - the baseURL they were constructed against, if any - the resource path that was appended to that baseURL - any query parameters present in the URL - + ### Example - + NSDictionary *queryParams; queryParams = [NSDictionary dictionaryWithObjectsAndKeys:@"pitbull", @"username", @"pickles", @"password", nil]; - + RKURL *URL = [RKURL URLWithBaseURLString:@"http://restkit.org" resourcePath:@"/test" queryParameters:queryParams]; @@ -49,7 +49,7 @@ /** Creates and returns an RKURL object intialized with a provided base URL. - + @param baseURL The URL object with which to initialize the RKURL object. @return An RKURL object initialized with baseURL. */ @@ -58,7 +58,7 @@ /** Creates and returns an RKURL object intialized with a provided base URL and resource path. - + @param baseURL The URL object with which to initialize the RKURL object. @param resourcePath The resource path for the RKURL object. @return An RKURL object initialized with baseURL and resourcePath. @@ -68,7 +68,7 @@ /** Creates and returns an RKURL object intialized with a provided base URL, resource path, and a dictionary of query parameters. - + @param baseURL The URL object with which to initialize the RKURL object. @param resourcePath The resource path for the RKURL object. @param queryParameters The query parameters for the RKURL object. @@ -80,7 +80,7 @@ /** Creates and returns an RKURL object intialized with a base URL constructed from the specified base URL string. - + @param baseURLString The string with which to initialize the RKURL object. @return An RKURL object initialized with baseURLString. */ @@ -89,7 +89,7 @@ /** Creates and returns an RKURL object intialized with a base URL constructed from the specified base URL string and resource path. - + @param baseURLString The string with which to initialize the RKURL object. @param resourcePath The resource path for the RKURL object. @return An RKURL object initialized with baseURLString and resourcePath. @@ -100,7 +100,7 @@ Creates and returns an RKURL object intialized with a base URL constructed from the specified base URL string, resource path and a dictionary of query parameters. - + @param baseURLString The string with which to initialize the RKURL object. @param resourcePath The resource path for the RKURL object. @param queryParameters The query parameters for the RKURL object. @@ -112,9 +112,9 @@ /** Initializes an RKURL object with a base URL, a resource path string, and a dictionary of query parameters. - + `initWithBaseURL:resourcePath:queryParameters:` is the designated initializer. - + @param theBaseURL The NSURL with which to initialize the RKURL object. @param theResourcePath The resource path for the RKURL object. @param theQueryParameters The query parameters for the RKURL object. @@ -129,7 +129,7 @@ /** Returns the base URL of the receiver. - + The base URL includes everything up to the resource path, typically the portion that is repeated in every API call. */ @@ -137,7 +137,7 @@ /** Returns the resource path of the receiver. - + The resource path is the path portion of the complete URL beyond that contained in the baseURL. */ @@ -145,7 +145,7 @@ /** Returns the query component of a URL conforming to RFC 1808 as a dictionary. - + If the receiver does not conform to RFC 1808, returns nil just as `NSURL query` does. */ @@ -158,7 +158,7 @@ /** Returns a new RKURL object with a new resource path appended to its path. - + @param theResourcePath The resource path to append to the receiver's path. @return A new RKURL that refers to a new resource at theResourcePath. */ @@ -167,7 +167,7 @@ /** Returns a new RKURL object with a new resource path appended to its path and a dictionary of query parameters merged with the existing query component. - + @param theResourcePath The resource path to append to the receiver's path. @param theQueryParameters A dictionary of query parameters to merge with any existing query parameters. @@ -179,7 +179,7 @@ /** Returns a new RKURL object with a dictionary of query parameters merged with the existing query component. - + @param theQueryParameters A dictionary of query parameters to merge with any existing query parameters. @return A new RKURL that refers to the same resource as the receiver with a new @@ -190,7 +190,7 @@ /** Returns a new RKURL object with the baseURL of the receiver and a new resourcePath. - + @param newResourcePath The resource path to replace the value of resourcePath in the new RKURL object. @return An RKURL object with newResourcePath appended to the receiver's baseURL. @@ -200,28 +200,28 @@ /** Returns a new RKURL object with its resource path processed as a pattern and evaluated against the specified object. - + Resource paths may contain pattern strings prefixed by colons (":") that refer to key-value coding accessible properties on the provided object. - + For example: - + // Given an RKURL initialized as: - RKURL *myURL = [RKURL URLWithBaseURLString:@"http://restkit.org" + RKURL *myURL = [RKURL URLWithBaseURLString:@"http://restkit.org" resourcePath:@"/paginate?per_page=:perPage&page=:page"]; - + // And a dictionary containing values: NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"25", @"perPage", @"5", @"page", nil]; - + // A new RKURL can be constructed by interpolating the dictionary with the original URL RKURL *interpolatedURL = [myURL URLByInterpolatingResourcePathWithObject:dictionary]; - + The absoluteString of this new URL would be: `http://restkit.org/paginate?per_page=25&page=5` - + @see RKPathMatcher - + @param object The object to call methods on for the pattern strings in the resource path. @return A new RKURL object with its resource path evaluated as a pattern and diff --git a/Code/Network/RKURL.m b/Code/Network/RKURL.m index db2547ba..13fc59c1 100644 --- a/Code/Network/RKURL.m +++ b/Code/Network/RKURL.m @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 10/18/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,7 +55,7 @@ return [self URLWithBaseURLString:baseURLString resourcePath:resourcePath queryParameters:nil]; } -+ (id)URLWithBaseURLString:(NSString *)baseURLString resourcePath:(NSString *)resourcePath queryParameters:(NSDictionary *)queryParameters { ++ (id)URLWithBaseURLString:(NSString *)baseURLString resourcePath:(NSString *)resourcePath queryParameters:(NSDictionary *)queryParameters { return [self URLWithBaseURL:[NSURL URLWithString:baseURLString] resourcePath:resourcePath queryParameters:queryParameters]; } @@ -67,14 +67,14 @@ NSMutableDictionary *mergedQueryParameters = [NSMutableDictionary dictionaryWithDictionary:[theBaseURL queryParameters]]; [mergedQueryParameters addEntriesFromDictionary:resourcePathQueryParameters]; [mergedQueryParameters addEntriesFromDictionary:theQueryParameters]; - + // Build the new URL path NSRange queryCharacterRange = [theResourcePath rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"?"]]; 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]; - + // 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]; @@ -83,13 +83,13 @@ [self release]; return nil; } - + self = [self initWithString:[completeURL absoluteString]]; if (self) { self.baseURL = theBaseURL; self.resourcePath = theResourcePath; } - + return self; } @@ -98,7 +98,7 @@ baseURL = nil; [resourcePath release]; resourcePath = nil; - + [super dealloc]; } @@ -145,7 +145,7 @@ if (self) { self.baseURL = self; } - + return self; } diff --git a/Code/ObjectMapping/ObjectMapping.h b/Code/ObjectMapping/ObjectMapping.h index b74383eb..293fe2e6 100644 --- a/Code/ObjectMapping/ObjectMapping.h +++ b/Code/ObjectMapping/ObjectMapping.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/30/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKConfigurationDelegate.h b/Code/ObjectMapping/RKConfigurationDelegate.h index 18b920cc..cc70f663 100644 --- a/Code/ObjectMapping/RKConfigurationDelegate.h +++ b/Code/ObjectMapping/RKConfigurationDelegate.h @@ -14,7 +14,7 @@ RKObjectLoader configuration. An object conforming to the protocol can be used to set headers, authentication credentials, etc. - + RKClient and RKObjectManager conform to RKConfigurationDelegate to configure request and object loader instances they build. */ @@ -24,14 +24,14 @@ /** Configure a request before it is utilized - + @param request A request object being configured for dispatch */ - (void)configureRequest:(RKRequest *)request; /** Configure an object loader before it is utilized - + @param request An object loader being configured for dispatch */ - (void)configureObjectLoader:(RKObjectLoader *)objectLoader; diff --git a/Code/ObjectMapping/RKDynamicObjectMapping.h b/Code/ObjectMapping/RKDynamicObjectMapping.h index 23e09f00..c0c70b3c 100644 --- a/Code/ObjectMapping/RKDynamicObjectMapping.h +++ b/Code/ObjectMapping/RKDynamicObjectMapping.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/28/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ typedef RKObjectMapping *(^RKDynamicObjectMappingDelegateBlock)(id); /** A delegate to call back to determine the appropriate concrete object mapping to apply to the mappable data. - + @see RKDynamicObjectMappingDelegate */ @property (nonatomic, assign) id delegate; @@ -82,11 +82,11 @@ typedef RKObjectMapping *(^RKDynamicObjectMappingDelegateBlock)(id); /** Defines a dynamic mapping rule stating that when the value of the key property matches the specified value, the objectMapping should be used. - + For example, suppose that we have a JSON fragment for a person that we want to map differently based on 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]; [mapping setObjectMapping:boyMapping whenValueOfKeyPath:@"gender" isEqualTo:@"male"]; [mapping setObjectMapping:boyMapping whenValueOfKeyPath:@"gender" isEqualTo:@"female"]; @@ -103,7 +103,7 @@ typedef RKObjectMapping *(^RKDynamicObjectMappingDelegateBlock)(id); /** Define an alias for the old class name for compatibility - + @deprecated */ @interface RKObjectDynamicMapping : RKDynamicObjectMapping diff --git a/Code/ObjectMapping/RKDynamicObjectMapping.m b/Code/ObjectMapping/RKDynamicObjectMapping.m index 9f6b2ec4..1ed3d396 100644 --- a/Code/ObjectMapping/RKDynamicObjectMapping.m +++ b/Code/ObjectMapping/RKDynamicObjectMapping.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/28/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,7 +55,7 @@ if (self) { _matchers = [NSMutableArray new]; } - + return self; } @@ -74,9 +74,9 @@ - (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; - + RKLogTrace(@"Performing dynamic object mapping for mappable data: %@", data); - + // Consult the declarative matchers first for (RKDynamicObjectMappingMatcher* matcher in _matchers) { if ([matcher isMatchForData:data]) { @@ -84,7 +84,7 @@ return matcher.objectMapping; } } - + // Otherwise consult the delegates if (self.delegate) { mapping = [self.delegate objectMappingForData:data]; @@ -93,14 +93,14 @@ return mapping; } } - - if (self.objectMappingForDataBlock) { + + if (self.objectMappingForDataBlock) { mapping = self.objectMappingForDataBlock(data); if (mapping) { RKLogTrace(@"Found dynamic delegateBlock match. objectMappingForDataBlock = %@", self.objectMappingForDataBlock); } } - + return mapping; } diff --git a/Code/ObjectMapping/RKErrorMessage.h b/Code/ObjectMapping/RKErrorMessage.h index 3541902c..5a20a993 100644 --- a/Code/ObjectMapping/RKErrorMessage.h +++ b/Code/ObjectMapping/RKErrorMessage.h @@ -4,13 +4,13 @@ // // Created by Jeremy Ellison on 5/10/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKErrorMessage.m b/Code/ObjectMapping/RKErrorMessage.m index f704255d..6df33aba 100644 --- a/Code/ObjectMapping/RKErrorMessage.m +++ b/Code/ObjectMapping/RKErrorMessage.m @@ -4,13 +4,13 @@ // // Created by Jeremy Ellison on 5/10/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKMappingOperationQueue.h b/Code/ObjectMapping/RKMappingOperationQueue.h index cb5a3c22..7d3b5c6a 100644 --- a/Code/ObjectMapping/RKMappingOperationQueue.h +++ b/Code/ObjectMapping/RKMappingOperationQueue.h @@ -13,11 +13,11 @@ operation until the entire aggregate operation has completed. This is used by Core Data to connect all object relationships once the entire object graph has been mapped, rather than as each object is encountered. - + Designed as a lightweight workalike for NSOperationQueue, which was not usable do to its reliance on threading for concurrent operations. The threading was causing problems with managed objects due to MOC being thread specific. - + This class is not intended to be thread-safe and is used for queueing non-concurrent operations that will be executed within the object mapper only. It is not a general purpose work queue. @@ -29,28 +29,28 @@ /** Adds an NSOperation to the queue for later execution - + @param op The operation to enqueue */ - (void)addOperation:(NSOperation *)op; /** Adds an NSBlockOperation to the queue configured to executed the block passed - + @param block A block to wrap into an operation for later execution */ - (void)addOperationWithBlock:(void (^)(void))block; /** Returns the collection of operations in the queue - + @return A new aray containing the NSOperation objects in the order in which they were added to the queue */ - (NSArray *)operations; /** Returns the number of operations in the queue - + @return The number of operations in the queue. */ - (NSUInteger)operationCount; diff --git a/Code/ObjectMapping/RKMappingOperationQueue.m b/Code/ObjectMapping/RKMappingOperationQueue.m index 0beff6d4..7f36a3eb 100644 --- a/Code/ObjectMapping/RKMappingOperationQueue.m +++ b/Code/ObjectMapping/RKMappingOperationQueue.m @@ -15,7 +15,7 @@ if (self) { _operations = [NSMutableArray new]; } - + return self; } diff --git a/Code/ObjectMapping/RKObjectAttributeMapping.h b/Code/ObjectMapping/RKObjectAttributeMapping.h index 49a054ea..93e859ba 100644 --- a/Code/ObjectMapping/RKObjectAttributeMapping.h +++ b/Code/ObjectMapping/RKObjectAttributeMapping.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/30/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,11 +36,11 @@ /** Returns YES if this attribute mapping targets the key of a nested dictionary. - + When an object mapping is configured to target mapping of nested content via [RKObjectMapping mapKeyOfNestedDictionaryToAttribute:], a special attribute mapping is defined that targets the key of the nested dictionary rather than a value within in. This method will return YES if this attribute mapping is configured in such a way. - + @see [RKObjectMapping mapKeyOfNestedDictionaryToAttribute:] @return YES if this attribute mapping targets a nesting key path */ diff --git a/Code/ObjectMapping/RKObjectAttributeMapping.m b/Code/ObjectMapping/RKObjectAttributeMapping.m index 883e82d1..d92dcee9 100644 --- a/Code/ObjectMapping/RKObjectAttributeMapping.m +++ b/Code/ObjectMapping/RKObjectAttributeMapping.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/30/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,7 +38,7 @@ extern NSString* const RKObjectMappingNestingAttributeKeyName; _sourceKeyPath = [sourceKeyPath retain]; _destinationKeyPath = [destinationKeyPath retain]; } - + return self; } @@ -50,7 +50,7 @@ extern NSString* const RKObjectMappingNestingAttributeKeyName; - (void)dealloc { [_sourceKeyPath release]; [_destinationKeyPath release]; - + [super dealloc]; } diff --git a/Code/ObjectMapping/RKObjectLoader.h b/Code/ObjectMapping/RKObjectLoader.h index 75c2e043..842159e8 100644 --- a/Code/ObjectMapping/RKObjectLoader.h +++ b/Code/ObjectMapping/RKObjectLoader.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/8/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,10 +36,10 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** The delegate of an RKObjectLoader object must adopt the RKObjectLoaderDelegate protocol. Optional methods of the protocol allow the delegate to handle asynchronous object mapping operations performed - by the object loader. Also note that the RKObjectLoaderDelegate protocol incorporates the + by the object loader. Also note that the RKObjectLoaderDelegate protocol incorporates the RKRequestDelegate protocol and the delegate may provide implementations of methods from RKRequestDelegate as well. - + @see RKRequestDelegate */ @protocol RKObjectLoaderDelegate @@ -61,7 +61,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction - (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects; /** - When implemented, sent to the delegate when the object loader has completed succesfully. + When implemented, sent to the delegate when the object loader has completed succesfully. If the load resulted in a collection of objects being mapped, only the first object in the collection will be sent with this delegate method. This method simplifies things when you know you are working with a single object reference. @@ -83,7 +83,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** Informs the delegate that the object loader has serialized the source object into a serializable representation for sending to the remote system. The serialization can be modified to allow customization of the request payload independent of mapping. - + @param objectLoader The object loader performing the serialization. @param sourceObject The object that was serialized. @param serialization The serialization of sourceObject to be sent to the remote backend for processing. @@ -92,25 +92,25 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** Sent when an object loader encounters a response status code or MIME Type that RestKit does not know how to handle. - + Response codes in the 2xx, 4xx, and 5xx range are all handled as you would expect. 2xx (successful) response codes are considered a successful content load and object mapping will be attempted. 4xx and 5xx are interpretted as errors and RestKit will attempt to object map an error out of the payload (provided the MIME Type is mappable) and will invoke objectLoader:didFailWithError: after constructing an NSError. Any other status code is considered - unexpected and will cause objectLoaderDidLoadUnexpectedResponse: to be invoked provided that you have provided + unexpected and will cause objectLoaderDidLoadUnexpectedResponse: to be invoked provided that you have provided an implementation in your delegate class. - + RestKit will also invoke objectLoaderDidLoadUnexpectedResponse: in the event that content is loaded, but there is not a parser registered to handle the MIME Type of the payload. This often happens when the remote backend system RestKit is talking to generates an HTML error page on failure. If your remote system returns content in a MIME Type other than application/json or application/xml, you must register the MIME Type and an appropriate parser with the [RKParserRegistry sharedParser] instance. - - Also note that in the event RestKit encounters an unexpected status code or MIME Type response an error will be - constructed and sent to the delegate via objectLoader:didFailsWithError: unless your delegate provides an + + Also note that in the event RestKit encounters an unexpected status code or MIME Type response an error will be + constructed and sent to the delegate via objectLoader:didFailsWithError: unless your delegate provides an implementation of objectLoaderDidLoadUnexpectedResponse:. It is recommended that you provide an implementation and attempt to handle common unexpected MIME types (particularly text/html and text/plain). - + @optional */ - (void)objectLoaderDidLoadUnexpectedResponse:(RKObjectLoader *)objectLoader; @@ -120,7 +120,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction to extract data from the parsed payload that is not object mapped, but is interesting for one reason or another. The mappableData will be made mutable via mutableCopy before the delegate method is invoked. - + Note that the mappable data is a pointer to a pointer to allow you to replace the mappable data with a new object to be mapped. You must dereference it to access the value. */ @@ -132,10 +132,10 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction * Wraps a request/response cycle and loads a remote object representation into local domain objects * * NOTE: When Core Data is linked into the application, the object manager will return instances of - * RKManagedObjectLoader instead of RKObjectLoader. RKManagedObjectLoader is a descendent class that + * RKManagedObjectLoader instead of RKObjectLoader. RKManagedObjectLoader is a descendent class that * includes Core Data specific mapping logic. */ -@interface RKObjectLoader : RKRequest { +@interface RKObjectLoader : RKRequest { RKObjectMappingProvider *_mappingProvider; RKResponse* _response; RKObjectMapping* _objectMapping; @@ -149,14 +149,14 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** The object that acts as the delegate of the receiving object loader. - + @see RKRequestDelegate */ @property (nonatomic, assign) id delegate; /** The block to invoke when the object loader fails due to an error. - + @see [RKObjectLoaderDelegate objectLoader:didFailWithError:] */ @property (nonatomic, copy) RKObjectLoaderDidFailWithErrorBlock onDidFailWithError; @@ -164,7 +164,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve a single object from the mapping result. - + @see [RKObjectLoaderDelegate objectLoader:didLoadObject:] @see RKObjectMappingResult */ @@ -173,7 +173,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve an collections of objects from the mapping result. - + @see [RKObjectLoaderDelegate objectLoader:didLoadObjects:] @see RKObjectMappingResult */ @@ -184,7 +184,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction wishes to retrieve the entire mapping result as a dictionary. Each key within the dictionary will correspond to a mapped keyPath within the source JSON/XML and the value will be the object mapped result. - + @see [RKObjectLoaderDelegate objectLoader:didLoadObjects:] @see RKObjectMappingResult */ @@ -205,7 +205,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** A mapping provider containing object mapping configurations for mapping remote object representations into local domain objects. - + @see RKObjectMappingProvider */ @property (nonatomic, retain) RKObjectMappingProvider *mappingProvider; @@ -245,7 +245,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** The object being serialized for transport. This object will be transformed into a serialization in the serializationMIMEType using the serializationMapping. - + @see RKObjectSerializer */ @property (nonatomic, retain) NSObject *sourceObject; @@ -268,7 +268,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** Initialize and return an autoreleased object loader targeting a remote URL using a mapping provider - + @param URL A RestKit RKURL targetting a particular baseURL and resourcePath @param mappingProvider A mapping provider containing object mapping configurations for processing loaded payloads */ @@ -276,7 +276,7 @@ typedef void(^RKObjectLoaderDidLoadObjectsDictionaryBlock)(NSDictionary *diction /** Initialize and return an autoreleased object loader targeting a remote URL using a mapping provider - + @param URL A RestKit RKURL targetting a particular baseURL and resourcePath @param mappingProvider A mapping provider containing object mapping configurations for processing loaded payloads */ diff --git a/Code/ObjectMapping/RKObjectLoader.m b/Code/ObjectMapping/RKObjectLoader.m index 7474289d..88fe3433 100644 --- a/Code/ObjectMapping/RKObjectLoader.m +++ b/Code/ObjectMapping/RKObjectLoader.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/8/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -70,7 +70,7 @@ _mappingProvider = [mappingProvider retain]; _mappingQueue = [RKObjectManager defaultMappingQueue]; } - + return self; } @@ -90,7 +90,7 @@ [_serializationMIMEType release]; _serializationMIMEType = nil; [_serializationMapping release]; - _serializationMapping = nil; + _serializationMapping = nil; [_onDidFailWithError release]; _onDidFailWithError = nil; [_onDidLoadObject release]; @@ -99,7 +99,7 @@ _onDidLoadObjects = nil; [_onDidLoadObjectsDictionary release]; _onDidLoadObjectsDictionary = nil; - + [super dealloc]; } @@ -113,7 +113,7 @@ - (void)informDelegateOfError:(NSError *)error { [(NSObject*)_delegate objectLoader:self didFailWithError:error]; - + if (self.onDidFailWithError) { self.onDidFailWithError(error); } @@ -126,7 +126,7 @@ - (void)finalizeLoad:(BOOL)successful { self.loading = NO; self.loaded = successful; - + if ([self.delegate respondsToSelector:@selector(objectLoaderDidFinishLoading:)]) { [(NSObject*)self.delegate performSelectorOnMainThread:@selector(objectLoaderDidFinishLoading:) withObject:self waitUntilDone:YES]; @@ -138,36 +138,36 @@ // Invoked on the main thread. Inform the delegate. - (void)informDelegateOfObjectLoadWithResultDictionary:(NSDictionary*)resultDictionary { NSAssert([NSThread isMainThread], @"RKObjectLoaderDelegate callbacks must occur on the main thread"); - + RKObjectMappingResult* result = [RKObjectMappingResult mappingResultWithDictionary:resultDictionary]; - + // Dictionary callback if ([self.delegate respondsToSelector:@selector(objectLoader:didLoadObjectDictionary:)]) { [(NSObject*)self.delegate objectLoader:self didLoadObjectDictionary:[result asDictionary]]; } - + if (self.onDidLoadObjectsDictionary) { self.onDidLoadObjectsDictionary([result asDictionary]); } - + // Collection callback if ([self.delegate respondsToSelector:@selector(objectLoader:didLoadObjects:)]) { [(NSObject*)self.delegate objectLoader:self didLoadObjects:[result asCollection]]; } - + if (self.onDidLoadObjects) { self.onDidLoadObjects([result asCollection]); } - + // Singular object callback if ([self.delegate respondsToSelector:@selector(objectLoader:didLoadObject:)]) { [(NSObject*)self.delegate objectLoader:self didLoadObject:[result asObject]]; } - + if (self.onDidLoadObject) { self.onDidLoadObject([result asObject]); } - + [self finalizeLoad:YES]; } @@ -199,7 +199,7 @@ if (self.targetObject) { return [RKObjectMappingResult mappingResultWithDictionary:[NSDictionary dictionaryWithObject:self.targetObject forKey:@""]]; } - + return [RKObjectMappingResult mappingResultWithDictionary:[NSDictionary dictionary]]; } @@ -239,20 +239,20 @@ if (self.objectMapping) { return self.objectMapping; } - + return [self.mappingProvider objectMappingForResourcePath:self.resourcePath]; } - (RKObjectMappingResult*)performMapping:(NSError**)error { NSAssert(_sentSynchronously || ![NSThread isMainThread], @"Mapping should occur on a background thread"); - + RKObjectMappingProvider* mappingProvider; RKObjectMappingDefinition *configuredObjectMapping = [self configuredObjectMapping]; if (configuredObjectMapping) { mappingProvider = [RKObjectMappingProvider mappingProvider]; NSString *rootKeyPath = configuredObjectMapping.rootKeyPath ? configuredObjectMapping.rootKeyPath : @""; [mappingProvider setMapping:configuredObjectMapping forKeyPath:rootKeyPath]; - + // Copy the error mapping from our configured mappingProvider mappingProvider.errorMapping = self.mappingProvider.errorMapping; } else { @@ -298,7 +298,7 @@ if ([self.response isFailure]) { [self informDelegateOfError:self.response.failureError]; - + [self didFailLoadWithError:self.response.failureError]; return NO; } else if ([self.response isNoContent]) { @@ -368,7 +368,7 @@ [self didFailLoadWithError:error]; return NO; } - + if ([self.delegate respondsToSelector:@selector(objectLoader:didSerializeSourceObject:toSerialization:)]) { [self.delegate objectLoader:self didSerializeSourceObject:self.sourceObject toSerialization:¶ms]; } @@ -398,7 +398,7 @@ if ([_delegate respondsToSelector:@selector(request:didFailLoadWithError:)]) { [_delegate request:self didFailLoadWithError:error]; } - + if (self.onDidFailLoadWithError) { self.onDidFailLoadWithError(error); } @@ -438,7 +438,7 @@ if ([_delegate respondsToSelector:@selector(request:didLoadResponse:)]) { [_delegate request:self didLoadResponse:_response]; } - + if (self.onDidLoadResponse) { self.onDidLoadResponse(_response); } @@ -496,12 +496,12 @@ return [[[self alloc] initWithResourcePath:resourcePath objectManager:objectManager delegate:delegate] autorelease]; } -- (id)initWithResourcePath:(NSString*)resourcePath objectManager:(RKObjectManager*)objectManager delegate:(id)theDelegate { +- (id)initWithResourcePath:(NSString*)resourcePath objectManager:(RKObjectManager*)objectManager delegate:(id)theDelegate { if ((self = [self initWithURL:[objectManager.baseURL URLByAppendingResourcePath:resourcePath] mappingProvider:objectManager.mappingProvider])) { [objectManager.client configureRequest:self]; _delegate = theDelegate; } - + return self; } diff --git a/Code/ObjectMapping/RKObjectLoader_Internals.h b/Code/ObjectMapping/RKObjectLoader_Internals.h index f6593f79..7f745bed 100644 --- a/Code/ObjectMapping/RKObjectLoader_Internals.h +++ b/Code/ObjectMapping/RKObjectLoader_Internals.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/13/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectManager.h b/Code/ObjectMapping/RKObjectManager.h index 5bdcd54c..9f15e901 100644 --- a/Code/ObjectMapping/RKObjectManager.h +++ b/Code/ObjectMapping/RKObjectManager.h @@ -4,13 +4,13 @@ // // Created by Jeremy Ellison on 8/14/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -53,44 +53,44 @@ typedef enum { domain objects via the RKObjectMapper. It is also capable of serializing local objects and sending them to a remote system for processing. The object manager strives to hide the developer from the details of configuring an RKRequest, processing an RKResponse, parsing any data returned by the remote system, and - running the parsed data through the object mapper. - + running the parsed data through the object mapper. +

Shared Manager Instance

- + Multiple instances of RKObjectManager may be used in parallel, but the first instance initialized is automatically configured as the sharedManager instance. The shared instance can be changed at runtime if so desired. See sharedManager and setSharedManager for details. - +

Configuring the Object Manager

- + The object mapper must be configured before object can be loaded from or transmitted to your remote backend system. Configuration consists of specifying the desired MIME types to be used during loads and serialization, registering object mappings to use for mapping and serialization, registering routes, and optionally configuring an instance of the managed object store (for Core Data). - +

MIME Types

- + MIME Types are used for two purposes within RestKit: - + 1. Content Negotiation. RestKit leverages the HTTP Accept header to specify the desired representation of content when contacting a remote web service. You can specify the MIME Type to use via the acceptMIMEType method. The default MIME Type is RKMIMETypeJSON (application/json). If the remote web service responds with content in a different MIME Type than specified, RestKit will attempt to parse it by consulting the [parser registry][RKParserRegistry parserForMIMEType:]. - Failure to find a parser for the returned content will result in an unexpected response invocation of + Failure to find a parser for the returned content will result in an unexpected response invocation of [RKObjectLoaderDelegate objectLoaderDidLoadUnexpectedResponse]. 1. Serialization. RestKit can be used to transport local object representation back to the remote web server for processing by serializing them into an RKRequestSerializable representation. The desired serialization format is configured by setting the serializationMIMEType property. RestKit currently supports serialization to RKMIMETypeFormURLEncoded and RKMIMETypeJSON. The serialization rules themselves are expressed via an instance of RKObjectMapping. - +

The Mapping Provider

- + RestKit determines how to map and serialize objects by consulting the mappingProvider. The mapping provider is responsible for providing instances of RKObjectMapper with object mappings that should be used for transforming mappable data into object representations. When you ask the object manager to load or send objects for you, the mappingProvider instance will be used for the object mapping operations constructed for you. In this way, the mappingProvider is the central registry for the knowledge about how objects in your application are mapped. - + Mappings are registered by constructing instances of RKObjectMapping and registering them with the provider: ` RKObjectManager* manager = [RKObjectManager managerWithBaseURL:myBaseURL]; @@ -98,22 +98,22 @@ typedef enum { [mapping mapAttributes:@"title", @"body", @"publishedAt", nil]; [manager.mappingProvider setObjectMapping:articleMapping forKeyPath:@"article"]; - // Generate an inverse mapping for transforming Article -> NSMutableDictionary. + // Generate an inverse mapping for transforming Article -> NSMutableDictionary. [manager.mappingProvider setSerializationMapping:[articleMapping inverseMapping] forClass:[Article class]];` - +

Configuring Routes

- + Routing is the process of transforming objects and actions (as defined by HTTP verbs) into resource paths. RestKit ships - +

Initializing a Core Data Object Store

Loading Remote Objects

- +

Routing & Object Serialization

- +

Default Error Mapping

- + When an instance of RKObjectManager is configured, the RKObjectMappingProvider - instance configured + instance configured */ @interface RKObjectManager : NSObject @@ -163,7 +163,7 @@ typedef enum { /** Initializes a newly created object manager with a specified baseURL. - + @param baseURL A baseURL to initialize the underlying client instance with @return The newly initialized RKObjectManager object */ @@ -180,7 +180,7 @@ typedef enum { The base URL of the underlying RKClient instance. Object loader and paginator instances built through the object manager are relative to this URL. - + @see RKClient @return The baseURL of the client. */ @@ -255,17 +255,17 @@ typedef enum { Returns the class of object loader instances built through the manager. When Core Data has been configured, instances of RKManagedObjectLoader will be emitted by the manager. Otherwise RKObjectLoader is used. - + @return RKObjectLoader OR RKManagedObjectLoader */ - (Class)objectLoaderClass; /** Creates and returns an RKObjectLoader or RKManagedObjectLoader instance targeting the specified resourcePath. - + The object loader instantiated will be initialized with an RKURL built by appending the resourcePath to the baseURL of the client. The loader will then be configured with object mapping configuration from the manager and request configuration from the client. - + @param resourcePath A resource to use when building the URL to initialize the object loader instance. @return The newly created object loader instance. @see RKURL @@ -275,10 +275,10 @@ typedef enum { /** Creates and returns an RKObjectLoader or RKManagedObjectLoader instance targeting the specified URL. - + The object loader instantiated will be initialized with URL and will then be configured with object mapping configuration from the manager and request configuration from the client. - + @param URL The URL with which to initialize the object loader. @return The newly created object loader instance. @see RKURL @@ -288,13 +288,13 @@ typedef enum { /** Creates and returns an RKObjectLoader or RKManagedObjectLoader instance for an object instance. - + The object loader instantiated will be initialized with a URL built by evaluating the object with the router to construct a resource path and then appending that resource path to the baseURL of the client. - The loader will then be configured with object mapping configuration from the manager and request + The loader will then be configured with object mapping configuration from the manager and request configuration from the client. The specified object will be the target of the object loader and will have any returned content mapped back onto the instance. - + @param object The object with which to initialize the object loader. @return The newly created object loader instance. @see RKObjectLoader @@ -304,10 +304,10 @@ typedef enum { /** Creates and returns an RKObjectPaginator instance targeting the specified resource path pattern. - - The paginator instantiated will be initialized with an RKURL built by appending the resourcePathPattern to the - baseURL of the client. - + + The paginator instantiated will be initialized with an RKURL built by appending the resourcePathPattern to the + baseURL of the client. + @return The newly created paginator instance. @see RKObjectMappingProvider @see RKObjectPaginator @@ -322,7 +322,7 @@ typedef enum { the mapping of complex payloads spanning multiple types (i.e. a search operation returning Articles & Comments in one payload). Ruby on Rails JSON serialization is an example of such a conformant system. */ - + /** Create and send an asynchronous GET request to load the objects at the resource path and call back the delegate with the loaded objects. Remote objects will be mapped to local objects by consulting the keyPath registrations @@ -334,7 +334,7 @@ typedef enum { /// @name Mappable Object Loaders /** - Fetch the data for a mappable object by performing an HTTP GET. + Fetch the data for a mappable object by performing an HTTP GET. */ - (void)getObject:(id)object delegate:(id)delegate; @@ -362,9 +362,9 @@ typedef enum { Load the objects at the specified resource path and perform object mapping on the response payload. Prior to sending the object loader, the block will be invoked to allow you to configure the object loader as you see fit. This can be used to change the response type, set custom parameters, choose an object mapping, etc. - + For example: - + - (void)loadObjectUsingBlockExample { [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/monkeys.json" usingBlock:^(RKObjectLoader* loader) { loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[Monkey class]]; @@ -376,9 +376,9 @@ typedef enum { /* Configure and send an object loader after yielding it to a block for configuration. This allows for very succinct on-the-fly configuration of the request without obtaining an object reference via objectLoaderForObject: and then sending it yourself. - + For example: - + - (BOOL)changePassword:(NSString*)newPassword error:(NSError**)error { if ([self validatePassword:newPassword error:error]) { self.password = newPassword; @@ -399,28 +399,28 @@ typedef enum { /** GET a remote object instance and yield the object loader to the block before sending - + @see sendObject:method:delegate:block */ - (void)getObject:(id)object usingBlock:(RKObjectLoaderBlock)block; /** POST a remote object instance and yield the object loader to the block before sending - + @see sendObject:method:delegate:block */ - (void)postObject:(id)object usingBlock:(RKObjectLoaderBlock)block; /** PUT a remote object instance and yield the object loader to the block before sending - + @see sendObject:method:delegate:block */ - (void)putObject:(id)object usingBlock:(RKObjectLoaderBlock)block; /** DELETE a remote object instance and yield the object loader to the block before sending - + @see sendObject:method:delegate:block */ - (void)deleteObject:(id)object usingBlock:(RKObjectLoaderBlock)block; @@ -440,7 +440,7 @@ typedef enum { /* NOTE: - + The mapResponseWith: family of methods have been deprecated by the support for object mapping selection using resourcePath's */ diff --git a/Code/ObjectMapping/RKObjectManager.m b/Code/ObjectMapping/RKObjectManager.m index 483f72ec..96dc3be0 100644 --- a/Code/ObjectMapping/RKObjectManager.m +++ b/Code/ObjectMapping/RKObjectManager.m @@ -4,13 +4,13 @@ // // Created by Jeremy Ellison on 8/14/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -76,27 +76,27 @@ static dispatch_queue_t defaultMappingQueue = nil; _mappingProvider = [RKObjectMappingProvider new]; _router = [RKObjectRouter new]; _networkStatus = RKObjectManagerNetworkStatusUnknown; - + self.serializationMIMEType = RKMIMETypeFormURLEncoded; self.mappingQueue = [RKObjectManager defaultMappingQueue]; - + // Setup default error message mappings RKObjectMapping *errorMapping = [RKObjectMapping mappingForClass:[RKErrorMessage class]]; errorMapping.rootKeyPath = @"errors"; [errorMapping mapKeyPath:@"" toAttribute:@"errorMessage"]; _mappingProvider.errorMapping = errorMapping; - - [self addObserver:self - forKeyPath:@"client.reachabilityObserver" - options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial + + [self addObserver:self + forKeyPath:@"client.reachabilityObserver" + options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial context:nil]; - + // Set shared manager if nil if (nil == sharedManager) { [RKObjectManager setSharedManager:self]; } } - + return self; } @@ -107,7 +107,7 @@ static dispatch_queue_t defaultMappingQueue = nil; [self.client release]; self.acceptMIMEType = RKMIMETypeJSON; } - + return self; } @@ -126,14 +126,14 @@ static dispatch_queue_t defaultMappingQueue = nil; } + (RKObjectManager *)managerWithBaseURL:(NSURL *)baseURL { - RKObjectManager *manager = [[[self alloc] initWithBaseURL:baseURL] autorelease]; + RKObjectManager *manager = [[[self alloc] initWithBaseURL:baseURL] autorelease]; return manager; } - (void)dealloc { [self removeObserver:self forKeyPath:@"client.reachabilityObserver"]; [[NSNotificationCenter defaultCenter] removeObserver:self]; - + [_router release]; _router = nil; self.client = nil; @@ -143,7 +143,7 @@ static dispatch_queue_t defaultMappingQueue = nil; _serializationMIMEType = nil; [_mappingProvider release]; _mappingProvider = nil; - + [super dealloc]; } @@ -179,10 +179,10 @@ static dispatch_queue_t defaultMappingQueue = nil; RKLogDebug(@"Reachability observer changed for client %@ of object manager %@, starting observing reachability changes", self.client, self); } - + // Initialize current Network Status if ([self.client.reachabilityObserver isReachabilityDetermined]) { - BOOL isNetworkReachable = [self.client.reachabilityObserver isNetworkReachable]; + BOOL isNetworkReachable = [self.client.reachabilityObserver isNetworkReachable]; self.networkStatus = isNetworkReachable ? RKObjectManagerNetworkStatusOnline : RKObjectManagerNetworkStatusOffline; } else { self.networkStatus = RKObjectManagerNetworkStatusUnknown; @@ -217,7 +217,7 @@ static dispatch_queue_t defaultMappingQueue = nil; if (self.objectStore && managedObjectLoaderClass) { return managedObjectLoaderClass; } - + return [RKObjectLoader class]; } @@ -233,7 +233,7 @@ static dispatch_queue_t defaultMappingQueue = nil; [(RKManagedObjectLoader *)loader setObjectStore:self.objectStore]; } [self configureObjectLoader:loader]; - + return loader; } @@ -243,7 +243,7 @@ static dispatch_queue_t defaultMappingQueue = nil; - (RKObjectPaginator *)paginatorWithResourcePathPattern:(NSString *)resourcePathPattern { RKURL *patternURL = [[self baseURL] URLByAppendingResourcePath:resourcePathPattern]; - RKObjectPaginator *paginator = [RKObjectPaginator paginatorWithPatternURL:patternURL + RKObjectPaginator *paginator = [RKObjectPaginator paginatorWithPatternURL:patternURL mappingProvider:self.mappingProvider]; paginator.configurationDelegate = self; return paginator; @@ -256,14 +256,14 @@ static dispatch_queue_t defaultMappingQueue = nil; loader.sourceObject = object; loader.serializationMIMEType = self.serializationMIMEType; loader.serializationMapping = [self.mappingProvider serializationMappingForClass:[object class]]; - + RKObjectMappingDefinition *objectMapping = resourcePath ? [self.mappingProvider objectMappingForResourcePath:resourcePath] : nil; if (objectMapping == nil || ([objectMapping isKindOfClass:[RKObjectMapping class]] && [object isMemberOfClass:[(RKObjectMapping *)objectMapping objectClass]])) { loader.targetObject = object; } else { loader.targetObject = nil; } - + return loader; } @@ -309,10 +309,10 @@ static dispatch_queue_t defaultMappingQueue = nil; - (void)loadObjectsAtResourcePath:(NSString*)resourcePath usingBlock:(void(^)(RKObjectLoader *))block { RKObjectLoader* loader = [self loaderWithResourcePath:resourcePath]; loader.method = RKRequestMethodGET; - + // Yield to the block for setup block(loader); - + [loader send]; } @@ -321,12 +321,12 @@ static dispatch_queue_t defaultMappingQueue = nil; loader.URL = [self.baseURL URLByAppendingResourcePath:resourcePath]; // Yield to the block for setup block(loader); - + [loader send]; } - (void)sendObject:(id)object method:(RKRequestMethod)method usingBlock:(void(^)(RKObjectLoader *))block { - NSString *resourcePath = [self.router resourcePathForObject:object method:method]; + NSString *resourcePath = [self.router resourcePathForObject:object method:method]; [self sendObject:object toResourcePath:resourcePath usingBlock:^(RKObjectLoader *loader) { loader.method = method; block(loader); @@ -425,7 +425,7 @@ static dispatch_queue_t defaultMappingQueue = nil; - (RKObjectLoader *)objectLoaderWithResourcePath:(NSString *)resourcePath delegate:(id)delegate { RKObjectLoader* loader = [self loaderWithResourcePath:resourcePath]; loader.delegate = delegate; - + return loader; } @@ -440,7 +440,7 @@ static dispatch_queue_t defaultMappingQueue = nil; loader.delegate = delegate; loader.method = RKRequestMethodGET; loader.objectMapping = objectMapping; - + [loader send]; } diff --git a/Code/ObjectMapping/RKObjectMapper.h b/Code/ObjectMapping/RKObjectMapper.h index 65ac1a25..d7fc361c 100644 --- a/Code/ObjectMapping/RKObjectMapper.h +++ b/Code/ObjectMapping/RKObjectMapper.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/6/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ @end /** - + */ @interface RKObjectMapper : NSObject { @protected diff --git a/Code/ObjectMapping/RKObjectMapper.m b/Code/ObjectMapping/RKObjectMapper.m index 5daafe41..cc97b1b9 100644 --- a/Code/ObjectMapping/RKObjectMapper.m +++ b/Code/ObjectMapping/RKObjectMapper.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/6/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -131,7 +131,7 @@ objectMapping = (RKObjectMapping *)mapping; } else { NSAssert(objectMapping, @"Encountered unknown mapping type '%@'", NSStringFromClass([mapping class])); - } + } if (NO == [[self.targetObject class] isSubclassOfClass:objectMapping.objectClass]) { NSString *errorMessage = [NSString stringWithFormat: @"Expected an object mapping for class of type '%@', provider returned one for '%@'", @@ -142,7 +142,7 @@ } else { destinationObject = [self objectWithMapping:mapping andData:mappableObject]; } - + if (mapping && destinationObject) { BOOL success = [self mapFromObject:mappableObject toObject:destinationObject atKeyPath:keyPath usingMapping:mapping]; if (success) { @@ -185,13 +185,13 @@ [self addErrorWithCode:RKObjectMapperErrorObjectMappingTypeMismatch message:errorMessage keyPath:keyPath userInfo:nil]; return nil; } - + for (id mappableObject in objectsToMap) { id destinationObject = [self objectWithMapping:mapping andData:mappableObject]; - if (! destinationObject) { + if (! destinationObject) { continue; } - + BOOL success = [self mapFromObject:mappableObject toObject:destinationObject atKeyPath:keyPath usingMapping:mapping]; if (success) { [mappedObjects addObject:destinationObject]; @@ -203,7 +203,7 @@ // The workhorse of this entire process. Emits object loading operations - (BOOL)mapFromObject:(id)mappableObject toObject:(id)destinationObject atKeyPath:(NSString *)keyPath usingMapping:(RKObjectMappingDefinition *)mapping { - NSAssert(destinationObject != nil, @"Cannot map without a target object to assign the results to"); + NSAssert(destinationObject != nil, @"Cannot map without a target object to assign the results to"); NSAssert(mappableObject != nil, @"Cannot map without a collection of attributes"); NSAssert(mapping != nil, @"Cannot map without an mapping"); @@ -211,14 +211,14 @@ if ([self.delegate respondsToSelector:@selector(objectMapper:willMapFromObject:toObject:atKeyPath:usingMapping:)]) { [self.delegate objectMapper:self willMapFromObject:mappableObject toObject:destinationObject atKeyPath:keyPath usingMapping:mapping]; } - + NSError *error = nil; - - RKObjectMappingOperation *operation = [RKObjectMappingOperation mappingOperationFromObject:mappableObject - toObject:destinationObject - withMapping:mapping]; + + RKObjectMappingOperation *operation = [RKObjectMappingOperation mappingOperationFromObject:mappableObject + toObject:destinationObject + withMapping:mapping]; operation.queue = operationQueue; - BOOL success = [operation performMapping:&error]; + BOOL success = [operation performMapping:&error]; if (success) { if ([self.delegate respondsToSelector:@selector(objectMapper:didMapFromObject:toObject:atKeyPath:usingMapping:)]) { [self.delegate objectMapper:self didMapFromObject:mappableObject toObject:destinationObject atKeyPath:keyPath usingMapping:mapping]; @@ -230,7 +230,7 @@ [self addError:error]; } - + return success; } @@ -247,11 +247,11 @@ } else { NSAssert(objectMapping, @"Encountered unknown mapping type '%@'", NSStringFromClass([mapping class])); } - + if (objectMapping) { return [objectMapping mappableObjectForData:mappableData]; } - + return nil; } @@ -300,33 +300,33 @@ if ([self.delegate respondsToSelector:@selector(objectMapper:didFindMappableObject:atKeyPath:withMapping:)]) { [self.delegate objectMapper:self didFindMappableObject:mappableValue atKeyPath:keyPath withMapping:mapping]; } - + mappingResult = [self performMappingForObject:mappableValue atKeyPath:keyPath usingMapping:mapping]; if (mappingResult) { [results setObject:mappingResult forKey:keyPath]; } } - + if (NO == foundMappable) return nil; return results; } -// Primary entry point for the mapper. +// Primary entry point for the mapper. - (RKObjectMappingResult *)performMapping { NSAssert(self.sourceObject != nil, @"Cannot perform object mapping without a source object to map from"); NSAssert(self.mappingProvider != nil, @"Cannot perform object mapping without an object mapping provider"); - + RKLogDebug(@"Performing object mapping sourceObject: %@\n and targetObject: %@", self.sourceObject, self.targetObject); - + if ([self.delegate respondsToSelector:@selector(objectMapperWillBeginMapping:)]) { [self.delegate objectMapperWillBeginMapping:self]; } - + // Perform the mapping BOOL foundMappable = NO; NSMutableDictionary *results = nil; - + // Handle mapping selection for context id mappingsForContext = [self.mappingProvider valueForContext:context]; if ([mappingsForContext isKindOfClass:[NSDictionary class]]) { @@ -339,18 +339,18 @@ mappableData = [self.sourceObject valueForKeyPath:rootKeyPath]; RKLogDebug(@"Selected object mapping has rootKeyPath. Apply valueForKeyPath to mappable data: %@", rootKeyPath); } - + if (mappableData) { id mappingResult = [self performMappingForObject:mappableData atKeyPath:@"" usingMapping:mappingsForContext]; - foundMappable = YES; + foundMappable = YES; results = [NSDictionary dictionaryWithObject:mappingResult forKey:@""]; } } - + // Allow any queued operations to complete RKLogDebug(@"The following operations are in the queue: %@", operationQueue.operations); [operationQueue waitUntilAllOperationsAreFinished]; - + if ([self.delegate respondsToSelector:@selector(objectMapperDidFinishMapping:)]) { [self.delegate objectMapperDidFinishMapping:self]; } diff --git a/Code/ObjectMapping/RKObjectMapperError.h b/Code/ObjectMapping/RKObjectMapperError.h index 86ddb5b9..bfe29eaf 100644 --- a/Code/ObjectMapping/RKObjectMapperError.h +++ b/Code/ObjectMapping/RKObjectMapperError.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/31/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectMapper_Private.h b/Code/ObjectMapping/RKObjectMapper_Private.h index 42681a49..d78f2f86 100644 --- a/Code/ObjectMapping/RKObjectMapper_Private.h +++ b/Code/ObjectMapping/RKObjectMapper_Private.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/9/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectMapping.h b/Code/ObjectMapping/RKObjectMapping.h index 311ca427..7c0f51f5 100644 --- a/Code/ObjectMapping/RKObjectMapping.h +++ b/Code/ObjectMapping/RKObjectMapping.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/30/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -100,8 +100,8 @@ relationship. Relationships are processed using an object mapping as well. @property (nonatomic, assign) BOOL setNilForMissingRelationships; /** - When YES, RestKit will invoke key-value validation at object mapping time. - + When YES, RestKit will invoke key-value validation at object mapping time. + **Default**: YES @see validateValue:forKey:error: */ @@ -125,10 +125,10 @@ relationship. Relationships are processed using an object mapping as well. into NSDate attributes on the target objectClass. Each date formatter will be invoked with the string value being mapped until one of the date formatters does not return nil. - + Defaults to the application-wide collection of date formatters configured via: [RKObjectMapping setDefaultDateFormatters:] - + @see [RKObjectMapping defaultDateFormatters] */ @property (nonatomic, retain) NSArray *dateFormatters; @@ -138,10 +138,10 @@ relationship. Relationships are processed using an object mapping as well. and time configuration. This date formatter will be used when generating string representations of NSDate attributes (i.e. during serialization to URL form encoded or JSON format). - + Defaults to the application-wide preferred date formatter configured via: [RKObjectMapping setPreferredDateFormatter:] - + @see [RKObjectMapping preferredDateFormatter] */ @property (nonatomic, retain) NSFormatter *preferredDateFormatter; @@ -172,10 +172,10 @@ relationship. Relationships are processed using an object mapping as well. Returns an object mapping targeting the specified class. The RKObjectMapping instance will be yieled to the block so that you can perform on the fly configuration without having to obtain a reference variable for the mapping. - - For example, consider we have a one-off request that will load a few attributes for our object. + + 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) { [mapping mapAttributes:@"email", @"first_name", nil]; @@ -188,10 +188,10 @@ relationship. Relationships are processed using an object mapping as well. Returns serialization mapping for encoding a local object to a dictionary for transport. The RKObjectMapping instance will be yieled to the block so that you can perform on the fly configuration without having to obtain a reference variable for the mapping. - + 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 { if ([self validatePassword:newPassword error:error]) { self.password = newPassword; @@ -202,7 +202,7 @@ relationship. Relationships are processed using an object mapping as well. }]; } } - + Using the block forms we are able to quickly configure and send this request on the fly. */ + (id)serializationMappingUsingBlock:(void (^)(RKObjectMapping *serializationMapping))block; @@ -242,7 +242,7 @@ relationship. Relationships are processed using an object mapping as well. /** Returns the attribute or relationship mapping for the given destination keyPath. - + @param destinationKeyPath A keyPath on the destination object that is currently */ - (id)mappingForDestinationKeyPath:(NSString *)destinationKeyPath; @@ -283,15 +283,15 @@ relationship. Relationships are processed using an object mapping as well. /** Defines an attribute mapping for each string attribute in the collection where the source keyPath and the destination attribute property have the same name. - + For example, given the transformation from a JSON dictionary: - + {"name": "My Name", "age": 28} - + To a Person class with corresponding name & age properties, we could configure the attribute mappings via: - + [mapping mapAttributesFromSet:[NSSet setWithObjects:@"name", @"age", nil]]; - + @param set A set of string attribute keyPaths to deifne mappings for */ - (void)mapAttributesFromSet:(NSSet *)set; @@ -299,15 +299,15 @@ relationship. Relationships are processed using an object mapping as well. /** Defines an attribute mapping for each string attribute in the collection where the source keyPath and the destination attribute property have the same name. - + For example, given the transformation from a JSON dictionary: - + {"name": "My Name", "age": 28} - + To a Person class with corresponding name & age properties, we could configure the attribute mappings via: - + [mapping mapAttributesFromSet:[NSArray arrayWithObjects:@"name", @"age", nil]]; - + @param array An array of string attribute keyPaths to deifne mappings for */ - (void)mapAttributesFromArray:(NSArray *)set; @@ -443,7 +443,7 @@ relationship. Relationships are processed using an object mapping as well. /** Returns the attribute mapping targeting the key of a nested dictionary in the source JSON. This attribute mapping corresponds to the attributeName configured via mapKeyOfNestedDictionaryToAttribute: - + @see mapKeyOfNestedDictionaryToAttribute: @returns An attribute mapping for the key of a nested dictionary being mapped or nil */ @@ -498,9 +498,9 @@ relationship. Relationships are processed using an object mapping as well. /** Returns the class of the attribute or relationship property of the target objectClass - + Given the name of a string property, this will return an NSString, etc. - + @param propertyName The name of the property we would like to retrieve the type of */ - (Class)classForProperty:(NSString*)propertyName; @@ -534,12 +534,12 @@ relationship. Relationships are processed using an object mapping as well. /** Returns the collection of default date formatters that will be used for all object mappings that have not been configured specifically. - + Out of the box, RestKit initializes the following default date formatters for you in the UTC time zone: * yyyy-MM-dd'T'HH:mm:ss'Z' * MM/dd/yyyy - + @return An array of NSFormatter objects used when mapping strings into NSDate attributes */ + (NSArray *)defaultDateFormatters; @@ -548,7 +548,7 @@ relationship. Relationships are processed using an object mapping as well. Sets the collection of default date formatters to the specified array. The array should contain configured instances of NSDateFormatter in the order in which you want them applied during object mapping operations. - + @param dateFormatters An array of date formatters to replace the existing defaults @see defaultDateFormatters */ @@ -556,7 +556,7 @@ relationship. Relationships are processed using an object mapping as well. /** Adds a date formatter instance to the default collection - + @param dateFormatter An NSFormatter object to append to the end of the default formatters collection @see defaultDateFormatters */ @@ -565,7 +565,7 @@ relationship. Relationships are processed using an object mapping as well. /** Convenience method for quickly constructing a date formatter and adding it to the collection of default date formatters. The locale is auto-configured to en_US_POSIX - + @param dateFormatString The dateFormat string to assign to the newly constructed NSDateFormatter instance @param nilOrTimeZone The NSTimeZone object to configure on the NSDateFormatter instance. Defaults to UTC time. @result A new NSDateFormatter will be appended to the defaultDateFormatters with the specified date format and time zone @@ -577,9 +577,9 @@ relationship. Relationships are processed using an object mapping as well. Returns the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct. - + Defaults to a date formatter configured for the UTC Time Zone with a format string of "yyyy-MM-dd HH:mm:ss Z" - + @return The preferred NSFormatter object to use when serializing dates into strings */ + (NSFormatter *)preferredDateFormatter; @@ -588,7 +588,7 @@ relationship. Relationships are processed using an object mapping as well. Sets the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct. - + @param dateFormatter The NSFormatter object to designate as the new preferred instance */ + (void)setPreferredDateFormatter:(NSFormatter *)dateFormatter; diff --git a/Code/ObjectMapping/RKObjectMapping.m b/Code/ObjectMapping/RKObjectMapping.m index 1d23f8de..a515f4ba 100644 --- a/Code/ObjectMapping/RKObjectMapping.m +++ b/Code/ObjectMapping/RKObjectMapping.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/30/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -191,7 +191,7 @@ NSString* const RKObjectMappingNestingAttributeKeyName = @" attributes and "rachit" => attributes as independent objects. This can be combined with mapKeyOfNestedDictionaryToAttribute: to properly map these sorts of structures. - + @default NO @see mapKeyOfNestedDictionaryToAttribute */ diff --git a/Code/ObjectMapping/RKObjectMappingOperation.h b/Code/ObjectMapping/RKObjectMappingOperation.h index 75b72854..4535260c 100644 --- a/Code/ObjectMapping/RKObjectMappingOperation.h +++ b/Code/ObjectMapping/RKObjectMappingOperation.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/30/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -117,7 +117,7 @@ /** An operation queue for deferring portions of the mapping process until later - + Defaults to nil. If this mapping operation was configured by an instance of RKObjectMapper, then an instance of the operation queue will be configured and assigned for use. If the queue is nil, the mapping operation will perform all its operations within the body of performMapping. If a queue @@ -128,9 +128,9 @@ /** Creates and returns a new mapping operation configured to transform the object representation in a source object to a new destination object according to an object mapping definition. - + Note that if Core Data support is available, an instance of RKManagedObjectMappingOperation may be returned. - + @param sourceObject The source object to be mapped. Cannot be nil. @param destinationObject The destination object the results are to be mapped onto. May be nil, in which case a new object will be constructed during the mapping. diff --git a/Code/ObjectMapping/RKObjectMappingOperation.m b/Code/ObjectMapping/RKObjectMappingOperation.m index c7248065..b7f4fb3c 100644 --- a/Code/ObjectMapping/RKObjectMappingOperation.m +++ b/Code/ObjectMapping/RKObjectMappingOperation.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/30/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { NSCAssert(sourceValue, @"Expected sourceValue not to be nil"); NSCAssert(destinationValue, @"Expected destinationValue not to be nil"); - + SEL comparisonSelector; if ([sourceValue isKindOfClass:[NSString class]] && [destinationValue isKindOfClass:[NSString class]]) { comparisonSelector = @selector(isEqualToString:); @@ -53,7 +53,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { } else { comparisonSelector = @selector(isEqual:); } - + // Comparison magic using function pointers. See this page for details: http://www.red-sweater.com/blog/320/abusing-objective-c-with-class // Original code courtesy of Greg Parker // This is necessary because isEqualToNumber will return negative integer values that aren't coercable directly to BOOL's without help [sbw] @@ -80,7 +80,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { // Check for availability of ManagedObjectMappingOperation. Better approach for handling? Class targetClass = NSClassFromString(@"RKManagedObjectMappingOperation"); if (targetClass == nil) targetClass = [RKObjectMappingOperation class]; - + return [[[targetClass alloc] initWithSourceObject:sourceObject destinationObject:destinationObject mapping:objectMapping] autorelease]; } @@ -88,12 +88,12 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { NSAssert(sourceObject != nil, @"Cannot perform a mapping operation without a sourceObject object"); NSAssert(destinationObject != nil, @"Cannot perform a mapping operation without a destinationObject"); NSAssert(objectMapping != nil, @"Cannot perform a mapping operation without a mapping"); - + self = [super init]; if (self) { - _sourceObject = [sourceObject retain]; + _sourceObject = [sourceObject retain]; _destinationObject = [destinationObject retain]; - + if ([objectMapping isKindOfClass:[RKDynamicObjectMapping class]]) { _objectMapping = [[(RKDynamicObjectMapping*)objectMapping objectMappingForDictionary:_sourceObject] retain]; RKLogDebug(@"RKObjectMappingOperation was initialized with a dynamic mapping. Determined concrete mapping = %@", _objectMapping); @@ -101,8 +101,8 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { _objectMapping = (RKObjectMapping*)[objectMapping retain]; } NSAssert(_objectMapping, @"Cannot perform a mapping operation with an object mapping"); - } - + } + return self; } @@ -112,7 +112,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { [_objectMapping release]; [_nestedAttributeSubstitution release]; [_queue release]; - + [super dealloc]; } @@ -120,14 +120,14 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { RKLogTrace(@"Transforming string value '%@' to NSDate...", string); NSDate* date = nil; - + NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; NSNumber *numeric = [numberFormatter numberFromString:string]; [numberFormatter release]; - + if (numeric) { date = [NSDate dateWithTimeIntervalSince1970:[numeric doubleValue]]; } else if(![string isEqualToString:@""]) { @@ -140,7 +140,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { NSString *errorDescription = nil; success = [dateFormatter getObjectValue:&date forString:string errorDescription:&errorDescription]; } - + if (success && date) { if ([dateFormatter isKindOfClass:[NSDateFormatter class]]) { RKLogTrace(@"Successfully parsed string '%@' with format string '%@' and time zone '%@' and turned into date '%@'", @@ -151,7 +151,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { } } } - + return date; } @@ -159,7 +159,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { RKLogTrace(@"Found transformable value at keyPath '%@'. Transforming from type '%@' to '%@'", keyPath, NSStringFromClass([value class]), NSStringFromClass(destinationType)); Class sourceType = [value class]; Class orderedSetClass = NSClassFromString(@"NSOrderedSet"); - + if ([sourceType isSubclassOfClass:[NSString class]]) { if ([destinationType isSubclassOfClass:[NSDate class]]) { // String -> Date @@ -241,13 +241,13 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { return nil; } -- (BOOL)isValue:(id)sourceValue equalToValue:(id)destinationValue { +- (BOOL)isValue:(id)sourceValue equalToValue:(id)destinationValue { return RKObjectIsValueEqualToValue(sourceValue, destinationValue); } - (BOOL)validateValue:(id *)value atKeyPath:(NSString*)keyPath { - BOOL success = YES; - + BOOL success = YES; + if (self.objectMapping.performKeyValueValidation && [self.destinationObject respondsToSelector:@selector(validateValue:forKeyPath:error:)]) { success = [self.destinationObject validateValue:value forKeyPath:keyPath error:&_validationError]; if (!success) { @@ -267,19 +267,19 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { if (currentValue == [NSNull null] || [currentValue isEqual:[NSNull null]]) { currentValue = nil; } - + /* WTF - This workaround should not be necessary, but I have been unable to replicate the circumstances that trigger it in a unit test to fix elsewhere. The proper place to handle it is in transformValue:atKeyPath:toType: - + See issue & pull request: https://github.com/RestKit/RestKit/pull/436 */ if (*value == [NSNull null] || [*value isEqual:[NSNull null]]) { RKLogWarning(@"Coercing NSNull value to nil in shouldSetValue:atKeyPath: -- should be fixed."); *value = nil; } - + if (nil == currentValue && nil == *value) { // Both are nil return NO; @@ -337,7 +337,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { // Ensure that the value is different if ([self shouldSetValue:&value atKeyPath:attributeMapping.destinationKeyPath]) { RKLogTrace(@"Mapped attribute value from keyPath '%@' to '%@'. Value: %@", attributeMapping.sourceKeyPath, attributeMapping.destinationKeyPath, value); - + [self.destinationObject setValue:value forKeyPath:attributeMapping.destinationKeyPath]; if ([self.delegate respondsToSelector:@selector(objectMappingOperation:didSetValue:forKeyPath:usingMapping:)]) { [self.delegate objectMappingOperation:self didSetValue:value forKeyPath:attributeMapping.destinationKeyPath usingMapping:attributeMapping]; @@ -354,17 +354,17 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { - (BOOL)applyAttributeMappings { // If we have a nesting substitution value, we have alread BOOL appliedMappings = (_nestedAttributeSubstitution != nil); - + if (!self.objectMapping.performKeyValueValidation) { RKLogDebug(@"Key-value validation is disabled for mapping, skipping..."); } - + for (RKObjectAttributeMapping* attributeMapping in [self attributeMappings]) { if ([attributeMapping isMappingForKeyOfNestedDictionary]) { RKLogTrace(@"Skipping attribute mapping for special keyPath '%@'", attributeMapping.sourceKeyPath); continue; } - + if (self.objectMapping.ignoreUnknownKeyPaths && ![self.sourceObject respondsToSelector:NSSelectorFromString(attributeMapping.sourceKeyPath)]) { RKLogDebug(@"Source object is not key-value coding compliant for the keyPath '%@', skipping...", attributeMapping.sourceKeyPath); continue; @@ -416,7 +416,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { - (BOOL)isTypeACollection:(Class)type { Class orderedSetClass = NSClassFromString(@"NSOrderedSet"); - return (type && ([type isSubclassOfClass:[NSSet class]] || + return (type && ([type isSubclassOfClass:[NSSet class]] || [type isSubclassOfClass:[NSArray class]] || (orderedSetClass && [type isSubclassOfClass:orderedSetClass]))); } @@ -430,7 +430,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { 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; - + RKLogTrace(@"Performing nested object mapping using mapping %@ for data: %@", relationshipMapping, anObject); RKObjectMappingOperation* subOperation = [RKObjectMappingOperation mappingOperationFromObject:anObject toObject:anotherObject withMapping:relationshipMapping.mapping]; subOperation.delegate = self.delegate; @@ -445,7 +445,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { - (BOOL)applyRelationshipMappings { BOOL appliedMappings = NO; id destinationObject = nil; - + for (RKObjectRelationshipMapping* relationshipMapping in [self relationshipMappings]) { id value = nil; @try { @@ -463,7 +463,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { if (value == nil || value == [NSNull null] || [value isEqual:[NSNull null]]) { RKLogDebug(@"Did not find mappable relationship value keyPath '%@'", relationshipMapping.sourceKeyPath); - + // Optionally nil out the property id nilReference = nil; if ([self.objectMapping setNilForMissingRelationships] && [self shouldSetValue:&nilReference atKeyPath:relationshipMapping.destinationKeyPath]) { @@ -473,8 +473,8 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { continue; } - - // Handle case where incoming content is collection represented by a dictionary + + // Handle case where incoming content is collection represented by a dictionary if (relationshipMapping.mapping.forceCollectionMapping) { // If we have forced mapping of a dictionary, map each subdictionary if ([value isKindOfClass:[NSDictionary class]]) { @@ -489,9 +489,9 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { RKLogWarning(@"Collection mapping forced but mappable objects is of type '%@' rather than NSDictionary", NSStringFromClass([value class])); } } - + // Handle case where incoming content is a single object, but we want a collection - Class relationshipType = [self.objectMapping classForProperty:relationshipMapping.destinationKeyPath]; + Class relationshipType = [self.objectMapping classForProperty:relationshipMapping.destinationKeyPath]; BOOL mappingToCollection = [self isTypeACollection:relationshipType]; if (mappingToCollection && ![self isValueACollection:value]) { Class orderedSetClass = NSClassFromString(@"NSOrderedSet"); @@ -506,8 +506,8 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { RKLogWarning(@"Failed to transform single object"); } } - - if ([self isValueACollection:value]) { + + if ([self isValueACollection:value]) { // One to many relationship RKLogDebug(@"Mapping one to many relationship value at keyPath '%@' to '%@'", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath); appliedMappings = YES; @@ -520,7 +520,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { RKLogWarning(@"WARNING: Detected a relationship mapping for a collection containing another collection. This is probably not what you want. Consider using a KVC collection operator (such as @unionOfArrays) to flatten your mappable collection."); RKLogWarning(@"Key path '%@' yielded collection containing another collection rather than a collection of objects: %@", relationshipMapping.sourceKeyPath, value); } - for (id nestedObject in value) { + for (id nestedObject in value) { RKObjectMappingDefinition * mapping = relationshipMapping.mapping; RKObjectMapping* objectMapping = nil; if ([mapping isKindOfClass:[RKDynamicObjectMapping class]]) { @@ -575,8 +575,8 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { } } else { // One to one relationship - RKLogDebug(@"Mapping one to one relationship value at keyPath '%@' to '%@'", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath); - + RKLogDebug(@"Mapping one to one relationship value at keyPath '%@' to '%@'", relationshipMapping.sourceKeyPath, relationshipMapping.destinationKeyPath); + RKObjectMappingDefinition * mapping = relationshipMapping.mapping; RKObjectMapping* objectMapping = nil; if ([mapping isKindOfClass:[RKDynamicObjectMapping class]]) { @@ -601,12 +601,12 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { } } } - + // Notify the delegate if ([self.delegate respondsToSelector:@selector(objectMappingOperation:didSetValue:forKeyPath:usingMapping:)]) { [self.delegate objectMappingOperation:self didSetValue:destinationObject forKeyPath:relationshipMapping.destinationKeyPath usingMapping:relationshipMapping]; } - + // Fail out if a validation error has occurred if (_validationError) { return NO; @@ -634,7 +634,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { - (BOOL)performMapping:(NSError**)error { RKLogDebug(@"Starting mapping operation..."); RKLogTrace(@"Performing mapping operation: %@", self); - + [self applyNestedMappings]; BOOL mappedAttributes = [self applyAttributeMappings]; BOOL mappedRelationships = [self applyRelationshipMappings]; diff --git a/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h b/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h index b5176b90..1a42c74d 100644 --- a/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h +++ b/Code/ObjectMapping/RKObjectMappingProvider+Contexts.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 1/17/12. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectMappingProvider.h b/Code/ObjectMapping/RKObjectMappingProvider.h index 553491f9..7a6cb197 100644 --- a/Code/ObjectMapping/RKObjectMappingProvider.h +++ b/Code/ObjectMapping/RKObjectMappingProvider.h @@ -4,13 +4,13 @@ // // Created by Jeremy Ellison on 5/6/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,17 +37,17 @@ typedef enum { The mapping provider is a repository of registered object mappings for use by instances of RKObjectManager and RKObjectMapper. It provides for the storage and retrieval of object mappings by keyPath and type. - + The mapping provider is responsible for: - - 1. Providing instances of RKObjectMapper with keyPaths and object mappings for use + + 1. Providing instances of RKObjectMapper with keyPaths and object mappings for use when attempting to map a parsed payload into objects. Each keyPath is examined using valueForKeyPath: to determine if any mappable data exists within the payload. If data is found, the RKObjectMapper will instantiate an RKObjectMappingOperation to perform the mapping using the RKObjectMapping or RKDynamicObjectMapping associated with the keyPath. 1. Providing the appropriate serialization mapping to instances of RKObjectManager when an object - is to be sent to the remote server using [RKObjectManager postObject:delegate:] or - [RKObjectManager postObject:delegate]. This mapping is used to serialize the object into a + is to be sent to the remote server using [RKObjectManager postObject:delegate:] or + [RKObjectManager postObject:delegate]. This mapping is used to serialize the object into a format suitable for encoding into a URL form encoded or JSON representation. 1. Providing convenient storage of RKObjectMapping references for users who are not using keyPath based mapping. Mappings can be added to the provider and retrieved by the [RKObjectMapping objectClass] @@ -59,7 +59,7 @@ typedef enum { /** Creates and returns an autoreleased RKObjectMappingProvider instance. - + @return A new autoreleased object mapping provider instance. */ + (id)mappingProvider; @@ -73,11 +73,11 @@ typedef enum { /** Configures the mapping provider to use the RKObjectMapping or RKDynamicObjectMapping provided when content is encountered at the specified keyPath. - + When an RKObjectMapper is performing its work, each registered keyPath within the mapping provider will be searched for content in the parsed payload. If mappable content is found, the object mapping configured for the keyPath will be used to perform an RKObjectMappingOperation. - + @param objectOrDynamicMapping An RKObjectMapping or RKDynamicObjectMapping to register for keyPath based mapping. @param keyPath The keyPath to register the mapping as being responsible for mapping. @see RKObjectMapper @@ -86,9 +86,9 @@ typedef enum { - (void)setObjectMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping forKeyPath:(NSString *)keyPath; /** - Returns the RKObjectMapping or RKObjectDynamic mapping configured for use + Returns the RKObjectMapping or RKObjectDynamic mapping configured for use when mappable content is encountered at keyPath - + @param keyPath A registered keyPath to retrieve the object mapping for @return The RKObjectMapping or RKDynamicObjectMapping for the specified keyPath or nil if none is registered. */ @@ -97,7 +97,7 @@ typedef enum { /** Removes the RKObjectMapping or RKDynamicObjectMapping registered at the specified keyPath from the provider. - + @param keyPath The keyPath to remove the corresponding mapping for */ - (void)removeObjectMappingForKeyPath:(NSString *)keyPath; @@ -105,7 +105,7 @@ typedef enum { /** Returns a dictionary where the keys are mappable keyPaths and the values are the RKObjectMapping or RKDynamicObjectMapping to use for mappable data that appears at the keyPath. - + @warning The returned dictionary can contain RKDynamicObjectMapping instances. Check the type if you are using dynamic mapping. @return A dictionary of all registered keyPaths and their corresponding object mapping instances @@ -114,35 +114,35 @@ typedef enum { /** Registers an object mapping as being rooted at a specific keyPath. The keyPath will be registered - and an inverse mapping for the object will be generated and used for serialization. - + and an inverse mapping for the object will be generated and used for serialization. + This is a shortcut for configuring a pair of object mappings that model a simple resource the same way when going to and from the server. - + For example, if we have a simple resource called 'person' that returns JSON in the following format: - + { "person": { "first_name": "Blake", "last_name": "Watters" } } - + We might configure a mapping like so: - + 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, we can auto-generate the serialization mapping and set the whole thing up in one shot: - + [[RKObjectManager sharedManager].mappingProvider registerMapping:mapping withRootKeyPath:@"person"]; - + This will call setMapping:forKeyPath: for you, then generate a serialization mapping and set the root keyPath as well. - + If you want to manipulate the serialization mapping yourself, you can work with the mapping directly: - + 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]]; - + @param objectMapping An object mapping we wish to register on the provider @param keyPath The keyPath we wish to register for the mapping and use as the rootKeyPath for serialization */ @@ -152,9 +152,9 @@ typedef enum { Adds an object mapping to the provider for later retrieval. The mapping is not bound to a particular keyPath and must be explicitly set on an instance of RKObjectLoader or RKObjectMappingOperation to be applied. This is useful in cases where the remote system does not namespace resources in a keyPath that can be used for disambiguation. - + You can retrieve mappings added to the provider by invoking objectMappingsForClass: and objectMappingForClass: - + @param objectMapping An object mapping instance we wish to register with the provider. @see objectMappingsForClass: @see objectMappingForClass: @@ -164,7 +164,7 @@ typedef enum { /** Returns all object mappings registered for a particular class on the provider. The collection of mappings is assembled by searching for all mappings added via addObjctMapping: and then consulting those registered via objectMappingForKeyPath: - + @param objectClass The class we want to retrieve the mappings for @return An array of all object mappings matching the objectClass. Can be empty. */ @@ -172,16 +172,16 @@ typedef enum { /** Returns the first object mapping for a objectClass registered in the provider. - + The objectClass is the class for a model you use to represent data retrieved in XML or JSON format. For example, if we were developing a Twitter application we might have an objectClass of RKTweet for storing Tweet data. We could retrieve - the object mapping for this model by invoking + the object mapping for this model by invoking `[mappingProvider objectMappingForClass:[RKTweet class]];` - - Mappings registered via addObjectMapping: take precedence over those registered + + Mappings registered via addObjectMapping: take precedence over those registered via setObjectMapping:forKeyPath:. - + @param objectClass The class that we want to return mappings for @return An RKObjectMapping matching objectClass or nil */ @@ -190,11 +190,11 @@ typedef enum { /** Registers an object mapping for use when serializing instances of objectClass for transport over HTTP. Used by the object manager during postObject: and putObject:. - + Serialization mappings are simply instances of RKObjectMapping that target NSMutableDictionary as the target object class. After the object is mapped into an NSMutableDictionary, it can be encoded to form encoded string, JSON, XML, etc. - + @param objectMapping The serialization mapping to register for use when serializing objectClass @param objectClass The class of the object type we are registering a serialization for @see [RKObjectMapping serializationMapping] @@ -203,8 +203,8 @@ typedef enum { /** Returns the serialization mapping for a specific object class - which has been previously registered. - + which has been previously registered. + @param objectClass The class we wish to obtain the serialization mapping for @return The RKObjectMapping instance used for mapping instances of objectClass for transport @see setSerializationMapping:forClass: @@ -214,16 +214,16 @@ typedef enum { /** Configures an object mapping to be used when during a load event where the resourcePath of the RKObjectLoader instance matches resourcePathPattern. - + The resourcePathPattern is a SOCKit pattern matching property names preceded by colons within a path. For example, if a collection of reviews for a product were loaded from a remote system - at the resourcePath @"/products/1234/reviews", object mapping could be configured to handle + at the resourcePath @"/products/1234/reviews", object mapping could be configured to handle this request with a resourcePathPattern of @"/products/:productID/reviews". - + **NOTE** that care must be taken when configuring patterns within the provider. The patterns will be evaluated in the order they are added to the provider, so more specific patterns must precede more general patterns where either would generate a match. - + @param objectMapping The object mapping to use when the resourcePath matches the specified resourcePathPattern. @param resourcePathPattern A pattern to be evaluated using an RKPathMatcher against a resourcePath @@ -237,7 +237,7 @@ typedef enum { /** Returns the first objectMapping configured in the provider with a resourcePathPattern matching the specified resourcePath. - + @param resourcePath A resource path to retrieve the first RKObjectMapping or RKDynamicObjectMapping configured with a matching pattern. @return An RKObjectMapping or RKDynamicObjectMapping for a resource path pattern matching resourcePath @@ -252,7 +252,7 @@ typedef enum { /** An object mapping used when the remote system returns an error status code and a payload with a MIME Type that RestKit is capable of parsing. - + @see RKObjectLoader @see RKParserRegistry */ @@ -262,16 +262,16 @@ typedef enum { An object mapping used when mapping pagination metadata (current page, object count, etc) during a paginated object loading operation. The objectClass of the paginationMapping must be RKObjectPaginator. - + For example, if using the popular will_paginate plugin with Ruby on Rails, we would configure our pagination mapping like so: - + // Assumes the JSON format of http://stackoverflow.com/questions/4699182/will-paginate-json-support RKObjectMapping *paginationMapping = [RKObjectMapping mappingForClass:[RKObjectPaginator class]]; [paginationMapping mapKeyPath:@"current_page" toAttribute:@"currentPage"]; [paginationMapping mapKeyPath:@"per_page" toAttribute:@"perPage"]; [paginationMapping mapKeyPath:@"total_entries" toAttribute:@"objectCount"]; - + @see RKObjectPaginator */ @property (nonatomic, retain) RKObjectMapping *paginationMapping; diff --git a/Code/ObjectMapping/RKObjectMappingProvider.m b/Code/ObjectMapping/RKObjectMappingProvider.m index a4c01d3a..3bf5d4ec 100644 --- a/Code/ObjectMapping/RKObjectMappingProvider.m +++ b/Code/ObjectMapping/RKObjectMappingProvider.m @@ -4,13 +4,13 @@ // // Created by Jeremy Ellison on 5/6/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -189,7 +189,7 @@ id contextValue = [self valueForContext:context]; if (contextValue == nil) return [NSArray array]; [self assertStorageForContext:context isKindOfClass:[NSArray class]]; - + return [NSArray arrayWithArray:contextValue]; } @@ -222,12 +222,12 @@ NSMutableDictionary *contextValue = [self valueForContext:context]; if (contextValue == nil) { contextValue = [NSMutableDictionary dictionary]; - [self setValue:contextValue forContext:context]; + [self setValue:contextValue forContext:context]; } [self assertStorageForContext:context isKindOfClass:[NSDictionary class]]; [contextValue setValue:mapping forKey:keyPath]; } - + - (void)removeMappingForKeyPath:(NSString *)keyPath context:(RKObjectMappingProviderContext)context { NSMutableDictionary *contextValue = [self valueForContext:context]; [self assertStorageForContext:context isKindOfClass:[NSDictionary class]]; @@ -238,7 +238,7 @@ RKOrderedDictionary *contextValue = [self valueForContext:context]; if (contextValue == nil) { contextValue = [RKOrderedDictionary dictionary]; - [self setValue:contextValue forContext:context]; + [self setValue:contextValue forContext:context]; } [self assertStorageForContext:context isKindOfClass:[RKOrderedDictionary class]]; [contextValue insertObject:[RKObjectMappingProviderContextEntry contextEntryWithMapping:mapping] @@ -250,7 +250,7 @@ RKOrderedDictionary *contextValue = [self valueForContext:context]; if (contextValue == nil) { contextValue = [RKOrderedDictionary dictionary]; - [self setValue:contextValue forContext:context]; + [self setValue:contextValue forContext:context]; } [self assertStorageForContext:context isKindOfClass:[RKOrderedDictionary class]]; [contextValue setObject:[RKObjectMappingProviderContextEntry contextEntryWithMapping:mapping] @@ -292,7 +292,7 @@ return [contextValue objectForKey:pattern]; } } - + return nil; } diff --git a/Code/ObjectMapping/RKObjectMappingResult.h b/Code/ObjectMapping/RKObjectMappingResult.h index 4d45228c..07acbbf6 100644 --- a/Code/ObjectMapping/RKObjectMappingResult.h +++ b/Code/ObjectMapping/RKObjectMappingResult.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/7/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectMappingResult.m b/Code/ObjectMapping/RKObjectMappingResult.m index 9b76e824..02061f39 100644 --- a/Code/ObjectMapping/RKObjectMappingResult.m +++ b/Code/ObjectMapping/RKObjectMappingResult.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/7/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ if (self) { _keyPathToMappedObjects = [dictionary retain]; } - + return self; } @@ -51,14 +51,14 @@ NSMutableArray* collection = [NSMutableArray array]; for (id object in [_keyPathToMappedObjects allValues]) { // We don't want to strip the keys off of a mapped dictionary result - + if (NO == [object isKindOfClass:[NSDictionary class]] && [object respondsToSelector:@selector(allObjects)]) { [collection addObjectsFromArray:[object allObjects]]; } else { [collection addObject:object]; } } - + return collection; } @@ -68,7 +68,7 @@ if (count == 0) { return nil; } - + if (count > 1) RKLogWarning(@"Coerced object mapping result containing %lu objects into singular result.", (unsigned long) count); return [collection objectAtIndex:0]; } @@ -83,7 +83,7 @@ } NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:collection, RKObjectMapperErrorObjectsKey, description, NSLocalizedDescriptionKey, nil]; - + NSError* error = [NSError errorWithDomain:RKErrorDomain code:RKObjectMapperErrorFromMappingResult userInfo:userInfo]; return error; } diff --git a/Code/ObjectMapping/RKObjectPaginator.h b/Code/ObjectMapping/RKObjectPaginator.h index 5e6746d6..20c5564e 100644 --- a/Code/ObjectMapping/RKObjectPaginator.h +++ b/Code/ObjectMapping/RKObjectPaginator.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 12/29/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,17 +33,17 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo from remote systems via HTTP. Paginators perform GET requests and use a patterned URL to construct a full URL reflecting the state of the paginator. Paginators rely on an instance of RKObjectMappingProvider to determine how to perform object mapping - on the retrieved data. Paginators can load Core Data backed models provided that an - instance of RKManagedObjectStore is assigned to the paginator. + on the retrieved data. Paginators can load Core Data backed models provided that an + instance of RKManagedObjectStore is assigned to the paginator. */ @interface RKObjectPaginator : NSObject /** Creates and returns a RKObjectPaginator object with the a provided patternURL and mappingProvider. - - @param patternURL A RKURL containing a dynamic pattern for constructing a URL to the paginated + + @param patternURL A RKURL containing a dynamic pattern for constructing a URL to the paginated resource collection. - @param mappingProvider An RKObjectMappingProvider containing object mapping configurations for mapping the + @param mappingProvider An RKObjectMappingProvider containing object mapping configurations for mapping the paginated resource collection. @see patternURL @return A paginator object initialized with patterned URL and mapping provider. @@ -52,10 +52,10 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Initializes a RKObjectPaginator object with the a provided patternURL and mappingProvider. - - @param patternURL A RKURL containing a dynamic pattern for constructing a URL to the paginated + + @param patternURL A RKURL containing a dynamic pattern for constructing a URL to the paginated resource collection. - @param mappingProvider An RKObjectMappingProvider containing object mapping configurations for mapping the + @param mappingProvider An RKObjectMappingProvider containing object mapping configurations for mapping the paginated resource collection. @see patternURL @return The receiver, initialized with patterned URL and mapping provider. @@ -66,26 +66,26 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo A RKURL with a resource path pattern for building a complete URL from which to load the paginated resource collection. The patterned resource path will be evaluated against the state of the paginator object itself. - + For example, given a paginated collection of data at the /articles resource path, the patterned resource path may look like: - + /articles?per_page=:perPage&page_number=:currentPage - + When the pattern is evaluated against the state of the paginator, this will yield a complete resource path that can be used to load the specified page. Given a paginator configured with 100 objects per page and a current page number of 3, the resource path of the pagination URL would become: - + /articles?per_page=100&page_number=3 - + @see [RKURL URLByInterpolatingResourcePathWithObject:] */ @property (nonatomic, copy) RKURL *patternURL; /** Returns a complete RKURL to the paginated resource collection by interpolating - the state of the paginator object against the resource + the state of the paginator object against the resource */ @property (nonatomic, readonly) RKURL *URL; @@ -96,22 +96,22 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** The block to invoke when the paginator has loaded a page of objects from the collection. - + @see [RKObjectPaginatorDelegate paginator:didLoadObjects:forPage] */ @property (nonatomic, copy) RKObjectPaginatorDidLoadObjectsForPageBlock onDidLoadObjectsForPage; /** The block to invoke when the paginator has failed loading due to an error. - + @see [RKObjectPaginatorDelegate paginator:didFailWithError:objectLoader:] */ @property (nonatomic, copy) RKObjectPaginatorDidFailWithErrorBlock onDidFailWithError; /** - The object that acts as the configuration delegate for RKObjectLoader instances built + The object that acts as the configuration delegate for RKObjectLoader instances built and utilized by the paginator. - + **Default**: nil @see RKClient @see RKObjectManager @@ -142,14 +142,14 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** A Boolean value indicating if the paginator has loaded a page of objects - + @returns YES when the paginator has loaded a page of objects */ @property (nonatomic, readonly, getter = isLoaded) BOOL loaded; /** Returns the page number for the most recently loaded page of objects. - + @return The page number for the current page of objects. @exception NSInternalInconsistencyException Raised if isLoaded is NO. */ @@ -157,7 +157,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Returns the number of pages in the total resource collection. - + @return A count of the number of pages in the resource collection. @exception NSInternalInconsistencyException Raised if hasPageCount is NO. */ @@ -165,7 +165,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Returns the total number of objects in the collection - + @return A count of the number of objects in the resource collection. @exception NSInternalInconsistencyException Raised if hasObjectCount is NO. */ @@ -174,7 +174,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Returns a Boolean value indicating if the total number of pages in the collection is known by the paginator. - + @return YES if the paginator knows the page count, otherwise NO */ - (BOOL)hasPageCount; @@ -182,14 +182,14 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Returns a Boolean value indicating if the total number of objects in the collection is known by the paginator. - + @return YES if the paginator knows the number of objects in the paginated collection, otherwise NO. */ - (BOOL)hasObjectCount; /** Returns a Boolean value indicating if there is a next page in the collection. - + @return YES if there is a next page, otherwise NO. @exception NSInternalInconsistencyException Raised if isLoaded or hasPageCount is NO. */ @@ -197,7 +197,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Returns a Boolean value indicating if there is a previous page in the collection. - + @return YES if there is a previous page, otherwise NO. @exception NSInternalInconsistencyException Raised if isLoaded is NO. */ @@ -220,7 +220,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Loads a specific page of data by mutating the current page, constructing an object loader to fetch the data, and object mapping the results. - + @param pageNumber The page of objects to load from the remote backend */ - (void)loadPage:(NSUInteger)pageNumber; @@ -237,7 +237,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Tells the delegate the paginator has loaded a page of objects from the collection. - + @param paginator The paginator that loaded the objects. @param objects An array of objects mapped from the remote JSON/XML representation. @param page The page number that was loaded. @@ -246,7 +246,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Tells the delegate the paginator has failed loading due to an error. - + @param paginator The paginator that failed loading due to an error. @param error An NSError indicating the cause of the failure. @param loader The loader request that resulted in the failure. @@ -257,7 +257,7 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Tells the delegate that the paginator is about to begin loading a page of objects. - + @param paginator The paginator performing the load. @param page The numeric page number being loaded. @param loader The object loader request used to load the page. @@ -266,14 +266,14 @@ typedef void(^RKObjectPaginatorDidFailWithErrorBlock)(NSError *error, RKObjectLo /** Tells the delegate the paginator has loaded the first page of objects in the collection. - + @param paginator The paginator instance that has loaded the first page. */ - (void)paginatorDidLoadFirstPage:(RKObjectPaginator *)paginator; /** Tells the delegate the paginator has loaded the last page of objects in the collection. - + @param paginator The paginator instance that has loaded the last page. */ - (void)paginatorDidLoadLastPage:(RKObjectPaginator *)paginator; diff --git a/Code/ObjectMapping/RKObjectPaginator.m b/Code/ObjectMapping/RKObjectPaginator.m index 1dcc9ed7..71e10b19 100644 --- a/Code/ObjectMapping/RKObjectPaginator.m +++ b/Code/ObjectMapping/RKObjectPaginator.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 12/29/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -62,14 +62,14 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; perPage = RKObjectPaginatorDefaultPerPage; loaded = NO; } - + return self; } - (void)dealloc { delegate = nil; configurationDelegate = nil; - objectLoader.delegate = nil; + objectLoader.delegate = nil; [patternURL release]; patternURL = nil; [mappingProvider release]; @@ -83,8 +83,8 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; [onDidLoadObjectsForPage release]; onDidLoadObjectsForPage = nil; [onDidFailWithError release]; - onDidFailWithError = nil; - + onDidFailWithError = nil; + [super dealloc]; } @@ -123,7 +123,7 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; - (BOOL)hasNextPage { NSAssert(self.isLoaded, @"Cannot determine hasNextPage: paginator is not loaded."); NSAssert([self hasPageCount], @"Cannot determine hasNextPage: page count is not known."); - + return self.currentPage < self.pageCount; } @@ -139,17 +139,17 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; loaded = YES; RKLogInfo(@"Loaded objects: %@", objects); [self.delegate paginator:self didLoadObjects:objects forPage:self.currentPage]; - + if (self.onDidLoadObjectsForPage) { self.onDidLoadObjectsForPage(objects, self.currentPage); } - + if ([self hasPageCount] && self.currentPage == 1) { if ([self.delegate respondsToSelector:@selector(paginatorDidLoadFirstPage:)]) { [self.delegate paginatorDidLoadFirstPage:self]; } } - + if ([self hasPageCount] && self.currentPage == self.pageCount) { if ([self.delegate respondsToSelector:@selector(paginatorDidLoadLastPage:)]) { [self.delegate paginatorDidLoadLastPage:self]; @@ -176,7 +176,7 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; } else if (self.perPage && [self hasObjectCount]) { float objectCountFloat = self.objectCount; pageCount = ceilf(objectCountFloat / self.perPage); - RKLogInfo(@"Paginator objectCount: %ld pageCount: %ld", (long) self.objectCount, (long) self.pageCount); + RKLogInfo(@"Paginator objectCount: %ld pageCount: %ld", (long) self.objectCount, (long) self.pageCount); } else { NSAssert(NO, @"Paginator perPage set is 0."); RKLogError(@"Paginator perPage set is 0."); @@ -197,23 +197,23 @@ static NSUInteger RKObjectPaginatorDefaultPerPage = 25; NSAssert(self.mappingProvider, @"Cannot perform a load with a nil mappingProvider."); NSAssert(! objectLoader, @"Cannot perform a load while one is already in progress."); currentPage = pageNumber; - + if (self.objectStore) { self.objectLoader = [[[RKManagedObjectLoader alloc] initWithURL:self.URL mappingProvider:self.mappingProvider objectStore:self.objectStore] autorelease]; } else { self.objectLoader = [[[RKObjectLoader alloc] initWithURL:self.URL mappingProvider:self.mappingProvider] autorelease]; } - + if ([self.configurationDelegate respondsToSelector:@selector(configureObjectLoader:)]) { [self.configurationDelegate configureObjectLoader:objectLoader]; } self.objectLoader.method = RKRequestMethodGET; self.objectLoader.delegate = self; - + if ([self.delegate respondsToSelector:@selector(paginator:willLoadPage:objectLoader:)]) { [self.delegate paginator:self willLoadPage:pageNumber objectLoader:self.objectLoader]; } - + [self.objectLoader send]; } diff --git a/Code/ObjectMapping/RKObjectPropertyInspector.h b/Code/ObjectMapping/RKObjectPropertyInspector.h index 004719ef..89964d13 100644 --- a/Code/ObjectMapping/RKObjectPropertyInspector.h +++ b/Code/ObjectMapping/RKObjectPropertyInspector.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 3/4/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectPropertyInspector.m b/Code/ObjectMapping/RKObjectPropertyInspector.m index 54ca2167..e3d2c2cb 100644 --- a/Code/ObjectMapping/RKObjectPropertyInspector.m +++ b/Code/ObjectMapping/RKObjectPropertyInspector.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 3/4/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ static RKObjectPropertyInspector* sharedInspector = nil; if (sharedInspector == nil) { sharedInspector = [RKObjectPropertyInspector new]; } - + return sharedInspector; } @@ -42,7 +42,7 @@ static RKObjectPropertyInspector* sharedInspector = nil; if ((self = [super init])) { _cachedPropertyNamesAndTypes = [[NSMutableDictionary alloc] init]; } - + return self; } @@ -55,7 +55,7 @@ static RKObjectPropertyInspector* sharedInspector = nil; NSString *type = [NSString string]; NSScanner *typeScanner = [NSScanner scannerWithString:attributeString]; [typeScanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"@"] intoString:NULL]; - + // we are not dealing with an object if([typeScanner isAtEnd]) { return @"NULL"; @@ -72,14 +72,14 @@ static RKObjectPropertyInspector* sharedInspector = nil; return propertyNames; } propertyNames = [NSMutableDictionary dictionary]; - + //include superclass properties Class currentClass = theClass; while (currentClass != nil) { // Get the raw list of properties unsigned int outCount; objc_property_t *propList = class_copyPropertyList(currentClass, &outCount); - + // Collect the property names int i; NSString *propName; @@ -87,9 +87,9 @@ static RKObjectPropertyInspector* sharedInspector = nil; // 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]; + 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]; Class aClass = objc_getClass(className); @@ -98,11 +98,11 @@ static RKObjectPropertyInspector* sharedInspector = nil; } } } - + free(propList); currentClass = [currentClass superclass]; } - + [_cachedPropertyNamesAndTypes setObject:propertyNames forKey:theClass]; RKLogDebug(@"Cached property names and types for Class '%@': %@", NSStringFromClass(theClass), propertyNames); return propertyNames; diff --git a/Code/ObjectMapping/RKObjectRelationshipMapping.h b/Code/ObjectMapping/RKObjectRelationshipMapping.h index 657da885..e2b4c26a 100644 --- a/Code/ObjectMapping/RKObjectRelationshipMapping.h +++ b/Code/ObjectMapping/RKObjectRelationshipMapping.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/4/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectRelationshipMapping.m b/Code/ObjectMapping/RKObjectRelationshipMapping.m index b88f6f32..555ea7eb 100644 --- a/Code/ObjectMapping/RKObjectRelationshipMapping.m +++ b/Code/ObjectMapping/RKObjectRelationshipMapping.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/4/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ @synthesize reversible = _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; diff --git a/Code/ObjectMapping/RKObjectRouter.h b/Code/ObjectMapping/RKObjectRouter.h index 61b1ada7..cbf39d32 100644 --- a/Code/ObjectMapping/RKObjectRouter.h +++ b/Code/ObjectMapping/RKObjectRouter.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 10/18/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,11 +38,11 @@ * 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 - * rather it is part of the "json" static string. In these instances, you need to escape the + * 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 + * rather it is part of the "json" static string. In these instances, you need to escape the * dot with two backslashes, like so: /:filename\\.json * @see RKPathMatcher */ @@ -55,10 +55,10 @@ - (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, + * Register a mapping from an object class to a resource path for a specific HTTP method, * optionally adding url escapes to the path. This urlEscape flag comes in handy when you want to provide * your own fully escaped dynamic resource path via a method/attribute on the object model. - * For example, if your Person model has a string attribute titled "polymorphicResourcePath" that returns + * For example, if your Person model has a string attribute titled "polymorphicResourcePath" that returns * @"/this/is/the/path", you should configure the route with url escapes 'off', otherwise the router will return * @"%2Fthis%2Fis%2Fthe%2Fpath". * @see RKPathMatcher diff --git a/Code/ObjectMapping/RKObjectRouter.m b/Code/ObjectMapping/RKObjectRouter.m index 61f2f4c0..3a5dd486 100644 --- a/Code/ObjectMapping/RKObjectRouter.m +++ b/Code/ObjectMapping/RKObjectRouter.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 10/18/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,7 @@ } NSMutableDictionary *routeEntry = [NSMutableDictionary dictionaryWithObjectsAndKeys: - resourcePathPattern, @"resourcePath", + resourcePathPattern, @"resourcePath", [NSNumber numberWithBool:addEscapes], @"addEscapes", nil]; [classRoutes setValue:routeEntry forKey:methodName]; } @@ -124,11 +124,11 @@ RKPathMatcher *matcher = [RKPathMatcher matcherWithPattern:[routeEntry objectForKey:@"resourcePath"]]; NSString *interpolatedPath = [matcher pathFromObject:object addingEscapes:addEscapes]; - return interpolatedPath; + return interpolatedPath; } [NSException raise:@"Unable to find a routable path for object" format:@"Unable to find a routable path for object of type '%@' for HTTP Method '%@'", className, methodName]; - + return nil; } diff --git a/Code/ObjectMapping/RKObjectSerializer.h b/Code/ObjectMapping/RKObjectSerializer.h index 1217372f..87758e67 100644 --- a/Code/ObjectMapping/RKObjectSerializer.h +++ b/Code/ObjectMapping/RKObjectSerializer.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/2/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/ObjectMapping/RKObjectSerializer.m b/Code/ObjectMapping/RKObjectSerializer.m index 4dbdd615..aecdcf89 100644 --- a/Code/ObjectMapping/RKObjectSerializer.m +++ b/Code/ObjectMapping/RKObjectSerializer.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/2/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ - (void)dealloc { [_object release]; [_mapping release]; - + [super dealloc]; } @@ -64,13 +64,13 @@ if (!success) { return nil; } - + // Optionally enclose the serialized object within a container... if (_mapping.rootKeyPath) { // TODO: Should log this... dictionary = [NSMutableDictionary dictionaryWithObject:dictionary forKey:_mapping.rootKeyPath]; } - + return dictionary; } @@ -83,10 +83,10 @@ if (string == nil) { return nil; } - + return string; } - + return nil; } @@ -101,7 +101,7 @@ return [RKRequestSerialization serializationWithData:data MIMEType:MIMEType]; } } - + return nil; } @@ -110,7 +110,7 @@ - (void)objectMappingOperation:(RKObjectMappingOperation *)operation didSetValue:(id)value forKeyPath:(NSString *)keyPath usingMapping:(RKObjectAttributeMapping *)mapping { id transformedValue = nil; Class orderedSetClass = NSClassFromString(@"NSOrderedSet"); - + if ([value isKindOfClass:[NSDate class]]) { // Date's are not natively serializable, must be encoded as a string @synchronized(self.mapping.preferredDateFormatter) { @@ -118,12 +118,12 @@ } } 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]; } - + if (transformedValue) { RKLogDebug(@"Serialized %@ value at keyPath to %@ (%@)", NSStringFromClass([value class]), NSStringFromClass([transformedValue class]), value); [operation.destinationObject setValue:transformedValue forKey:keyPath]; diff --git a/Code/ObjectMapping/RKParserRegistry.h b/Code/ObjectMapping/RKParserRegistry.h index 6a8e257c..b7cbc124 100644 --- a/Code/ObjectMapping/RKParserRegistry.h +++ b/Code/ObjectMapping/RKParserRegistry.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/18/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,37 +34,37 @@ /** Return the global shared singleton registry for MIME Type to Parsers - + @return The global shared RKParserRegistry instance. */ + (RKParserRegistry *)sharedRegistry; /** Sets the global shared registry singleton to a new instance of RKParserRegistry - + @param registry A new parser registry object to configure as the shared instance. */ + (void)setSharedRegistry:(RKParserRegistry *)registry; /** - Returns an instance of the RKParser conformant class registered to handle content + Returns an instance of the RKParser conformant class registered to handle content with the given MIME Type. - + MIME Types are searched in the order in which they are registered and exact string matches are favored over regular expressions. - + @param MIMEType The MIME Type of the content to be parsed/serialized. @return An instance of the RKParser conformant class registered to handle the given MIME Type. */ - (id)parserForMIMEType:(NSString *)MIMEType; /** - Returns an instance of the RKParser conformant class registered to handle content - with the given MIME Type. - + Returns an instance of the RKParser conformant class registered to handle content + with the given MIME Type. + MIME Types are searched in the order in which they are registered and exact string matches are favored over regular expressions. - + @param MIMEType The MIME Type of the content to be parsed/serialized. @return The RKParser conformant class registered to handle the given MIME Type. */ @@ -73,7 +73,7 @@ /** Registers an RKParser conformant class as the handler for MIME Types exactly matching the specified MIME Type string. - + @param parserClass The RKParser conformant class to instantiate when parsing/serializing MIME Types matching MIMETypeExpression. @param MIMEType A MIME Type string for which instances of parserClass should be used for parsing/serialization. */ @@ -84,7 +84,7 @@ /** Registers an RKParser conformant class as the handler for MIME Types matching the specified regular expression. - + @param parserClass The RKParser conformant class to instantiate when parsing/serializing MIME Types matching MIMETypeExpression. @param MIMETypeRegex A regular expression that matches MIME Types that should be handled by instances of parserClass. */ diff --git a/Code/ObjectMapping/RKParserRegistry.m b/Code/ObjectMapping/RKParserRegistry.m index fa976180..70d8ecf3 100644 --- a/Code/ObjectMapping/RKParserRegistry.m +++ b/Code/ObjectMapping/RKParserRegistry.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/18/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ RKParserRegistry *gSharedRegistry; gSharedRegistry = [RKParserRegistry new]; [gSharedRegistry autoconfigure]; } - + return gSharedRegistry; } @@ -45,7 +45,7 @@ RKParserRegistry *gSharedRegistry; _MIMETypeToParserClasses = [[NSMutableDictionary alloc] init]; _MIMETypeToParserClassesRegularExpressions = [[NSMutableArray alloc] init]; } - + return self; } @@ -91,15 +91,15 @@ RKParserRegistry *gSharedRegistry; if (parserClass) { return [[[parserClass alloc] init] autorelease]; } - + return nil; } - (void)autoconfigure { Class parserClass = nil; - + // JSON - NSSet *JSONParserClassNames = [NSSet setWithObjects:@"RKJSONParserJSONKit", @"RKJSONParserYAJL", @"RKJSONParserSBJSON", @"RKJSONParserNXJSON", nil]; + NSSet *JSONParserClassNames = [NSSet setWithObjects:@"RKJSONParserJSONKit", @"RKJSONParserYAJL", @"RKJSONParserSBJSON", @"RKJSONParserNXJSON", nil]; for (NSString *parserClassName in JSONParserClassNames) { parserClass = NSClassFromString(parserClassName); if (parserClass) { @@ -107,7 +107,7 @@ RKParserRegistry *gSharedRegistry; break; } } - + // XML parserClass = NSClassFromString(@"RKXMLParserXMLReader"); if (parserClass) { diff --git a/Code/ObjectMapping/RKRouter.h b/Code/ObjectMapping/RKRouter.h index a058bd1b..6d6c0638 100644 --- a/Code/ObjectMapping/RKRouter.h +++ b/Code/ObjectMapping/RKRouter.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/20/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/RestKit.h b/Code/RestKit.h index e3541a5e..b779fa24 100644 --- a/Code/RestKit.h +++ b/Code/RestKit.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 2/19/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ /** Set the App logging component. This header file is generally only imported by apps that - are pulling in all of RestKit. By setting the + are pulling in all of RestKit. By setting the log component to App here, we allow the app developer to use RKLog() in their own app. */ diff --git a/Code/Support/NSArray+RKAdditions.h b/Code/Support/NSArray+RKAdditions.h index 18493721..466429df 100644 --- a/Code/Support/NSArray+RKAdditions.h +++ b/Code/Support/NSArray+RKAdditions.h @@ -17,7 +17,7 @@ Evaluates a given key path against the receiving array, divides the array entries into sections grouped by the value for the key path, and returns an aggregate array of arrays containing the sections. The receiving array is assumed to be sorted. - + @param keyPath The key path of the value to group the entries by. @returns An array of section arrays, with each section containing a group of objects sharing the same value for the given key path. diff --git a/Code/Support/NSArray+RKAdditions.m b/Code/Support/NSArray+RKAdditions.m index 110bf8ef..bb58701d 100644 --- a/Code/Support/NSArray+RKAdditions.m +++ b/Code/Support/NSArray+RKAdditions.m @@ -23,7 +23,7 @@ // Create the first section and establish the first section's grouping value. NSMutableArray *sectionItems = [NSMutableArray array]; id currentGroup = [[self objectAtIndex:0] valueForKeyPath:keyPath]; - + // Iterate over our items, placing them in the appropriate section and // creating new sections when necessary. for (id item in self) { @@ -50,7 +50,7 @@ if ([sectionItems count] > 0) { [sections addObject:sectionItems]; } - + return sections; } diff --git a/Code/Support/NSDictionary+RKAdditions.h b/Code/Support/NSDictionary+RKAdditions.h index b1131747..44fe6653 100644 --- a/Code/Support/NSDictionary+RKAdditions.h +++ b/Code/Support/NSDictionary+RKAdditions.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/5/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,9 +32,9 @@ + (id)dictionaryWithKeysAndObjects:(id)firstKey, ... NS_REQUIRES_NIL_TERMINATION; /** - Return a new dictionary by stripping out any percent escapes (such as %20) + Return a new dictionary by stripping out any percent escapes (such as %20) from the receiving dictionary's key and values. - + @return A new dictionary wherein any percent escape sequences in the key and values have been replaced with their literal values. */ @@ -42,14 +42,14 @@ /** Returns a dictionary by digesting a URL encoded set of key/value pairs into unencoded - values. Keys that appear multiple times with the string are decoded into an array of + values. Keys that appear multiple times with the string are decoded into an array of values. */ + (NSDictionary *)dictionaryWithURLEncodedString:(NSString *)URLEncodedString; /** Returns a representation of the dictionary as a URLEncoded string - + @returns A UTF-8 encoded string representation of the keys/values in the dictionary */ - (NSString *)stringWithURLEncodedEntries; diff --git a/Code/Support/NSDictionary+RKAdditions.m b/Code/Support/NSDictionary+RKAdditions.m index 53cba90b..0aac48af 100644 --- a/Code/Support/NSDictionary+RKAdditions.m +++ b/Code/Support/NSDictionary+RKAdditions.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/5/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,10 +34,10 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions) for (id key = firstKey; key != nil; key = va_arg(args, id)) { id value = va_arg(args, id); [keys addObject:key]; - [values addObject:value]; + [values addObject:value]; } va_end(args); - + return [self dictionaryWithObjects:values forKeys:keys]; } @@ -62,7 +62,7 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions) if ([keyValuePairArray count] < 2) continue; // Verify that there is at least one key, and at least one value. Ignore extra = signs NSString *key = [[keyValuePairArray objectAtIndex:0] stringByReplacingURLEncoding]; NSString *value = [[keyValuePairArray objectAtIndex:1] stringByReplacingURLEncoding]; - + // URL spec says that multiple values are allowed per key id results = [queryComponents objectForKey:key]; if(results) { @@ -72,7 +72,7 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions) // On second occurrence of the key, convert into an array NSMutableArray *values = [NSMutableArray arrayWithObjects:results, value, nil]; [queryComponents setObject:values forKey:key]; - } + } } else { [queryComponents setObject:value forKey:key]; } @@ -90,7 +90,7 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions) [self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) { NSString *encodedKey = [[key description] stringByAddingURLEncoding]; NSString *path = inPath ? [inPath stringByAppendingFormat:@"[%@]", encodedKey] : encodedKey; - + if ([value isKindOfClass:[NSArray class]]) { for (id item in value) { if ([item isKindOfClass:[NSDictionary class]] || [item isKindOfClass:[NSMutableDictionary class]]) { @@ -98,7 +98,7 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions) } else { [self URLEncodePart:parts path:[path stringByAppendingString:@"[]"] value:item]; } - + } } else if([value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSMutableDictionary class]]) { [value URLEncodeParts:parts path:path]; diff --git a/Code/Support/NSString+RKAdditions.h b/Code/Support/NSString+RKAdditions.h index cb122555..b5a21bbc 100644 --- a/Code/Support/NSString+RKAdditions.h +++ b/Code/Support/NSString+RKAdditions.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 6/15/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ This is a convenience method for constructing a new resource path that includes a query. For example, when given a resourcePath of /contacts and a dictionary of parameters containing foo=bar and color=red, will return /contacts?foo=bar&color=red - + *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 @@ -43,11 +43,11 @@ Convenience method for generating a path against the properties of an object. Takes a string with property names prefixed with a colon and interpolates the values of the properties specified and returns the generated path. - + For example, given an 'article' object with an 'articleID' property of 12345 [@"articles/:articleID" interpolateWithObject:article] would generate @"articles/12345" This functionality is the basis for resource path generation in the Router. - + @param object The object to interpolate the properties against @see RKMakePathWithObject @see RKPathMatcher @@ -56,9 +56,9 @@ /** Returns a dictionary of parameter keys and values using UTF-8 encoding given a URL-style query string - on the receiving object. For example, when given the string /contacts?foo=bar&color=red, + on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excluding the path "/contacts?" - + @param receiver A string in the form of @"/object/?sortBy=name", or @"/object/?sortBy=name&color=red" @return A new dictionary of query parameters, with keys like 'sortBy' and values like 'name'. */ @@ -66,12 +66,12 @@ /** Returns a dictionary of parameter keys and values given a URL-style query string - on the receiving object. For example, when given the string /contacts?foo=bar&color=red, + on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=bar and color=red, excludes the path "/contacts?" - + This method originally appeared as queryContentsUsingEncoding: in the Three20 project: https://github.com/facebook/three20/blob/master/src/Three20Core/Sources/NSStringAdditions.m - + @param receiver A string in the form of @"/object/?sortBy=name", or @"/object/?sortBy=name&color=red" @param encoding The encoding for to use while parsing the query string. @return A new dictionary of query parameters, with keys like 'sortBy' and values like 'name'. @@ -80,12 +80,12 @@ /** Returns a dictionary of parameter keys and values arrays (if requested) given a URL-style query string - on the receiving object. For example, when given the string /contacts?foo=bar&color=red, + on the receiving object. For example, when given the string /contacts?foo=bar&color=red, this will return a dictionary of parameters containing foo=[bar] and color=[red], excludes the path "/contacts?" - + This method originally appeared as queryContentsUsingEncoding: in the Three20 project: https://github.com/facebook/three20/blob/master/src/Three20Core/Sources/NSStringAdditions.m - + @param receiver A string in the form of @"/object?sortBy=name", or @"/object?sortBy=name&color=red" @param shouldUseArrays If NO, it yields the same results as queryParametersUsingEncoding:, otherwise it creates value arrays instead of value strings. @param encoding The encoding for to use while parsing the query string. @@ -95,7 +95,7 @@ - (NSDictionary *)queryParametersUsingArrays:(BOOL)shouldUseArrays encoding:(NSStringEncoding)encoding; /** - Returns a URL encoded representation of self. + Returns a URL encoded representation of self. */ - (NSString *)stringByAddingURLEncoding; @@ -106,9 +106,9 @@ - (NSString *)stringByReplacingURLEncoding; /** - Returns a new string made by appending a path component to the original string, + Returns a new string made by appending a path component to the original string, along with a trailing slash if the component is designated a directory. - + @param pathComponent The path component to add to the URL. @param isDirectory: If TRUE, a trailing slash is appended after pathComponent. @return A new string with pathComponent appended. @@ -116,19 +116,19 @@ - (NSString *)stringByAppendingPathComponent:(NSString *)pathComponent isDirectory:(BOOL)isDirectory; /** - Interprets the receiver as a path and returns the MIME Type for the path extension + Interprets the receiver as a path and returns the MIME Type for the path extension using Core Services. - - For example, given a string with the path /Users/blake/Documents/monkey.json we would get + + For example, given a string with the path /Users/blake/Documents/monkey.json we would get @"application/json" as the MIME Type. - + @return The expected MIME Type of the resource identified by the path or nil if unknown */ - (NSString *)MIMETypeForPathExtension; /** Returns YES if the receiver contains a valid IP address - + For example, @"127.0.0.1" and @"10.0.1.35" would return YES while @"restkit.org" would return NO */ @@ -136,7 +136,7 @@ /** Returns a string of the MD5 sum of the receiver. - + @return A new string containing the MD5 sum of the receiver. */ - (NSString *)MD5; diff --git a/Code/Support/NSString+RKAdditions.m b/Code/Support/NSString+RKAdditions.m index 2da08ce3..20ba3aa8 100644 --- a/Code/Support/NSString+RKAdditions.m +++ b/Code/Support/NSString+RKAdditions.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 6/15/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -85,7 +85,7 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions) [scanner scanUpToCharactersFromSet:delimiterSet intoString:&pairString]; [scanner scanCharactersFromSet:delimiterSet intoString:NULL]; NSArray* kvPair = [pairString componentsSeparatedByString:@"="]; - + if (!shouldUseArrays) { if (kvPair.count == 2) { NSString* key = [[kvPair objectAtIndex:0] @@ -106,7 +106,7 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions) } if (kvPair.count == 1) { [values addObject:[NSNull null]]; - + } else if (kvPair.count == 2) { NSString* value = [[kvPair objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:encoding]; @@ -123,13 +123,13 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions) CFStringRef legalURLCharactersToBeEscaped = CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`\n\r"); CFStringRef encodedString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, - NULL, + NULL, legalURLCharactersToBeEscaped, kCFStringEncodingUTF8); if (encodedString) { return [(NSString *)encodedString autorelease]; } - + // TODO: Log a warning? return @""; } @@ -162,7 +162,7 @@ RK_FIX_CATEGORY_BUG(NSString_RKAdditions) - (BOOL)isIPAddress { struct sockaddr_in sa; char *hostNameOrIPAddressCString = (char *) [self UTF8String]; - int result = inet_pton(AF_INET, hostNameOrIPAddressCString, &(sa.sin_addr)); + int result = inet_pton(AF_INET, hostNameOrIPAddressCString, &(sa.sin_addr)); return (result != 0); } diff --git a/Code/Support/NSURL+RKAdditions.h b/Code/Support/NSURL+RKAdditions.h index f9e03680..dc2c9fbe 100644 --- a/Code/Support/NSURL+RKAdditions.h +++ b/Code/Support/NSURL+RKAdditions.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 10/11/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,10 +30,10 @@ /** Returns the MIME Type for the resource identified by the URL by interpretting the path extension using Core Services. - - For example, given a URL to http://restkit.org/monkey.json we would get + + For example, given a URL to http://restkit.org/monkey.json we would get @"application/json" as the MIME Type. - + @return The expected MIME Type of the resource identified by the URL or nil if unknown */ - (NSString *)MIMETypeForPathExtension; diff --git a/Code/Support/NSURL+RKAdditions.m b/Code/Support/NSURL+RKAdditions.m index 0fb24f69..ee937f83 100644 --- a/Code/Support/NSURL+RKAdditions.m +++ b/Code/Support/NSURL+RKAdditions.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 10/11/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/Parsers/JSON/RKJSONParserJSONKit.h b/Code/Support/Parsers/JSON/RKJSONParserJSONKit.h index 6e7c7a5e..e283ec97 100644 --- a/Code/Support/Parsers/JSON/RKJSONParserJSONKit.h +++ b/Code/Support/Parsers/JSON/RKJSONParserJSONKit.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/14/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/Parsers/JSON/RKJSONParserJSONKit.m b/Code/Support/Parsers/JSON/RKJSONParserJSONKit.m index 384cc6c2..5a29e3b5 100644 --- a/Code/Support/Parsers/JSON/RKJSONParserJSONKit.m +++ b/Code/Support/Parsers/JSON/RKJSONParserJSONKit.m @@ -4,13 +4,13 @@ // // Created by Jeff Arena on 3/16/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/Parsers/XML/RKXMLParserXMLReader.h b/Code/Support/Parsers/XML/RKXMLParserXMLReader.h index 5ee142b9..f4aa125f 100644 --- a/Code/Support/Parsers/XML/RKXMLParserXMLReader.h +++ b/Code/Support/Parsers/XML/RKXMLParserXMLReader.h @@ -10,13 +10,13 @@ Provides a basic XML implementation using an adapted version of the XMLReader class by "Insert-Witty-Name" available at: https://github.com/RestKit/XML-to-NSDictionary - + RKXMLParserXMLReader will parse an XML document into an NSDictionary representation suitable for use with RestKit's key-value coding based object mapping implementation. - + XML attributes are represented as keys in a dictionary. - + **NOTE** When an XML tag is parsed containing both XML attributes and an enclosed text node, the value of the text node will be inserted in the parsed dictionary at the `@"text"` key. @@ -26,7 +26,7 @@ #import "RKParser.h" @interface RKXMLParserXMLReader : NSObject { - + } @end diff --git a/Code/Support/RKAlert.h b/Code/Support/RKAlert.h index 36db3af7..00e7ab49 100644 --- a/Code/Support/RKAlert.h +++ b/Code/Support/RKAlert.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/10/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/RKAlert.m b/Code/Support/RKAlert.m index 1ec124b1..c6ed0f64 100644 --- a/Code/Support/RKAlert.m +++ b/Code/Support/RKAlert.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 4/10/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,7 +46,7 @@ void RKAlertWithTitle(NSString* message, NSString* title) { NSAlert *alert = [[alertClass alloc] init]; [alert setMessageText:message]; [alert setInformativeText:message]; - [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)]; + [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)]; [alert runModal]; [alert release]; } else { @@ -54,5 +54,5 @@ void RKAlertWithTitle(NSString* message, NSString* title) { } #elif TARGET_OS_UNIX RKLogCritical(@"%@: %@", title, message); -#endif +#endif } diff --git a/Code/Support/RKBenchmark.h b/Code/Support/RKBenchmark.h index 785767f4..73c7e991 100644 --- a/Code/Support/RKBenchmark.h +++ b/Code/Support/RKBenchmark.h @@ -55,7 +55,7 @@ /** Performs a benchmark and returns a time interval measurement of the total time elapsed during the execution of the blocl. - + @param block A block to execute and measure the elapsed time during execution. @return A time interval equal to the total time elapsed during execution. */ @@ -67,7 +67,7 @@ /** Retrieves or creates a benchmark object instance with a given name. - + @param name A name for the benchmark. @return A new or existing benchmark object with the given name. */ @@ -75,7 +75,7 @@ /** Creates and returns a benchmark object with a name. - + @param name A name for the benchmark. @return A new benchmark object with the given name. */ @@ -83,7 +83,7 @@ /** Initializes a new benchmark object with a name. - + @param name The name to initialize the receiver with. @return The receiver, initialized with the given name. */ @@ -96,7 +96,7 @@ /** Runs a benchmark by starting the receiver, executing the block, and then stopping the benchmark object. - + @param executionBlock A block to execute as the body of the benchmark. */ - (void)run:(void (^)(void))executionBlock; diff --git a/Code/Support/RKBenchmark.m b/Code/Support/RKBenchmark.m index f05fd20e..10d1cb86 100644 --- a/Code/Support/RKBenchmark.m +++ b/Code/Support/RKBenchmark.m @@ -92,7 +92,7 @@ static NSMutableDictionary * __sharedBenchmarks = nil; - (void)stop { self.endTime = CFAbsoluteTimeGetCurrent(); self.stopped = YES; - + // Calculate elapsed time CFDateRef startDate = CFDateCreate(NULL, self.startTime); CFDateRef endDate = CFDateCreate(NULL, self.endTime); @@ -102,15 +102,15 @@ static NSMutableDictionary * __sharedBenchmarks = nil; } - (void)log { - CFTimeInterval timeElapsed; + CFTimeInterval timeElapsed; if (self.isStopped) { timeElapsed = self.elapsedTime; } else { CFDateRef startDate = CFDateCreate(NULL, self.startTime); timeElapsed = CFDateGetTimeIntervalSinceDate(startDate, (CFDateRef)[NSDate date]); CFRelease(startDate); - } - + } + // log elapsed time if (_name) NSLog(@"Benchmark '%@' took %f seconds.", _name, timeElapsed); else NSLog(@"Benchmark took %f seconds.", timeElapsed); diff --git a/Code/Support/RKDirectory.h b/Code/Support/RKDirectory.h index 8fb876af..dfd0b46f 100644 --- a/Code/Support/RKDirectory.h +++ b/Code/Support/RKDirectory.h @@ -9,7 +9,7 @@ #import /** - iOS and OS X agnostic accessors for safely returning directory paths for use + iOS and OS X agnostic accessors for safely returning directory paths for use by the framework and applications. */ @interface RKDirectory : NSObject @@ -27,7 +27,7 @@ Returns a path to the root caches directory used by RestKit for storage. On iOS, this is a sanboxed path specific for the executing application. On OS X, this is an application specific path under NSCachesDirectory (i.e. ~/Library/Caches). - + @return The full path to the Caches directory. */ + (NSString *)cachesDirectory; diff --git a/Code/Support/RKDirectory.m b/Code/Support/RKDirectory.m index 610f3e4e..5da5deab 100644 --- a/Code/Support/RKDirectory.m +++ b/Code/Support/RKDirectory.m @@ -19,43 +19,43 @@ RKLogWarning(@"Unable to determine CFBundleExecutable: storing data under RestKit directory name."); executableName = @"RestKit"; } - + return executableName; } + (NSString *)applicationDataDirectory { #if TARGET_OS_IPHONE - + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); return ([paths count] > 0) ? [paths objectAtIndex:0] : nil; - + #else - + NSFileManager *sharedFM = [NSFileManager defaultManager]; - + NSArray *possibleURLs = [sharedFM URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]; NSURL *appSupportDir = nil; NSURL *appDirectory = nil; - + if ([possibleURLs count] >= 1) { appSupportDir = [possibleURLs objectAtIndex:0]; } - + if (appSupportDir) { NSString *executableName = [RKDirectory executableName]; appDirectory = [appSupportDir URLByAppendingPathComponent:executableName]; return [appDirectory path]; } - + return nil; #endif } + (NSString *)cachesDirectory { -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; #else NSString *path = nil; @@ -63,7 +63,7 @@ if ([paths count]) { path = [[paths objectAtIndex:0] stringByAppendingPathComponent:[RKDirectory executableName]]; } - + return path; #endif } diff --git a/Code/Support/RKDotNetDateFormatter.h b/Code/Support/RKDotNetDateFormatter.h index 8c73f01c..3e8466e7 100644 --- a/Code/Support/RKDotNetDateFormatter.h +++ b/Code/Support/RKDotNetDateFormatter.h @@ -33,7 +33,7 @@ } /** - Instantiates an autoreleased RKDotNetDateFormatter object with the timezone set to UTC + Instantiates an autoreleased RKDotNetDateFormatter object with the timezone set to UTC (Greenwich Mean Time). @return An autoreleased RKDotNetDateFormatter object @@ -42,7 +42,7 @@ + (RKDotNetDateFormatter *)dotNetDateFormatter; /** - Instantiates an autoreleased RKDotNetDateFormatter object. + Instantiates an autoreleased RKDotNetDateFormatter object. The supplied timeZone, such as one produced with [NSTimeZone timeZoneWithName:@"UTC"], is only used during calls to stringFromDate:, for a detailed explanation see dateFromString: @@ -60,14 +60,14 @@ /Date(-1112715000000)/ 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 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. + 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. If, on the other hand, there is no offset in the ASP.NET string, we assume GMT (+0000) anyway. - In summation, for this class setTimeZone: is ignored except when using stringFromDate: - + In summation, for this class setTimeZone: is ignored except when using stringFromDate: + @param string The ASP.NET style string, /Date(1112715000000-0500)/ @return An NSDate object @see stringFromDate @@ -79,10 +79,10 @@ /** Returns an ASP.NET style date string from an NSDate, such as /Date(1112715000000+0000)/ 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. - + timezone offset from GMT in 24-hour time. + *NOTE* GMT (+0000) is assumed otherwise specified via setTimeZone: - + @param date An NSDate @return The ASP.NET style string, /Date(1112715000000-0500)/ @see dateFromString diff --git a/Code/Support/RKFixCategoryBug.h b/Code/Support/RKFixCategoryBug.h index f2b023f6..7bb79094 100644 --- a/Code/Support/RKFixCategoryBug.h +++ b/Code/Support/RKFixCategoryBug.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/1/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ -all_load or -force_load to load object files from static libraries that only contain categories and no classes. See http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html for more info. - + Shamelessly borrowed from Three20 */ #define RK_FIX_CATEGORY_BUG(name) @interface RK_FIX_CATEGORY_BUG##name @end \ diff --git a/Code/Support/RKLog.h b/Code/Support/RKLog.h index 945e4dd2..0bf7ba90 100644 --- a/Code/Support/RKLog.h +++ b/Code/Support/RKLog.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/3/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ /** RestKit Logging is based on the LibComponentLogging framework - + @see lcl_config_components.h @see lcl_config_logger.h */ @@ -28,11 +28,11 @@ /** RKLogComponent defines the active component within any given portion of RestKit - + By default, messages will log to the base 'RestKit' log component. All other components used by RestKit are nested under this parent, so this effectively sets the default log level for the entire library. - + The component can be undef'd and redefined to change the active logging component. */ #define RKLogComponent lcl_cRestKit @@ -40,23 +40,23 @@ /** The logging macros. These macros will log to the currently active logging component at the log level identified in the name of the macro. - + For example, in the RKObjectMappingOperation class we would redefine the RKLogComponent: - + #undef RKLogComponent #define RKLogComponent lcl_cRestKitObjectMapping - + The lcl_c prefix is the LibComponentLogging data structure identifying the logging component we want to target within this portion of the codebase. See lcl_config_component.h for reference. - + Having defined the logging component, invoking the logger via: - + RKLogInfo(@"This is my log message!"); - + Would result in a log message similar to: - + I RestKit.ObjectMapping:RKLog.h:42 This is my log message! - + The message will only be logged if the log level for the active component is equal to or higher than the level the message was logged at (in this case, Info). */ @@ -80,7 +80,7 @@ lcl_log(RKLogComponent, lcl_vTrace, @"" __VA_ARGS__) /** Log Level Aliases - + These aliases simply map the log levels defined within LibComponentLogger to something more friendly */ #define RKLogLevelOff lcl_vOff @@ -94,14 +94,14 @@ lcl_log(RKLogComponent, lcl_vTrace, @"" __VA_ARGS__) /** Alias the LibComponentLogger logging configuration method. Also ensures logging is initialized for the framework. - + Expects the name of the component and a log level. - + Examples: - + // Log debugging messages from the Network component RKLogConfigureByName("RestKit/Network", RKLogLevelDebug); - + // Log only critical messages from the Object Mapping component RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelCritical); */ @@ -111,7 +111,7 @@ lcl_configure_by_name(name, level); /** Alias for configuring the LibComponentLogger logging component for the App. This - enables the end-user of RestKit to leverage RKLog() to log messages inside of + enables the end-user of RestKit to leverage RKLog() to log messages inside of their apps. */ #define RKLogSetAppLoggingLevel(level) \ @@ -158,10 +158,10 @@ lcl_configure_by_name("App", level); /** Set the Default Log Level - + Based on the presence of the DEBUG flag, we default the logging for the RestKit parent component to Info or Warning. - + You can override this setting by defining RKLogLevelDefault as a pre-processor macro. */ #ifndef RKLogLevelDefault diff --git a/Code/Support/RKLog.m b/Code/Support/RKLog.m index 05f5b1b1..4b67c297 100644 --- a/Code/Support/RKLog.m +++ b/Code/Support/RKLog.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 6/10/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/RKMIMETypes.h b/Code/Support/RKMIMETypes.h index 3ba26408..7cfdbaa3 100644 --- a/Code/Support/RKMIMETypes.h +++ b/Code/Support/RKMIMETypes.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/18/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/RKMIMETypes.m b/Code/Support/RKMIMETypes.m index ef7c7d8e..818c21ec 100644 --- a/Code/Support/RKMIMETypes.m +++ b/Code/Support/RKMIMETypes.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 5/18/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/RKOrderedDictionary.m b/Code/Support/RKOrderedDictionary.m index aedc85ff..3ff6e8e2 100644 --- a/Code/Support/RKOrderedDictionary.m +++ b/Code/Support/RKOrderedDictionary.m @@ -134,7 +134,7 @@ NSString *RKDescriptionForObject(NSObject *object, id locale, NSUInteger indent) { [indentString appendFormat:@" "]; } - + NSMutableString *description = [NSMutableString string]; [description appendFormat:@"%@{\n", indentString]; for (NSObject *key in self) diff --git a/Code/Support/RKParser.h b/Code/Support/RKParser.h index dc137e15..4302d767 100644 --- a/Code/Support/RKParser.h +++ b/Code/Support/RKParser.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 10/1/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/RKPathMatcher.h b/Code/Support/RKPathMatcher.h index edc08f21..53c5ecfb 100755 --- a/Code/Support/RKPathMatcher.h +++ b/Code/Support/RKPathMatcher.h @@ -4,13 +4,13 @@ // // Created by Greg Combs on 9/2/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,12 +23,12 @@ /** This class performs pattern matching and parameter parsing of strings, usually resource paths. - It provides much of the necessary tools to map a given resource path to local objects (the inverse + It provides much of the necessary tools to map a given resource path to local objects (the inverse of RKRouter's function). This makes it easier to implement RKManagedObjectCache, and generate fetched requests from a given resource path. There are two means of instantiating and using a matcher object in order to provide more flexibility in implementations, and to improve efficiency by eliminating repetitive and costly pattern initializations. - + @see RKManagedObjectCache @see RKMakePathWithObject @see RKRouter @@ -43,65 +43,65 @@ @property (copy, readonly) NSDictionary *queryParameters; /** - Creates an RKPathMatcher starting from a resource path string. This method should be followed by + Creates an RKPathMatcher starting from a resource path string. This method should be followed by matchesPattern:tokenizeQueryStrings:parsedArguments: - + @param pathString The string to evaluate and parse, such as /districts/tx/upper/?apikey=GC5512354 @return An instantiated RKPathMatcher without an established pattern. */ +(RKPathMatcher *)matcherWithPath:(NSString *)pathString; /** - Determines if the path string matches the provided pattern, and yields a dictionary with the resulting + Determines if the path string matches the provided pattern, and yields a dictionary with the resulting matched key/value pairs. Use of this method should be preceded by matcherWithPath: - 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 + 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 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 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: + part of the json static string. In these instances, you need to escape the dot with two backslashes, like so: /:filename\\.json - + @param patternString The pattern to use for evaluating, such as /:entityName/:stateID/:chamber/ @param shouldTokenize If YES, any query parameters will be tokenized and inserted into the parsed argument dictionary. @param arguments A pointer to a dictionary that contains the key/values from the pattern (and parameter) matching. - @return A boolean indicating if the path string successfully matched the pattern. + @return A boolean indicating if the path string successfully matched the pattern. */ - (BOOL)matchesPattern:(NSString *)patternString tokenizeQueryStrings:(BOOL)shouldTokenize parsedArguments:(NSDictionary **)arguments; /** - Creates an RKPathMatcher starting from a pattern string. This method should be followed by + Creates an RKPathMatcher starting from a pattern string. This method should be followed by 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 + 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 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 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: + part of the json static string. In these instances, you need to escape the dot with two backslashes, like so: /:filename\\.json - + @param patternString The pattern to use for evaluating, such as /:entityName/:stateID/:chamber/ - @return An instantiated RKPathMatcher with an established pattern. + @return An instantiated RKPathMatcher with an established pattern. */ +(RKPathMatcher *)matcherWithPattern:(NSString *)patternString; /** - Determines if the provided resource path string matches a pattern, and yields a dictionary with the resulting + Determines if the provided resource path string matches a pattern, and yields a dictionary with the resulting matched key/value pairs. Use of this method should be preceded by matcherWithPattern: - + @param pathString The string to evaluate and parse, such as /districts/tx/upper/?apikey=GC5512354 @param shouldTokenize If YES, any query parameters will be tokenized and inserted into the parsed argument dictionary. @param arguments A pointer to a dictionary that contains the key/values from the pattern (and parameter) matching. - @return A boolean indicating if the path string successfully matched the pattern. + @return A boolean indicating if the path string successfully matched the pattern. */ - (BOOL)matchesPath:(NSString *)pathString tokenizeQueryStrings:(BOOL)shouldTokenize parsedArguments:(NSDictionary **)arguments; @@ -109,14 +109,14 @@ This generates a resource path by interpolating the properties of the 'object' argument, assuming the existence of a previously specified pattern established via matcherWithPattern:. Otherwise, this method is identical in function to RKMakePathWithObject (in fact it is a shortcut for this method). - + For example, given an 'article' object with an 'articleID' property value of 12345 ... - + RKPathMatcher *matcher = [RKPathMatcher matcherWithPattern:@"/articles/:articleID"]; NSString *resourcePath = [matcher pathFromObject:article]; - + ... will produce a 'resourcePath' containing the string "/articles/12345" - + @param object The object containing the properties to interpolate. @return A string with the object's interpolated property values inserted into the receiver's established pattern. @see RKMakePathWithObject @@ -128,14 +128,14 @@ This generates a resource path by interpolating the properties of the 'object' argument, assuming the existence of a previously specified pattern established via matcherWithPattern:. Otherwise, this method is identical in function to RKMakePathWithObject (in fact it is a shortcut for this method). - + For example, given an 'article' object with an 'articleID' property value of 12345 and a code of "This/That"... - + RKPathMatcher *matcher = [RKPathMatcher matcherWithPattern:@"/articles/:articleID/:code"]; NSString *resourcePath = [matcher pathFromObject:article addingEscapes:YES]; - + ... will produce a 'resourcePath' containing the string "/articles/12345/This%2FThat" - + @param object The object containing the properties to interpolate. @param addEscapes Conditionally add percent escapes to the interpolated property values @return A string with the object's interpolated property values inserted into the receiver's established pattern. diff --git a/Code/Support/RKPathMatcher.m b/Code/Support/RKPathMatcher.m index 577a798a..4726f499 100755 --- a/Code/Support/RKPathMatcher.m +++ b/Code/Support/RKPathMatcher.m @@ -4,13 +4,13 @@ // // Created by Greg Combs on 9/2/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -73,7 +73,7 @@ NSString *RKEncodeURLString(NSString *unencodedString) { copy.sourcePath = self.sourcePath; copy.rootPath = self.rootPath; copy.queryParameters = self.queryParameters; - + return copy; } @@ -109,7 +109,7 @@ NSString *RKEncodeURLString(NSString *unencodedString) { NSArray *components = [self.sourcePath componentsSeparatedByString:@"?"]; if ([components count] > 1) { self.rootPath = [components objectAtIndex:0]; - self.queryParameters = [[components objectAtIndex:1] queryParametersUsingEncoding:NSUTF8StringEncoding]; + self.queryParameters = [[components objectAtIndex:1] queryParametersUsingEncoding:NSUTF8StringEncoding]; return YES; } return NO; diff --git a/Code/Support/RKPortCheck.h b/Code/Support/RKPortCheck.h index e54359af..d943a759 100644 --- a/Code/Support/RKPortCheck.h +++ b/Code/Support/RKPortCheck.h @@ -22,7 +22,7 @@ /** Initializes the receiver with a given hostname or IP address as a string and a numeric TCP port number. - + @param hostNameOrIPAddress A string containing the hostname or IP address to check. @param port The TCP port on the remote host to check for a listening server on. @return The receiver, initialized with host and port. @@ -49,7 +49,7 @@ /** Runs the check by creating a socket and attempting to connect to the - target host and port via TCP. The + target host and port via TCP. The */ - (void)run; @@ -59,7 +59,7 @@ /** Returns a Boolean value indicating if the check has been run. - + @return YES if the check has been run, otherwise NO. */ - (BOOL)hasRun; @@ -67,7 +67,7 @@ /** Returns a Boolean value indicating if the host and port the receiver checked is open and listening for incoming connections. - + @return YES if the port on the remote host is open, otherwise NO. */ - (BOOL)isOpen; @@ -75,7 +75,7 @@ /** Returns a Boolean value indicating if the host and port the receiver checked is NOT open and listening for incoming connections. - + @return YES if the port on the remote host is closed, otherwise NO. */ - (BOOL)isClosed; diff --git a/Code/Support/RKPortCheck.m b/Code/Support/RKPortCheck.m index 254d46a8..788dc73f 100644 --- a/Code/Support/RKPortCheck.m +++ b/Code/Support/RKPortCheck.m @@ -27,15 +27,15 @@ - (id)initWithHost:(NSString *)hostNameOrIPAddress port:(NSUInteger)port { - self = [self init]; + self = [self init]; if (self) { _run = NO; _host = [hostNameOrIPAddress retain]; _port = port; - + struct sockaddr_in sa; char *hostNameOrIPAddressCString = (char *) [hostNameOrIPAddress UTF8String]; - int result = inet_pton(AF_INET, hostNameOrIPAddressCString, &(sa.sin_addr)); + int result = inet_pton(AF_INET, hostNameOrIPAddressCString, &(sa.sin_addr)); if (result != 0) { // IP Address bzero(&_remote_saddr, sizeof(struct sockaddr_in)); @@ -49,14 +49,14 @@ if ((hp = gethostbyname(hostNameOrIPAddressCString)) == 0) { return nil; } - + bzero(&_remote_saddr, sizeof(struct sockaddr_in)); _remote_saddr.sin_family = AF_INET; _remote_saddr.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; _remote_saddr.sin_port = htons(port); } } - + return self; } @@ -67,22 +67,22 @@ } - (void)run -{ +{ int sd; _run = YES; - + // Create Internet domain socket if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { _open = NO; return; } - + // Try to connect to the port _open = (connect(sd,(struct sockaddr *) &_remote_saddr, sizeof(_remote_saddr)) == 0); - + if (_open) { close(sd); - } + } } - (BOOL)isOpen diff --git a/Code/Support/RKSearchEngine.h b/Code/Support/RKSearchEngine.h index bfc96eea..9675111c 100644 --- a/Code/Support/RKSearchEngine.h +++ b/Code/Support/RKSearchEngine.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/26/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/RKSearchEngine.m b/Code/Support/RKSearchEngine.m index 17384576..4c77c6f1 100644 --- a/Code/Support/RKSearchEngine.m +++ b/Code/Support/RKSearchEngine.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 8/26/09. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,7 +41,7 @@ stripsWhitespace = YES; caseSensitive = NO; } - + return self; } @@ -69,7 +69,7 @@ - (NSArray *)searchWithTerms:(NSArray*)searchTerms onProperties:(NSArray *)properties inCollection:(NSArray *)collection compoundSelector:(SEL)selector { NSPredicate *searchPredicate = nil; - + // do any of these properties contain all of these terms NSMutableArray *propertyPredicates = [NSMutableArray array]; for (NSString *property in properties) { @@ -83,12 +83,12 @@ } [termPredicates addObject:predicate]; } - + // build a predicate for all of the search terms NSPredicate *termsPredicate = [NSCompoundPredicate performSelector:selector withObject:termPredicates]; [propertyPredicates addObject:termsPredicate]; } - + searchPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:propertyPredicates]; return [collection filteredArrayUsingPredicate:searchPredicate]; } @@ -107,7 +107,7 @@ NSString *searchQuery = [[searchText copy] autorelease]; searchQuery = [self stripWhitespaceIfNecessary:searchQuery]; NSArray *searchTerms = [self tokenizeOrCollect:searchQuery]; - + if (mode == RKSearchModeOr) { return [self searchWithTerms:searchTerms onProperties:properties inCollection:collection compoundSelector:@selector(orPredicateWithSubpredicates:)]; } else if (mode == RKSearchModeAnd) { diff --git a/Code/Support/Support.h b/Code/Support/Support.h index 9dac8073..f3242978 100644 --- a/Code/Support/Support.h +++ b/Code/Support/Support.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 9/30/10. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/lcl_config_components.h b/Code/Support/lcl_config_components.h index 8a556396..50ce8a24 100644 --- a/Code/Support/lcl_config_components.h +++ b/Code/Support/lcl_config_components.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 6/8/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ // and its grouping information in a non-technical, human-readable way // which could be used by a user interface. Groups should be separated by the // path separator '/', e.g. 'Example/Main/Component 1'. -// +// // diff --git a/Code/Support/lcl_config_extensions.h b/Code/Support/lcl_config_extensions.h index ffbe792a..f9b31765 100644 --- a/Code/Support/lcl_config_extensions.h +++ b/Code/Support/lcl_config_extensions.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 6/8/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Support/lcl_config_logger.h b/Code/Support/lcl_config_logger.h index 5fdbfe9e..44eabdcc 100644 --- a/Code/Support/lcl_config_logger.h +++ b/Code/Support/lcl_config_logger.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 6/8/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Code/Testing/RKMappingTest.h b/Code/Testing/RKMappingTest.h index 96b554c2..4d623757 100644 --- a/Code/Testing/RKMappingTest.h +++ b/Code/Testing/RKMappingTest.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 2/17/12. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ /** Creates and returns a new test for a given object mapping and source object. - + @param mapping The object mapping being tested. @param sourceObject The source object being mapped. @return A new mapping test object for a mapping and sourceObject. @@ -45,7 +45,7 @@ /** Creates and returns a new test for a given object mapping, source object and destination object. - + @param mapping The object mapping being tested. @param sourceObject The source object being mapped from. @param destinationObject The destionation object being to. @@ -55,7 +55,7 @@ /** Initializes the receiver with a given object mapping, source object, and destination object. - + @param mapping The object mapping being tested. @param sourceObject The source object being mapped from. @param destinationObject The destionation object being to. @@ -70,7 +70,7 @@ /** Creates and adds an expectation that a key path on the source object will be mapped to a new key path on the destination object. - + @param sourceKeyPath A key path on the sourceObject that should be mapped from. @param destinationKeyPath A key path on the destinationObject that should be mapped to. @see RKObjectMappingTestExpectation @@ -80,7 +80,7 @@ /** Creates and adds an expectation that a key path on the source object will be mapped to a new key path on the destination object with a given value. - + @param sourceKeyPath A key path on the sourceObject that should be mapped from. @param destinationKeyPath A key path on the destinationObject that should be mapped from. @param value A value that is expected to be assigned to destinationKeyPath on the destinationObject. @@ -91,7 +91,7 @@ /** Creates and adds an expectation that a key path on the source object will be mapped to a new key path on the destination object with a value that passes a given test block. - + @param sourceKeyPath A key path on the sourceObject that should be mapped from. @param destinationKeyPath A key path on the destinationObject that should be mapped to. @param evaluationBlock A block with which to evaluate the success of the mapping. @@ -101,11 +101,11 @@ /** Adds an expectation to the receiver to be evaluated during verification. - + If the receiver has been configured with verifiesOnExpect = YES, the mapping operation is performed immediately and the expectation is evaluated. - - @param expectation An expectation object to evaluate during test verification. + + @param expectation An expectation object to evaluate during test verification. @see RKObjectMappingTestExpectation @see verifiesOnExpect */ @@ -127,7 +127,7 @@ /** Verifies that the mapping is configured correctly by performing an object mapping operation and ensuring that all expectations are met. - + @exception NSInternalInconsistencyException Raises an NSInternalInconsistencyException if mapping fails or any expectation is not satisfied. */ @@ -158,11 +158,11 @@ /** The destionation object being mapped to. - + If nil, the mapping test will instantiate a destination object to perform the mapping by invoking `[self.mapping mappableObjectForData:self.sourceObject]` and set the new object as the value for the destinationObject property. - + @see [RKObjectMapping mappableObjectForData:] */ @property(nonatomic, strong, readonly) id destinationObject; @@ -170,7 +170,7 @@ /** A Boolean value that determines if expectations should be verified immediately when added to the receiver. - + **Default**: NO */ @property(nonatomic, assign) BOOL verifiesOnExpect; diff --git a/Code/Testing/RKMappingTest.m b/Code/Testing/RKMappingTest.m index b30acdc7..4b015a73 100644 --- a/Code/Testing/RKMappingTest.m +++ b/Code/Testing/RKMappingTest.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 2/17/12. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); RKMappingTestEvent *event = [RKMappingTestEvent new]; event.value = value; event.mapping = mapping; - + return event; } @@ -108,9 +108,9 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); - (id)initWithMapping:(RKObjectMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject { NSAssert(sourceObject != nil, @"Cannot perform a mapping operation without a sourceObject object"); NSAssert(mapping != nil, @"Cannot perform a mapping operation without a mapping"); - + self = [super init]; - if (self) { + if (self) { _sourceObject = sourceObject; _destinationObject = destinationObject; _mapping = mapping; @@ -125,7 +125,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); - (void)addExpectation:(RKMappingTestExpectation *)expectation { [self.expectations addObject:expectation]; - + if (self.verifiesOnExpect) { [self performMapping]; [self verifyExpectation:expectation]; @@ -150,7 +150,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); return event; } } - + return nil; } @@ -169,7 +169,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); - (void)performMapping { NSAssert(self.mapping.objectClass, @"Cannot test a mapping that does not have a destination objectClass"); - + // Ensure repeated invocations of verify only result in a single mapping operation if (! self.hasPerformedMapping) { id sourceObject = self.rootKeyPath ? [self.sourceObject valueForKeyPath:self.rootKeyPath] : self.sourceObject; @@ -184,7 +184,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); [NSException raise:NSInternalInconsistencyException format:@"%@: failure when mapping from %@ to %@ with mapping %@", [self description], self.sourceObject, self.destinationObject, self.mapping]; } - + self.performedMapping = YES; } } @@ -206,7 +206,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue); - (void)verify { [self performMapping]; - + for (RKMappingTestExpectation *expectation in self.expectations) { [self verifyExpectation:expectation]; } diff --git a/Code/Testing/RKMappingTestExpectation.h b/Code/Testing/RKMappingTestExpectation.h index eb293f76..33a6f6e2 100644 --- a/Code/Testing/RKMappingTestExpectation.h +++ b/Code/Testing/RKMappingTestExpectation.h @@ -11,7 +11,7 @@ /** An RKMappingTestExpectation defines an expected mapping event that should occur during the execution of a RKMappingTest. - + @see RKMappingTest */ @interface RKMappingTestExpectation : NSObject @@ -23,7 +23,7 @@ /** Creates and returns a new expectation specifying that a key path in a source object should be mapped to another key path on a destination object. The value mapped is not evaluated. - + @param sourceKeyPath A key path on the source object that should be mapped. @param destinationKeyPath A key path on the destination object that should be mapped onto. @return An expectation specifying that sourceKeyPath should be mapped to destionationKeyPath. @@ -33,7 +33,7 @@ /** Creates and returns a new expectation specifying that a key path in a source object should be mapped to another key path on a destination object with a given value. - + @param sourceKeyPath A key path on the source object that should be mapped. @param destinationKeyPath A key path on the destination object that should be mapped onto. @param value The value that is expected to be assigned to the destination object at destinationKeyPath. @@ -45,7 +45,7 @@ Creates and returns a new expectation specifying that a key path in a source object should be mapped to another key path on a destinaton object and that the attribute mapping and value should evaluate to true with a given block. - + @param sourceKeyPath A key path on the source object that should be mapped. @param destinationKeyPath A key path on the destination object that should be mapped onto. @param evaluationBlock A block with which to evaluate the success of the mapping. diff --git a/Code/Testing/RKMappingTestExpectation.m b/Code/Testing/RKMappingTestExpectation.m index 9f71d37d..7613ce39 100644 --- a/Code/Testing/RKMappingTestExpectation.m +++ b/Code/Testing/RKMappingTestExpectation.m @@ -27,7 +27,7 @@ RKMappingTestExpectation *expectation = [self new]; expectation.sourceKeyPath = sourceKeyPath; expectation.destinationKeyPath = destinationKeyPath; - + return expectation; } @@ -36,7 +36,7 @@ expectation.sourceKeyPath = sourceKeyPath; expectation.destinationKeyPath = destinationKeyPath; expectation.value = value; - + return expectation; } @@ -45,7 +45,7 @@ expectation.sourceKeyPath = sourceKeyPath; expectation.destinationKeyPath = destinationKeyPath; expectation.evaluationBlock = testBlock; - + return expectation; } @@ -62,7 +62,7 @@ return [NSString stringWithFormat:@"expected sourceKeyPath '%@' to map to destinationKeyPath '%@' satisfying evaluation block", self.sourceKeyPath, self.destinationKeyPath]; } - + return [self mappingDescription]; } diff --git a/Code/Testing/RKTestFactory.h b/Code/Testing/RKTestFactory.h index 4724223b..b107cd5c 100644 --- a/Code/Testing/RKTestFactory.h +++ b/Code/Testing/RKTestFactory.h @@ -10,7 +10,7 @@ /** The default filename used for managed object stores created via the factory. - + @see [RKTestFactory setManagedObjectStoreFilename:] */ extern NSString * const RKTestFactoryDefaultStoreFilename; @@ -84,21 +84,21 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Returns the base URL with which to initialize RKClient and RKObjectManager instances created via the factory. - + @return The base URL for the factory. */ + (RKURL *)baseURL; /** Sets the base URL for the factory. - + @param URL The new base URL. */ + (void)setBaseURL:(RKURL *)URL; /** Returns the base URL as a string value. - + @return The base URL for the factory, as a string. */ + (NSString *)baseURLString; @@ -106,7 +106,7 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Sets the base URL for the factory to a new value by constructing an RKURL from the given string. - + @param baseURLString A string containing the URL to set as the base URL for the factory. */ + (void)setBaseURLString:(NSString *)baseURLString; @@ -114,15 +114,15 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Returns the filename used when constructing instances of RKManagedObjectStore via the factory. - + @return A string containing the filename to use when creating a managed object store. */ + (NSString *)managedObjectStoreFilename; /** Sets the filename to use when the factory constructs an instance of RKManagedObjectStore. - - @param managedObjectStoreFilename A string containing the filename to use when creating managed object + + @param managedObjectStoreFilename A string containing the filename to use when creating managed object store instances. */ + (void)setManagedObjectStoreFilename:(NSString *)managedObjectStoreFilename; @@ -177,7 +177,7 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Creates and returns an RKObjectManager instance using the factory defined for the name RKTestFactoryDefaultNamesObjectManager. - + @return A new object manager instance. */ + (id)objectManager; @@ -185,7 +185,7 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Creates and returns an RKObjectMappingProvider instance using the factory defined for the name RKTestFactoryDefaultNamesMappingProvider. - + @return A new object mapping provider instance. */ + (id)mappingProvider; @@ -193,11 +193,11 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Creates and returns a RKManagedObjectStore instance using the factory defined for the name RKTestFactoryDefaultNamesManagedObjectStore. - + A new managed object store will be configured and returned. If there is an existing persistent store (i.e. from a previous test invocation), then the persistent store is deleted. - + @return A new managed object store instance. */ + (id)managedObjectStore; @@ -207,7 +207,7 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; ///----------------------------------------------------------------------------- /** - Sets up the RestKit testing environment. Invokes the didSetUp callback for application + Sets up the RestKit testing environment. Invokes the didSetUp callback for application specific setup. */ + (void)setUp; @@ -226,7 +226,7 @@ extern NSString * const RKTestFactoryDefaultNamesManagedObjectStore; /** Clears the contents of the cache directory by removing the directory and recreating it. - + @see [RKDirectory cachesDirectory] */ + (void)clearCacheDirectory; diff --git a/Code/Testing/RKTestFactory.m b/Code/Testing/RKTestFactory.m index d35e9890..0c157f8b 100644 --- a/Code/Testing/RKTestFactory.m +++ b/Code/Testing/RKTestFactory.m @@ -33,7 +33,7 @@ static RKTestFactory *sharedFactory = nil; { // Ensure the shared factory is initialized [self sharedFactory]; - + if ([RKTestFactory respondsToSelector:@selector(didInitialize)]) { [RKTestFactory didInitialize]; } @@ -44,7 +44,7 @@ static RKTestFactory *sharedFactory = nil; if (! sharedFactory) { sharedFactory = [RKTestFactory new]; } - + return sharedFactory; } @@ -57,7 +57,7 @@ static RKTestFactory *sharedFactory = nil; self.factoryBlocks = [NSMutableDictionary new]; [self defineDefaultFactories]; } - + return self; } @@ -70,7 +70,7 @@ static RKTestFactory *sharedFactory = nil; { id (^block)() = [self.factoryBlocks objectForKey:factoryName]; NSAssert(block, @"No factory is defined with the name '%@'", factoryName); - + return block(); } @@ -80,33 +80,33 @@ static RKTestFactory *sharedFactory = nil; RKClient *client = [RKClient clientWithBaseURL:self.baseURL]; client.requestQueue.suspended = NO; [client.reachabilityObserver getFlags]; - + return client; }]; - + [self defineFactory:RKTestFactoryDefaultNamesObjectManager withBlock:^id { RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:self.baseURL]; RKObjectMappingProvider *mappingProvider = [self objectFromFactory:RKTestFactoryDefaultNamesMappingProvider]; objectManager.mappingProvider = mappingProvider; - + // Force reachability determination [objectManager.client.reachabilityObserver getFlags]; - + return objectManager; }]; - + [self defineFactory:RKTestFactoryDefaultNamesMappingProvider withBlock:^id { RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider mappingProvider]; return mappingProvider; }]; - + [self defineFactory:RKTestFactoryDefaultNamesManagedObjectStore withBlock:^id { NSString *storePath = [[RKDirectory applicationDataDirectory] stringByAppendingPathComponent:RKTestFactoryDefaultStoreFilename]; if ([[NSFileManager defaultManager] fileExistsAtPath:storePath]) { [RKManagedObjectStore deleteStoreInApplicationDataDirectoryWithFilename:RKTestFactoryDefaultStoreFilename]; } RKManagedObjectStore *store = [RKManagedObjectStore objectStoreWithStoreFilename:RKTestFactoryDefaultStoreFilename]; - + return store; }]; } @@ -186,7 +186,7 @@ static RKTestFactory *sharedFactory = nil; { RKManagedObjectStore *objectStore = [self objectFromFactory:RKTestFactoryDefaultNamesManagedObjectStore]; [RKManagedObjectStore setDefaultObjectStore:objectStore]; - + return objectStore; } @@ -206,7 +206,7 @@ static RKTestFactory *sharedFactory = nil; [RKObjectManager setSharedManager:nil]; [RKClient setSharedClient:nil]; [RKManagedObjectStore setDefaultObjectStore:nil]; - + if ([self respondsToSelector:@selector(didTearDown)]) { [self didTearDown]; } diff --git a/Code/Testing/RKTestFixture.h b/Code/Testing/RKTestFixture.h index 909f8d69..44fc99a5 100644 --- a/Code/Testing/RKTestFixture.h +++ b/Code/Testing/RKTestFixture.h @@ -47,7 +47,7 @@ /** Returns the full path to the specified fixture file on within the fixture bundle. - + @param fixtureName The name of the fixture file. @return The full path to the specified fixture file or nil if it cannot be located. */ diff --git a/Code/UI/RKAbstractTableController.m b/Code/UI/RKAbstractTableController.m index 97f2226d..f58cb73b 100755 --- a/Code/UI/RKAbstractTableController.m +++ b/Code/UI/RKAbstractTableController.m @@ -655,9 +655,9 @@ static NSString* lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey"; - (NSDate*)lastUpdatedDate { if (! self.objectLoader) { - return nil; + return nil; } - + if (_autoRefreshFromNetwork) { NSAssert(_cache, @"Found a nil cache when trying to read our last loaded time"); NSDictionary* lastUpdatedDates = [_cache dictionaryForCacheKey:lastUpdatedDateDictionaryKey]; diff --git a/Code/UI/RKFetchedResultsTableController.h b/Code/UI/RKFetchedResultsTableController.h index 21e2d0c7..c56a5f69 100755 --- a/Code/UI/RKFetchedResultsTableController.h +++ b/Code/UI/RKFetchedResultsTableController.h @@ -23,7 +23,7 @@ typedef UIView *(^RKFetchedResultsTableViewViewForHeaderInSectionBlock)(NSUInteger sectionIndex, NSString *sectionTitle); /** - Instances of RKFetchedResultsTableController provide an interface for driving a UITableView + Instances of RKFetchedResultsTableController provide an interface for driving a UITableView */ @interface RKFetchedResultsTableController : RKAbstractTableController { @private diff --git a/Code/UI/RKFetchedResultsTableController.m b/Code/UI/RKFetchedResultsTableController.m index 38763bf8..25e47c0d 100755 --- a/Code/UI/RKFetchedResultsTableController.m +++ b/Code/UI/RKFetchedResultsTableController.m @@ -324,7 +324,7 @@ NSError* error = nil; BOOL success = [mappingOperation performMapping:&error]; [mappingOperation release]; - + // NOTE: If there is no mapping work performed, but no error is generated then // we consider the operation a success. It is common for table cells to not contain // any dynamically mappable content (i.e. header/footer rows, banners, etc.) diff --git a/Code/UI/RKObjectManager+RKTableController.h b/Code/UI/RKObjectManager+RKTableController.h index 621668cb..c6d8ff43 100644 --- a/Code/UI/RKObjectManager+RKTableController.h +++ b/Code/UI/RKObjectManager+RKTableController.h @@ -20,7 +20,7 @@ /** Creates and returns a table controller object capable of loading remote object representations into a UITableView using the RestKit object mapping engine for a given table view controller. - + @param tableViewController A UITableViewController to instantiate a table controller for @return An RKTableController instance ready to drive the table view for the provided tableViewController. */ @@ -29,7 +29,7 @@ /** Creates and returns a table controller object capable of loading remote object representations into a UITableView using the RestKit object mapping engine for a given table view and view controller. - + @param tableView The UITableView object that table controller with acts as the delegate and data source for. @param viewController The UIViewController that owns the specified tableView. @return An RKTableController instance ready to drive the table view for the provided tableViewController. @@ -39,7 +39,7 @@ /** Creates and returns a fetched results table controller object capable of loading remote object representations stored in Core Data into a UITableView using the RestKit object mapping engine for a given table view controller. - + @param tableViewController A UITableViewController to instantiate a table controller for @return An RKFetchedResultsTableController instance ready to drive the table view for the provided tableViewController. */ @@ -48,7 +48,7 @@ /** Creates and returns a table controller object capable of loading remote object representations stored in Core Data into a UITableView using the RestKit object mapping engine for a given table view and view controller. - + @param tableView The UITableView object that table controller with acts as the delegate and data source for. @param viewController The UIViewController that owns the specified tableView. @return An RKFetchedResultsTableController instance ready to drive the table view for the provided tableViewController. diff --git a/Code/UI/RKTableController.h b/Code/UI/RKTableController.h index c37a3706..8fe33d76 100644 --- a/Code/UI/RKTableController.h +++ b/Code/UI/RKTableController.h @@ -102,7 +102,7 @@ /// @name Managing Sections ///////////////////////////////////////////////////////////////////////// -/** +/** The key path on the loaded objects used to determine the section they belong to. */ @property(nonatomic, copy) NSString *sectionNameKeyPath; diff --git a/Code/UI/RKTableController.m b/Code/UI/RKTableController.m index 9bdc6c0d..0d892d60 100644 --- a/Code/UI/RKTableController.m +++ b/Code/UI/RKTableController.m @@ -54,7 +54,7 @@ [self removeObserver:self forKeyPath:@"sections"]; [_form release]; [_sectionNameKeyPath release]; - + [super dealloc]; } @@ -194,12 +194,12 @@ } [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:self.defaultRowAnimation]; - - // The load is finalized via network callbacks for + + // The load is finalized via network callbacks for // dynamic table controllers if (nil == self.objectLoader) { [self didFinishLoad]; - } + } } - (void)loadObjects:(NSArray *)objects { @@ -322,7 +322,7 @@ - (void)objectLoader:(RKObjectLoader *)loader didLoadObjects:(NSArray *)objects { // TODO: Could not get the KVO to work without a boolean property... // TODO: Apply any sorting... - + if (self.sectionNameKeyPath) { NSArray *sectionedObjects = [objects sectionsGroupedByKeyPath:self.sectionNameKeyPath]; for (NSArray *sectionOfObjects in sectionedObjects) { diff --git a/Code/UI/RKTableViewCellMapping.h b/Code/UI/RKTableViewCellMapping.h index 4ea24a2c..573d0823 100644 --- a/Code/UI/RKTableViewCellMapping.h +++ b/Code/UI/RKTableViewCellMapping.h @@ -86,9 +86,9 @@ typedef void(^RKTableViewCellBlock)(UITableViewCell *cell); A Boolean value that determines whether the cell mapping manages basic cell attributes (accessoryType, selectionStyle, etc.) or defers to a Storyboard/XIB for defining basic cell attributes. - + Setting the accessoryType or selectionStyle will set the value to YES. - + **Default**: NO */ @property (nonatomic, assign) BOOL managesCellAttributes; @@ -203,7 +203,7 @@ typedef void(^RKTableViewCellBlock)(UITableViewCell *cell); /** Creates and returns an RKTableCellMapping instance configured with the default cell mappings. - + @return An RKTableCellMapping instance with default mappings applied. @see [RKTableCellMapping addDefaultMappings] */ diff --git a/Code/UI/RKTableViewCellMapping.m b/Code/UI/RKTableViewCellMapping.m index af79ad22..dd579c41 100644 --- a/Code/UI/RKTableViewCellMapping.m +++ b/Code/UI/RKTableViewCellMapping.m @@ -193,7 +193,7 @@ typedef void(^RKControlBlockActionBlock)(id sender); cell = [[[self.objectClass alloc] initWithStyle:self.style reuseIdentifier:self.reuseIdentifier] autorelease]; } - + if (self.managesCellAttributes) { cell.accessoryType = self.accessoryType; cell.selectionStyle = self.selectionStyle; diff --git a/Examples/RKCatalog/App/RKCatalogAppDelegate.m b/Examples/RKCatalog/App/RKCatalogAppDelegate.m index 00e7116d..2a327342 100644 --- a/Examples/RKCatalog/App/RKCatalogAppDelegate.m +++ b/Examples/RKCatalog/App/RKCatalogAppDelegate.m @@ -21,10 +21,10 @@ NSURL *gRKCatalogBaseURL = nil; // Add the navigation controller's view to the window and display. self.window.rootViewController = self.navigationController; [self.window makeKeyAndVisible]; - - + + gRKCatalogBaseURL = [[NSURL alloc] initWithString:@"http://rkcatalog.heroku.com"]; - + return YES; } diff --git a/Examples/RKCatalog/App/RootViewController.m b/Examples/RKCatalog/App/RootViewController.m index acfa75aa..33ee604f 100644 --- a/Examples/RKCatalog/App/RootViewController.m +++ b/Examples/RKCatalog/App/RootViewController.m @@ -13,7 +13,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - + _exampleTableItems = [[NSArray alloc] initWithObjects: @"RKAuthenticationExample", @"RKParamsExample", @@ -28,7 +28,7 @@ - (void)dealloc { [_exampleTableItems release]; - + [super dealloc]; } @@ -42,7 +42,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"RKCatalogCellIdentifier"; - + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease]; @@ -51,8 +51,8 @@ } NSString* exampleName = [_exampleTableItems objectAtIndex:indexPath.row]; - cell.textLabel.text = exampleName; - + cell.textLabel.text = exampleName; + return cell; } @@ -60,7 +60,7 @@ // Clear the singleton instances to isolate the examples [RKClient setSharedClient:nil]; [RKObjectManager setSharedManager:nil]; - + NSString* exampleName = [_exampleTableItems objectAtIndex:indexPath.row]; Class exampleClass = NSClassFromString(exampleName); UIViewController* exampleController = [[exampleClass alloc] initWithNibName:exampleName bundle:nil]; @@ -71,7 +71,7 @@ } [exampleController release]; } - + [tableView deselectRowAtIndexPath:indexPath animated:YES]; } diff --git a/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m b/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m index caf4e8f4..cde8d1a7 100644 --- a/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m +++ b/Examples/RKCatalog/Examples/RKAuthenticationExample/RKAuthenticationExample.m @@ -30,7 +30,7 @@ [authenticatedRequest cancel]; [authenticatedRequest release]; authenticatedRequest = nil; - + [super dealloc]; } @@ -46,7 +46,7 @@ newRequest.authenticationType = RKRequestAuthenticationTypeHTTP; newRequest.username = [usernameTextField text]; newRequest.password = [passwordTextField text]; - + self.authenticatedRequest = newRequest; } diff --git a/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m b/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m index 970fe050..2c89b017 100644 --- a/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m +++ b/Examples/RKCatalog/Examples/RKBackgroundRequestExample/RKBackgroundRequestExample.m @@ -21,13 +21,13 @@ RKClient* client = [RKClient clientWithBaseURL:gRKCatalogBaseURL]; [RKClient setSharedClient:client]; } - + return self; } - (void)dealloc { [[RKClient sharedClient].requestQueue cancelRequestsWithDelegate:self]; - + [super dealloc]; } @@ -40,7 +40,7 @@ } - (void)requestDidStartLoad:(RKRequest *)request { - _statusLabel.text = [NSString stringWithFormat:@"Sent request with background policy %d at %@", request.backgroundPolicy, [NSDate date]]; + _statusLabel.text = [NSString stringWithFormat:@"Sent request with background policy %d at %@", request.backgroundPolicy, [NSDate date]]; } - (void)requestDidTimeout:(RKRequest *)request { diff --git a/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m b/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m index b4e5cb14..5bdb5e11 100644 --- a/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m +++ b/Examples/RKCatalog/Examples/RKCoreDataExample/RKCoreDataExample.m @@ -37,7 +37,7 @@ RKObjectManager* manager = [RKObjectManager managerWithBaseURLString:@"http://restkit.org"]; manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"RKCoreDataExample.sqlite"]; [RKObjectManager setSharedManager:manager]; - + // Create some starter objects if the database is empty if ([Article count:nil] == 0) { for (int i = 1; i <= 5; i++) { @@ -45,12 +45,12 @@ article.articleID = [NSNumber numberWithInt:i]; article.title = [NSString stringWithFormat:@"Article %d", i]; article.body = @"This is the body"; - + // Persist the object store [manager.objectStore save:nil]; } } - + NSArray* items = [NSArray arrayWithObjects:@"All", @"Sorted", @"By Predicate", @"By ID", nil]; _segmentedControl = [[UISegmentedControl alloc] initWithItems:items]; _segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; @@ -58,7 +58,7 @@ [_segmentedControl addTarget:self action:@selector(updateTableView) forControlEvents:UIControlEventValueChanged]; _segmentedControl.selectedSegmentIndex = 0; } - + return self; } @@ -72,45 +72,45 @@ return 35; } -- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { +- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return _segmentedControl; } - (NSFetchRequest*)fetchRequestForSelectedSegment { NSFetchRequest* fetchRequest = [Article fetchRequest]; NSPredicate* predicate = nil; - + switch (_segmentedControl.selectedSegmentIndex) { // All objects case 0: // An empty fetch request will return all objects // Duplicates the functionality of [Article allObjects] break; - + // Sorted case 1:; NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:NO]; [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; break; - + // By Predicate case 2: // Duplicates functionality of calling [Article objectsWithPredicate:predicate]; predicate = [NSPredicate predicateWithFormat:@"title CONTAINS[c] %@", @"2"]; [fetchRequest setPredicate:predicate]; break; - + // By ID case 3: // Duplicates functionality of [Article findByAttribute:@"articleID" withValue:[NSNumber numberWithInt:3]]; predicate = [NSPredicate predicateWithFormat:@"%K = %d", @"articleID", 3]; [fetchRequest setPredicate:predicate]; break; - - default: + + default: break; } - + return fetchRequest; } @@ -134,11 +134,11 @@ if (nil == cell) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ArticleCell"] autorelease]; } - + Article* article = [_articles objectAtIndex:indexPath.row]; cell.textLabel.text = article.title; cell.detailTextLabel.text = article.body; - + return cell; } diff --git a/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m b/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m index ee7be0ad..c5e69b9a 100644 --- a/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m +++ b/Examples/RKCatalog/Examples/RKKeyValueMappingExample/RKKeyValueMappingExample.m @@ -53,13 +53,13 @@ if (self) { [RKObjectManager managerWithBaseURL:gRKCatalogBaseURL]; } - + return self; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - + RKObjectMapping* mapping = [RKObjectMapping mappingForClass:[SimpleAccount class]]; [mapping mapKeyPathsToAttributes: @"id", @"accountID", @@ -69,14 +69,14 @@ @"transactions.@avg.amount", @"averageTransactionAmount", @"transactions.@distinctUnionOfObjects.payee", @"distinctPayees", nil]; - + [[RKObjectManager sharedManager].mappingProvider setObjectMapping:mapping forResourcePathPattern:@"/RKKeyValueMappingExample"]; [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/RKKeyValueMappingExample" delegate:self]; } - (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects { SimpleAccount* account = [objects objectAtIndex:0]; - + NSString* info = [NSString stringWithFormat: @"The count is %@\n" @"The average transaction amount is %@\n" diff --git a/Examples/RKCatalog/Examples/RKParamsExample/RKParamsExample.m b/Examples/RKCatalog/Examples/RKParamsExample/RKParamsExample.m index 3b2dd1f8..f7e96d3b 100644 --- a/Examples/RKCatalog/Examples/RKParamsExample/RKParamsExample.m +++ b/Examples/RKCatalog/Examples/RKParamsExample/RKParamsExample.m @@ -16,7 +16,7 @@ @synthesize uploadButton = _uploadButton; @synthesize statusLabel = _statusLabel; -- (void)dealloc { +- (void)dealloc { [RKClient setSharedClient:nil]; [_client release]; [super dealloc]; @@ -26,23 +26,23 @@ _client = [[RKClient alloc] initWithBaseURL:gRKCatalogBaseURL]; } -- (IBAction)uploadButtonWasTouched:(id)sender { +- (IBAction)uploadButtonWasTouched:(id)sender { RKParams* params = [RKParams params]; - + // Attach the Image from Image View NSLog(@"Got image: %@", [_imageView image]); NSData* imageData = UIImagePNGRepresentation([_imageView image]); [params setData:imageData MIMEType:@"image/png" forParam:@"image1"]; - + // Attach an Image from the App Bundle UIImage* image = [UIImage imageNamed:@"RestKit.png"]; imageData = UIImagePNGRepresentation(image); [params setData:imageData MIMEType:@"image/png" forParam:@"image2"]; - + // Log info about the serialization NSLog(@"RKParams HTTPHeaderValueForContentType = %@", [params HTTPHeaderValueForContentType]); NSLog(@"RKParams HTTPHeaderValueForContentLength = %d", [params HTTPHeaderValueForContentLength]); - + // Send it for processing! [_client post:@"/RKParamsExample" params:params delegate:self]; } @@ -59,7 +59,7 @@ - (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response { _uploadButton.enabled = YES; [_activityIndicatorView stopAnimating]; - + if ([response isOK]) { _statusLabel.text = @"Upload Successful!"; _statusLabel.textColor = [UIColor greenColor]; @@ -73,7 +73,7 @@ _uploadButton.enabled = YES; [_activityIndicatorView stopAnimating]; _progressView.progress = 0.0; - + _statusLabel.text = [NSString stringWithFormat:@"Upload failed with error: %@", [error localizedDescription]]; _statusLabel.textColor = [UIColor redColor]; } diff --git a/Examples/RKCatalog/Examples/RKReachabilityExample/RKReachabilityExample.m b/Examples/RKCatalog/Examples/RKReachabilityExample/RKReachabilityExample.m index 7e05ba8c..c6fdceeb 100644 --- a/Examples/RKCatalog/Examples/RKReachabilityExample/RKReachabilityExample.m +++ b/Examples/RKCatalog/Examples/RKReachabilityExample/RKReachabilityExample.m @@ -28,13 +28,13 @@ name:RKReachabilityDidChangeNotification object:_observer]; } - + return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [_observer release]; + [_observer release]; [super dealloc]; } @@ -47,19 +47,19 @@ - (void)reachabilityChanged:(NSNotification *)notification { RKReachabilityObserver* observer = (RKReachabilityObserver *) [notification object]; - + RKLogCritical(@"Received reachability update: %@", observer); _flagsLabel.text = [NSString stringWithFormat:@"Host: %@ -> %@", observer.host, [observer reachabilityFlagsDescription]]; - + if ([observer isNetworkReachable]) { if ([observer isConnectionRequired]) { _statusLabel.text = @"Connection is available..."; _statusLabel.textColor = [UIColor yellowColor]; return; } - + _statusLabel.textColor = [UIColor greenColor]; - + if (RKReachabilityReachableViaWiFi == [observer networkStatus]) { _statusLabel.text = @"Online via WiFi"; } else if (RKReachabilityReachableViaWWAN == [observer networkStatus]) { diff --git a/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m b/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m index d737a378..d3a00623 100644 --- a/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m +++ b/Examples/RKCatalog/Examples/RKRelationshipMappingExample/RKRelationshipMappingExample.m @@ -21,21 +21,21 @@ RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:gRKCatalogBaseURL]; RKManagedObjectStore *objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"RKRelationshipMappingExample.sqlite"]; objectManager.objectStore = objectStore; - + RKManagedObjectMapping* taskMapping = [RKManagedObjectMapping mappingForClass:[Task class] inManagedObjectStore:objectStore]; taskMapping.primaryKeyAttribute = @"taskID"; [taskMapping mapKeyPath:@"id" toAttribute:@"taskID"]; [taskMapping mapKeyPath:@"name" toAttribute:@"name"]; [taskMapping mapKeyPath:@"assigned_user_id" toAttribute:@"assignedUserID"]; [objectManager.mappingProvider setMapping:taskMapping forKeyPath:@"task"]; - + RKManagedObjectMapping* userMapping = [RKManagedObjectMapping mappingForClass:[User class] inManagedObjectStore:objectStore]; userMapping.primaryKeyAttribute = @"userID"; [userMapping mapAttributes:@"name", @"email", nil]; [userMapping mapKeyPath:@"id" toAttribute:@"userID"]; [userMapping mapRelationship:@"tasks" withMapping:taskMapping]; [objectManager.mappingProvider setMapping:userMapping forKeyPath:@"user"]; - + // Hydrate the assignedUser association via primary key [taskMapping hasOne:@"assignedUser" withMapping:userMapping]; [taskMapping connectRelationship:@"assignedUser" withObjectForPrimaryKeyAttribute:@"assignedUserID"]; @@ -48,7 +48,7 @@ [projectMapping mapRelationship:@"tasks" withMapping:taskMapping]; [objectManager.mappingProvider setMapping:projectMapping forKeyPath:@"project"]; } - + return self; } @@ -59,9 +59,9 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - + self.title = @"Task List"; - + [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/RKRelationshipMappingExample" delegate:self]; } @@ -93,7 +93,7 @@ return [[[_objects objectAtIndex:indexPath.row] tasks] count]; } } - + return 0; } @@ -101,7 +101,7 @@ UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, 150, 100)]; label.backgroundColor = [UIColor clearColor]; label.font = [UIFont boldSystemFontOfSize:18]; - + if (section == 0) { label.text = @"Projects"; } else if (section == 1) { @@ -118,27 +118,27 @@ if (indexPath.section == 1) { return nil; } - + return indexPath; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [_selectedProject release]; _selectedProject = [[_objects objectAtIndex:indexPath.row] retain]; - - [self.tableView reloadData]; + + [self.tableView reloadData]; UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; - + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } - + if (indexPath.section == 0) { Project* project = (Project*) [_objects objectAtIndex:indexPath.row]; cell.accessoryType = UITableViewCellAccessoryNone; @@ -150,7 +150,7 @@ cell.textLabel.text = [NSString stringWithFormat:@"%@", task.name]; cell.detailTextLabel.text = [NSString stringWithFormat:@"Assigned to: %@", task.assignedUser.name]; } - + return cell; } diff --git a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h index fefc9c45..5f61107d 100644 --- a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h +++ b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.h @@ -15,5 +15,5 @@ - (IBAction)sendRequest; - (IBAction)queueRequests; - + @end diff --git a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m index 5a9db7ed..941193a8 100644 --- a/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m +++ b/Examples/RKCatalog/Examples/RKRequestQueueExample/RKRequestQueueExample.m @@ -19,12 +19,12 @@ if (self) { RKClient* client = [RKClient clientWithBaseURL:gRKCatalogBaseURL]; [RKClient setSharedClient:client]; - + // Ask RestKit to spin the network activity indicator for us client.requestQueue.delegate = self; client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; } - + return self; } @@ -34,7 +34,7 @@ [requestQueue cancelAllRequests]; [requestQueue release]; requestQueue = nil; - + [super dealloc]; } @@ -56,31 +56,31 @@ queue.delegate = self; queue.concurrentRequestsLimit = 1; queue.showsNetworkActivityIndicatorWhenBusy = YES; - + // Queue up 4 requests RKRequest *request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; request.delegate = self; [queue addRequest:request]; - + request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; request.delegate = self; [queue addRequest:request]; - + request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; request.delegate = self; [queue addRequest:request]; - + request = [[RKClient sharedClient] requestWithResourcePath:@"/RKRequestQueueExample"]; request.delegate = self; [queue addRequest:request]; - + // Start processing! [queue start]; self.requestQueue = queue; } - (void)requestQueue:(RKRequestQueue *)queue didSendRequest:(RKRequest *)request { - statusLabel.text = [NSString stringWithFormat:@"RKRequestQueue %@ is current loading %d of %d requests", + statusLabel.text = [NSString stringWithFormat:@"RKRequestQueue %@ is current loading %d of %d requests", queue, [queue loadingCount], [queue count]]; } diff --git a/Examples/RKTwitter/Classes/RKTStatus.h b/Examples/RKTwitter/Classes/RKTStatus.h index fff2c03d..750a01ea 100644 --- a/Examples/RKTwitter/Classes/RKTStatus.h +++ b/Examples/RKTwitter/Classes/RKTStatus.h @@ -14,7 +14,7 @@ NSString* _text; NSString* _urlString; NSString* _inReplyToScreenName; - NSNumber* _isFavorited; + NSNumber* _isFavorited; RKTUser* _user; } diff --git a/Examples/RKTwitter/Classes/RKTStatus.m b/Examples/RKTwitter/Classes/RKTStatus.m index d1fff951..c4dd0f86 100644 --- a/Examples/RKTwitter/Classes/RKTStatus.m +++ b/Examples/RKTwitter/Classes/RKTStatus.m @@ -15,7 +15,7 @@ @synthesize text = _text; @synthesize urlString = _urlString; @synthesize inReplyToScreenName = _inReplyToScreenName; -@synthesize isFavorited = _isFavorited; +@synthesize isFavorited = _isFavorited; @synthesize user = _user; - (NSString*)description { @@ -29,7 +29,7 @@ [_urlString release]; [_inReplyToScreenName release]; [_user release]; - + [super dealloc]; } diff --git a/Examples/RKTwitter/Classes/RKTUser.m b/Examples/RKTwitter/Classes/RKTUser.m index cf74eca9..8ea569fb 100644 --- a/Examples/RKTwitter/Classes/RKTUser.m +++ b/Examples/RKTwitter/Classes/RKTUser.m @@ -18,7 +18,7 @@ [_userID release]; [_name release]; [_screenName release]; - + [super dealloc]; } diff --git a/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m b/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m index 835966dd..84a6bd3c 100644 --- a/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m +++ b/Examples/RKTwitter/Classes/RKTwitterAppDelegate.m @@ -20,19 +20,19 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RKLogConfigureByName("RestKit/Network*", RKLogLevelTrace); RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace); - + // Initialize RestKit RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@"http://twitter.com"]; - + // Enable automatic network activity indicator management objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; - + // Setup our object mappings RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[RKTUser class]]; [userMapping mapKeyPath:@"id" toAttribute:@"userID"]; [userMapping mapKeyPath:@"screen_name" toAttribute:@"screenName"]; [userMapping mapAttributes:@"name", nil]; - + RKObjectMapping* statusMapping = [RKObjectMapping mappingForClass:[RKTStatus class]]; [statusMapping mapKeyPathsToAttributes:@"id", @"statusID", @"created_at", @"createdAt", @@ -42,25 +42,25 @@ @"favorited", @"isFavorited", nil]; [statusMapping mapRelationship:@"user" withMapping:userMapping]; - + // Update date format so that we can parse Twitter dates properly // Wed Sep 29 15:31:08 +0000 2010 [RKObjectMapping addDefaultDateFormatterForString:@"E MMM d HH:mm:ss Z y" inTimeZone:nil]; - + // Uncomment these lines to use XML, comment it to use JSON // objectManager.acceptMIMEType = RKMIMETypeXML; // statusMapping.rootKeyPath = @"statuses.status"; - + // Register our mappings with the provider using a resource path pattern [objectManager.mappingProvider setObjectMapping:statusMapping forResourcePathPattern:@"/status/user_timeline/:username"]; - + // Create Window and View Controllers RKTwitterViewController* viewController = [[[RKTwitterViewController alloc] initWithNibName:nil bundle:nil] autorelease]; UINavigationController* controller = [[UINavigationController alloc] initWithRootViewController:viewController]; UIWindow* window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; [window addSubview:controller.view]; [window makeKeyAndVisible]; - + return YES; } diff --git a/Examples/RKTwitter/Classes/RKTwitterViewController.m b/Examples/RKTwitter/Classes/RKTwitterViewController.m index 464a3bb0..9929afd2 100644 --- a/Examples/RKTwitter/Classes/RKTwitterViewController.m +++ b/Examples/RKTwitter/Classes/RKTwitterViewController.m @@ -16,7 +16,7 @@ @implementation RKTwitterViewController - (void)loadTimeline { - // Load the object model via RestKit + // Load the object model via RestKit RKObjectManager* objectManager = [RKObjectManager sharedManager]; objectManager.client.baseURL = [RKURL URLWithString:@"http://www.twitter.com"]; [objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self]; @@ -24,25 +24,25 @@ - (void)loadView { [super loadView]; - - // Setup View and Table View + + // Setup View and Table View self.title = @"RestKit Tweets"; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent; self.navigationController.navigationBar.tintColor = [UIColor blackColor]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(loadTimeline)] autorelease]; - + UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BG.png"]] autorelease]; imageView.frame = CGRectOffset(imageView.frame, 0, -64); - + [self.view insertSubview:imageView atIndex:0]; - + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStylePlain]; _tableView.dataSource = self; - _tableView.delegate = self; + _tableView.delegate = self; _tableView.backgroundColor = [UIColor clearColor]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.view addSubview:_tableView]; - + [self loadTimeline]; } @@ -59,7 +59,7 @@ } - (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects { - NSLog(@"Loaded statuses: %@", objects); + NSLog(@"Loaded statuses: %@", objects); [_statuses release]; _statuses = [objects retain]; [_tableView reloadData]; diff --git a/Examples/RKTwitter/main.m b/Examples/RKTwitter/main.m index f2eff9c9..68a63176 100644 --- a/Examples/RKTwitter/main.m +++ b/Examples/RKTwitter/main.m @@ -9,7 +9,7 @@ #import int main(int argc, char *argv[]) { - + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @"RKTwitterAppDelegate"); [pool release]; diff --git a/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m b/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m index 7221fdf5..12446cf6 100644 --- a/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m +++ b/Examples/RKTwitterCoreData/Classes/RKTwitterAppDelegate.m @@ -20,10 +20,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Initialize RestKit RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@"http://twitter.com"]; - + // Enable automatic network activity indicator management objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; - + // Initialize object store #ifdef RESTKIT_GENERATE_SEED_DB NSString *seedDatabaseName = nil; @@ -34,8 +34,8 @@ #endif objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:databaseName usingSeedDatabaseName:seedDatabaseName managedObjectModel:nil delegate:self]; - - // Setup our object mappings + + // Setup our object mappings /*! Mapping by entity. Here we are configuring a mapping by targetting a Core Data entity with a specific name. This allows us to map back Twitter user objects directly onto NSManagedObject instances -- @@ -46,7 +46,7 @@ [userMapping mapKeyPath:@"id" toAttribute:@"userID"]; [userMapping mapKeyPath:@"screen_name" toAttribute:@"screenName"]; [userMapping mapAttributes:@"name", nil]; - + /*! Map to a target object class -- just as you would for a non-persistent class. The entity is resolved for you using the Active Record pattern where the class name corresponds to the entity name within Core Data. @@ -59,21 +59,21 @@ @"text", @"text", @"url", @"urlString", @"in_reply_to_screen_name", @"inReplyToScreenName", - @"favorited", @"isFavorited", + @"favorited", @"isFavorited", nil]; [statusMapping mapRelationship:@"user" withMapping:userMapping]; - + // Update date format so that we can parse Twitter dates properly // Wed Sep 29 15:31:08 +0000 2010 [RKObjectMapping addDefaultDateFormatterForString:@"E MMM d HH:mm:ss Z y" inTimeZone:nil]; - + // Register our mappings with the provider [objectManager.mappingProvider setObjectMapping:statusMapping forResourcePathPattern:@"/status/user_timeline/:username"]; - + // Uncomment this to use XML, comment it to use JSON // objectManager.acceptMIMEType = RKMIMETypeXML; // [objectManager.mappingProvider setMapping:statusMapping forKeyPath:@"statuses.status"]; - + // Database seeding is configured as a copied target of the main application. There are only two differences // between the main application target and the 'Generate Seed Database' target: // 1) RESTKIT_GENERATE_SEED_DB is defined in the 'Preprocessor Macros' section of the build setting for the target @@ -84,20 +84,20 @@ RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelInfo); RKLogConfigureByName("RestKit/CoreData", RKLogLevelTrace); RKManagedObjectSeeder* seeder = [RKManagedObjectSeeder objectSeederWithObjectManager:objectManager]; - + // Seed the database with instances of RKTStatus from a snapshot of the RestKit Twitter timeline [seeder seedObjectsFromFile:@"restkit.json" withObjectMapping:statusMapping]; - + // Seed the database with RKTUser objects. The class will be inferred via element registration [seeder seedObjectsFromFiles:@"users.json", nil]; - + // Finalize the seeding operation and output a helpful informational message [seeder finalizeSeedingAndExit]; - + // NOTE: If all of your mapped objects use keyPath -> objectMapping registration, you can perform seeding in one line of code: // [RKManagedObjectSeeder generateSeedDatabaseWithObjectManager:objectManager fromFiles:@"users.json", nil]; #endif - + // Create Window and View Controllers RKTwitterViewController* viewController = [[[RKTwitterViewController alloc] initWithNibName:nil bundle:nil] autorelease]; UINavigationController* controller = [[UINavigationController alloc] initWithRootViewController:viewController]; diff --git a/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m b/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m index f0524c4c..95f15e02 100644 --- a/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m +++ b/Examples/RKTwitterCoreData/Classes/RKTwitterViewController.m @@ -13,25 +13,25 @@ - (void)loadView { [super loadView]; - - // Setup View and Table View + + // Setup View and Table View self.title = @"RestKit Tweets"; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent; self.navigationController.navigationBar.tintColor = [UIColor blackColor]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(reloadButtonWasPressed:)] autorelease]; - + UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BG.png"]] autorelease]; imageView.frame = CGRectOffset(imageView.frame, 0, -64); - + [self.view insertSubview:imageView atIndex:0]; - + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStylePlain]; _tableView.dataSource = self; - _tableView.delegate = self; + _tableView.delegate = self; _tableView.backgroundColor = [UIColor clearColor]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.view addSubview:_tableView]; - + // Load statuses from core data [self loadObjectsFromDataStore]; } @@ -51,7 +51,7 @@ } - (void)loadData { - // Load the object model via RestKit + // Load the object model via RestKit RKObjectManager* objectManager = [RKObjectManager sharedManager]; [objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" delegate:self]; } @@ -72,9 +72,9 @@ } - (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error { - UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error" - message:[error localizedDescription] - delegate:nil + UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error" + message:[error localizedDescription] + delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [alert show]; NSLog(@"Hit error: %@", error); diff --git a/Examples/RKTwitterCoreData/main.m b/Examples/RKTwitterCoreData/main.m index f2eff9c9..68a63176 100644 --- a/Examples/RKTwitterCoreData/main.m +++ b/Examples/RKTwitterCoreData/main.m @@ -9,7 +9,7 @@ #import int main(int argc, char *argv[]) { - + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @"RKTwitterAppDelegate"); [pool release]; diff --git a/Examples/RKTwitterCoreData/restkit.json b/Examples/RKTwitterCoreData/restkit.json index fc83ef67..ae03977e 100644 --- a/Examples/RKTwitterCoreData/restkit.json +++ b/Examples/RKTwitterCoreData/restkit.json @@ -1 +1 @@ -[{"in_reply_to_status_id_str":"42716229147967491","text":"@JustJenFelice Be sure to join the Google Group and reach out if you need any support!","contributors":null,"retweeted":false,"in_reply_to_user_id_str":"7426812","retweet_count":0,"id_str":"44029179364253696","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Sat Mar 05 13:39:09 +0000 2011","place":null,"in_reply_to_status_id":42716229147967491,"coordinates":null,"favorited":false,"user":{"following":true,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","is_translator":false,"show_all_inline_media":false,"geo_enabled":false,"time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","follow_request_sent":false,"profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","profile_background_tile":true,"location":"","contributors_enabled":false,"statuses_count":136,"lang":"en","verified":false,"notifications":false,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","listed_count":5,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":44029179364253696,"in_reply_to_screen_name":"JustJenFelice","in_reply_to_user_id":7426812},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/h180ef Blake Watters - Added new initializer for starting from a seed database. Need to finish cleaning up API an...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"43646264163844096","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Mar 04 12:17:34 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":43646264163844096,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fa2Law Blake Watters - Silenced a couple of Xcode 4 warning. Don't send a serialization with a GET request by def...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"43074105142026241","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Mar 02 22:24:01 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":43074105142026241,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fBWUre Jeremy Ellison - update projects to link libxml2 (verified working). Update readme to mention changes","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660583622975488","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:50 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660583622975488,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/ho92wG Jeremy Ellison - Working XML Support. Twitter example working (XML and JSON)","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660582243049472","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:50 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660582243049472,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/dPAmx6 Jeremy Ellison - make RKXMLParser support RKParser protocol","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660580796022784","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:49 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660580796022784,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/gfGynL Jeremy Ellison - add RKXMLParser","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660579399307264","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:49 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660579399307264,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fVQI5Q Blake Watters - Fixed crash during dealloc of RKClient due to initialization of baseURL observer using a b...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"41221933492076544","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Feb 25 19:44:09 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":41221933492076544,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/hJtNCV Jeremy Ellison - Merge branch 'gtio-mapping-updates' of github.com:twotoasters\/RestKit into gtio-mapping-u...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"41221089635864576","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Feb 25 19:40:48 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":41221089635864576,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fZYIyg Jeremy Ellison - Add did cancel delegate","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"41221088297877504","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Feb 25 19:40:47 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":41221088297877504,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":"36907142883573761","text":"@chrisabruce New Xcode 4 specific install instructions are now included. Should be fully compatible with Xcode 3 and 4 now","contributors":null,"retweeted":false,"in_reply_to_user_id_str":"104933758","retweet_count":0,"id_str":"37909707221897216","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:22:33 +0000 2011","place":null,"in_reply_to_status_id":36907142883573761,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37909707221897216,"in_reply_to_screen_name":"chrisabruce","in_reply_to_user_id":104933758},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/gUIrfk Blake Watters - Updates to quick start section","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37906943557369856","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:11:34 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37906943557369856,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/eabC8R Blake Watters - Trying to get formatting right for Github flavored markdown","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37905652214923264","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:06:26 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37905652214923264,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/g8b9VX Blake Watters - Merge branch 'master' of github.com:twotoasters\/RestKit\n\nConflicts:\n\tRestKit.xcodeproj\/pro...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37905228544217089","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:04:45 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37905228544217089,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/f1DpxP Blake Watters - Xcode 4 specific install instructions","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37905226803589120","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:04:44 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37905226803589120,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/dNaG1Z Blake Watters - Fix for whitespace. Really annoyed at Xcode 4","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37713900346548224","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 03:24:29 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37713900346548224,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/g72vPt Blake Watters - trying to get the project to work with various Xcode output path settings","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37697830005112832","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 02:20:37 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37697830005112832,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"Xcode 4 build environment changes are very frustrating.","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37686673852604416","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 01:36:17 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37686673852604416,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/dPjF4h Blake Watters - More Xcode 4 crap","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37684000310951936","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 01:25:40 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37684000310951936,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":"36907142883573761","text":"@chrisabruce Xcode 4 fixes were recently pushed","contributors":null,"retweeted":false,"in_reply_to_user_id_str":"104933758","retweet_count":0,"id_str":"37676602791821312","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 00:56:16 +0000 2011","place":null,"in_reply_to_status_id":36907142883573761,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37676602791821312,"in_reply_to_screen_name":"chrisabruce","in_reply_to_user_id":104933758}] \ No newline at end of file +[{"in_reply_to_status_id_str":"42716229147967491","text":"@JustJenFelice Be sure to join the Google Group and reach out if you need any support!","contributors":null,"retweeted":false,"in_reply_to_user_id_str":"7426812","retweet_count":0,"id_str":"44029179364253696","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Sat Mar 05 13:39:09 +0000 2011","place":null,"in_reply_to_status_id":42716229147967491,"coordinates":null,"favorited":false,"user":{"following":true,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","is_translator":false,"show_all_inline_media":false,"geo_enabled":false,"time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","follow_request_sent":false,"profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","profile_background_tile":true,"location":"","contributors_enabled":false,"statuses_count":136,"lang":"en","verified":false,"notifications":false,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","listed_count":5,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":44029179364253696,"in_reply_to_screen_name":"JustJenFelice","in_reply_to_user_id":7426812},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/h180ef Blake Watters - Added new initializer for starting from a seed database. Need to finish cleaning up API an...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"43646264163844096","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Mar 04 12:17:34 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":43646264163844096,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fa2Law Blake Watters - Silenced a couple of Xcode 4 warning. Don't send a serialization with a GET request by def...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"43074105142026241","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Mar 02 22:24:01 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":43074105142026241,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fBWUre Jeremy Ellison - update projects to link libxml2 (verified working). Update readme to mention changes","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660583622975488","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:50 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660583622975488,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/ho92wG Jeremy Ellison - Working XML Support. Twitter example working (XML and JSON)","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660582243049472","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:50 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660582243049472,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/dPAmx6 Jeremy Ellison - make RKXMLParser support RKParser protocol","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660580796022784","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:49 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660580796022784,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/gfGynL Jeremy Ellison - add RKXMLParser","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"42660579399307264","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Tue Mar 01 19:00:49 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":42660579399307264,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fVQI5Q Blake Watters - Fixed crash during dealloc of RKClient due to initialization of baseURL observer using a b...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"41221933492076544","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Feb 25 19:44:09 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":41221933492076544,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/hJtNCV Jeremy Ellison - Merge branch 'gtio-mapping-updates' of github.com:twotoasters\/RestKit into gtio-mapping-u...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"41221089635864576","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Feb 25 19:40:48 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":41221089635864576,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/fZYIyg Jeremy Ellison - Add did cancel delegate","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"41221088297877504","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Fri Feb 25 19:40:47 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":41221088297877504,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":"36907142883573761","text":"@chrisabruce New Xcode 4 specific install instructions are now included. Should be fully compatible with Xcode 3 and 4 now","contributors":null,"retweeted":false,"in_reply_to_user_id_str":"104933758","retweet_count":0,"id_str":"37909707221897216","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:22:33 +0000 2011","place":null,"in_reply_to_status_id":36907142883573761,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37909707221897216,"in_reply_to_screen_name":"chrisabruce","in_reply_to_user_id":104933758},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/gUIrfk Blake Watters - Updates to quick start section","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37906943557369856","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:11:34 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37906943557369856,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/eabC8R Blake Watters - Trying to get formatting right for Github flavored markdown","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37905652214923264","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:06:26 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37905652214923264,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/g8b9VX Blake Watters - Merge branch 'master' of github.com:twotoasters\/RestKit\n\nConflicts:\n\tRestKit.xcodeproj\/pro...","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37905228544217089","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:04:45 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37905228544217089,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/f1DpxP Blake Watters - Xcode 4 specific install instructions","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37905226803589120","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 16:04:44 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37905226803589120,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/dNaG1Z Blake Watters - Fix for whitespace. Really annoyed at Xcode 4","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37713900346548224","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 03:24:29 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37713900346548224,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/g72vPt Blake Watters - trying to get the project to work with various Xcode output path settings","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37697830005112832","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 02:20:37 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37697830005112832,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"Xcode 4 build environment changes are very frustrating.","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37686673852604416","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 01:36:17 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37686673852604416,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":null,"text":"[RestKit] http:\/\/bit.ly\/dPjF4h Blake Watters - More Xcode 4 crap","contributors":null,"retweeted":false,"in_reply_to_user_id_str":null,"retweet_count":0,"id_str":"37684000310951936","source":"\u003Ca href=\"http:\/\/github.com\" rel=\"nofollow\"\u003EGitHub Service Hooks\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 01:25:40 +0000 2011","place":null,"in_reply_to_status_id":null,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37684000310951936,"in_reply_to_screen_name":null,"in_reply_to_user_id":null},{"in_reply_to_status_id_str":"36907142883573761","text":"@chrisabruce Xcode 4 fixes were recently pushed","contributors":null,"retweeted":false,"in_reply_to_user_id_str":"104933758","retweet_count":0,"id_str":"37676602791821312","source":"\u003Ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003ETweetie for Mac\u003C\/a\u003E","geo":null,"truncated":false,"created_at":"Wed Feb 16 00:56:16 +0000 2011","place":null,"in_reply_to_status_id":36907142883573761,"coordinates":null,"favorited":false,"user":{"is_translator":false,"contributors_enabled":false,"following":null,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/181380497\/twitter-bg.png","favourites_count":0,"follow_request_sent":null,"statuses_count":136,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1190091434\/restkit-twitter-logo_normal.png","description":"RestKit is a framework for consuming and modeling restful web resources on OS X and iOS (iPhone, iPad & iPod Touch) - Built by @twotoasters","time_zone":null,"friends_count":87,"profile_text_color":"333333","url":"http:\/\/restkit.org","profile_sidebar_fill_color":"efefef","screen_name":"RestKit","id_str":"208727870","geo_enabled":false,"profile_background_tile":true,"location":"","listed_count":5,"lang":"en","verified":false,"notifications":null,"created_at":"Wed Oct 27 20:46:12 +0000 2010","profile_link_color":"009999","show_all_inline_media":false,"profile_sidebar_border_color":"eeeeee","protected":false,"followers_count":122,"name":"RestKit","profile_use_background_image":true,"id":208727870,"utc_offset":null,"profile_background_color":"131516"},"id":37676602791821312,"in_reply_to_screen_name":"chrisabruce","in_reply_to_user_id":104933758}] diff --git a/Examples/RKTwitterCoreData/users.json b/Examples/RKTwitterCoreData/users.json index fa42a9c3..550fd6f2 100644 --- a/Examples/RKTwitterCoreData/users.json +++ b/Examples/RKTwitterCoreData/users.json @@ -4,4 +4,4 @@ "name": "Blake Watters", "screen_name": "Blake Watters" } -}] \ No newline at end of file +}] diff --git a/Examples/RestKit CLI/RestKit CLI/main.m b/Examples/RestKit CLI/RestKit CLI/main.m index cc28242f..b3ea0cf1 100644 --- a/Examples/RestKit CLI/RestKit CLI/main.m +++ b/Examples/RestKit CLI/RestKit CLI/main.m @@ -14,7 +14,7 @@ int main (int argc, const char * argv[]) @autoreleasepool { RKLogConfigureByName("App", RKLogLevelTrace); - + // Validate arguments if (argc < 2) { printf("usage: %s path/to/file [keyPath]\n", argv[0]); @@ -22,11 +22,11 @@ int main (int argc, const char * argv[]) "If keyPath is provided it will be evaluated against the payload and the result printed.\n"); return 0; } - - NSString *filePathOrURL = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding]; + + NSString *filePathOrURL = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding]; NSURL *URL = nil; - NSString *keyPath = nil; - + NSString *keyPath = nil; + if ([filePathOrURL rangeOfString:@"://"].length == 0) { // Local file URL = [NSURL fileURLWithPath:filePathOrURL]; @@ -35,14 +35,14 @@ int main (int argc, const char * argv[]) URL = [NSURL URLWithString:filePathOrURL]; } if (argc == 3) keyPath = [NSString stringWithCString:argv[2] encoding:NSUTF8StringEncoding]; - + NSError *error = nil; NSString *payload = [NSString stringWithContentsOfURL:URL encoding:NSUTF8StringEncoding error:&error]; if (!payload) { RKLogError(@"Failed to read file at path %@: %@", URL, error); return 0; } - + NSString *MIMEType = [[URL absoluteString] MIMETypeForPathExtension]; RKLogInfo(@"Parsing %@ using MIME Type: %@", URL, MIMEType); id parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:MIMEType]; @@ -53,8 +53,8 @@ int main (int argc, const char * argv[]) return 0; } RKLogInfo(@"Parsed data => %@", parsedData); - if (keyPath) RKLogInfo(@"valueForKeyPath:@\"%@\" => %@", keyPath, [parsedData valueForKeyPath:keyPath]); + if (keyPath) RKLogInfo(@"valueForKeyPath:@\"%@\" => %@", keyPath, [parsedData valueForKeyPath:keyPath]); } - + return 0; } diff --git a/Tests/Application/UI/RKFetchedResultsTableControllerTest.m b/Tests/Application/UI/RKFetchedResultsTableControllerTest.m index 65dc7654..3a035d2f 100644 --- a/Tests/Application/UI/RKFetchedResultsTableControllerTest.m +++ b/Tests/Application/UI/RKFetchedResultsTableControllerTest.m @@ -74,7 +74,7 @@ RKObjectManager* objectManager = [RKTestFactory objectManager]; [objectManager.mappingProvider setMapping:humanMapping forKeyPath:@"human"]; objectManager.objectStore = store; - + [objectManager.mappingProvider setObjectMapping:humanMapping forResourcePathPattern:@"/JSON/humans/all\\.json" withFetchRequestBlock:^NSFetchRequest *(NSString *resourcePath) { return [RKHuman requestAllSortedBy:@"name" ascending:YES]; }]; diff --git a/Tests/Application/UI/RKTableControllerTest.m b/Tests/Application/UI/RKTableControllerTest.m index 2e0518d0..81a6ad72 100644 --- a/Tests/Application/UI/RKTableControllerTest.m +++ b/Tests/Application/UI/RKTableControllerTest.m @@ -59,7 +59,7 @@ if ([[NSDate date] timeIntervalSinceDate:startDate] > self.timeout) { NSLog(@"%@: Timed out!!!", self); _awaitingResponse = NO; - [NSException raise:nil format:@"*** Operation timed out after %f seconds...", self.timeout]; + [NSException raise:nil format:@"*** Operation timed out after %f seconds...", self.timeout]; } } } @@ -1663,7 +1663,7 @@ cellMapping.titleForDeleteButtonForObjectAtIndexPath = ^ NSString*(UITableViewCell* cell, id object, NSIndexPath* indexPath) { return deleteTitle; }; - }]; + }]; [tableController loadTableItems:[NSArray arrayWithObject:tableItem] withMapping:mapping]; NSString* delegateTitle = [tableController tableView:tableController.tableView titleForDeleteConfirmationButtonForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; @@ -1679,7 +1679,7 @@ cellMapping.editingStyleForObjectAtIndexPath = ^ UITableViewCellEditingStyle(UITableViewCell* cell, id object, NSIndexPath* indexPath) { return UITableViewCellEditingStyleInsert; }; - }]; + }]; [tableController loadTableItems:[NSArray arrayWithObject:tableItem] withMapping:mapping]; UITableViewCellEditingStyle delegateStyle = [tableController tableView:tableController.tableView editingStyleForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; @@ -1724,7 +1724,7 @@ tableController.tableView.rowHeight = 55; RKTableItem* tableItem = [RKTableItem tableItem]; [tableController loadTableItems:[NSArray arrayWithObject:tableItem] withMapping:[RKTableViewCellMapping cellMappingUsingBlock:^(RKTableViewCellMapping* cellMapping) { - cellMapping.rowHeight = 200; + cellMapping.rowHeight = 200; }]]; CGFloat height = [tableController tableView:tableController.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; assertThatFloat(height, is(equalToFloat(200))); diff --git a/Tests/Fixtures/JSON/ArrayOfNestedDictionaries.json b/Tests/Fixtures/JSON/ArrayOfNestedDictionaries.json index 1d85aad6..ded2caf2 100644 --- a/Tests/Fixtures/JSON/ArrayOfNestedDictionaries.json +++ b/Tests/Fixtures/JSON/ArrayOfNestedDictionaries.json @@ -26,4 +26,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/ArrayOfResults.json b/Tests/Fixtures/JSON/ArrayOfResults.json index b7f67129..2af487cb 100644 --- a/Tests/Fixtures/JSON/ArrayOfResults.json +++ b/Tests/Fixtures/JSON/ArrayOfResults.json @@ -12,4 +12,4 @@ "photo_url": "1308634984.jpg" } ] -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/ConnectingParents.json b/Tests/Fixtures/JSON/ConnectingParents.json index 3945fe04..4b78cfe2 100644 --- a/Tests/Fixtures/JSON/ConnectingParents.json +++ b/Tests/Fixtures/JSON/ConnectingParents.json @@ -9,4 +9,4 @@ "parentID": 1 } ] -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/Dynamic/boy.json b/Tests/Fixtures/JSON/Dynamic/boy.json index 9cac23c9..df95b9e1 100644 --- a/Tests/Fixtures/JSON/Dynamic/boy.json +++ b/Tests/Fixtures/JSON/Dynamic/boy.json @@ -1 +1 @@ -{ "name": "Blake Watters", "type": "Boy", "numeric_type": 1 } \ No newline at end of file +{ "name": "Blake Watters", "type": "Boy", "numeric_type": 1 } diff --git a/Tests/Fixtures/JSON/Dynamic/child.json b/Tests/Fixtures/JSON/Dynamic/child.json index bb11b910..1a85ebcc 100644 --- a/Tests/Fixtures/JSON/Dynamic/child.json +++ b/Tests/Fixtures/JSON/Dynamic/child.json @@ -1 +1 @@ -{ "name": "Gargamel", "type": "Child", "id": 2 } \ No newline at end of file +{ "name": "Gargamel", "type": "Child", "id": 2 } diff --git a/Tests/Fixtures/JSON/Dynamic/friends.json b/Tests/Fixtures/JSON/Dynamic/friends.json index 83debc98..0f1f64fa 100644 --- a/Tests/Fixtures/JSON/Dynamic/friends.json +++ b/Tests/Fixtures/JSON/Dynamic/friends.json @@ -11,4 +11,4 @@ "type": "Girl" } ] -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/Dynamic/girl.json b/Tests/Fixtures/JSON/Dynamic/girl.json index b4d2ab3d..db10e7cf 100644 --- a/Tests/Fixtures/JSON/Dynamic/girl.json +++ b/Tests/Fixtures/JSON/Dynamic/girl.json @@ -1 +1 @@ -{ "name": "Sarah", "type": "Girl", "numeric_type": 0 } \ No newline at end of file +{ "name": "Sarah", "type": "Girl", "numeric_type": 0 } diff --git a/Tests/Fixtures/JSON/Dynamic/mixed.json b/Tests/Fixtures/JSON/Dynamic/mixed.json index 51dfb6f3..649e333a 100644 --- a/Tests/Fixtures/JSON/Dynamic/mixed.json +++ b/Tests/Fixtures/JSON/Dynamic/mixed.json @@ -1,2 +1,2 @@ [ { "name": "Blake Watters", "type": "Boy" }, - { "name": "Sarah", "type": "Girl" } ] \ No newline at end of file + { "name": "Sarah", "type": "Girl" } ] diff --git a/Tests/Fixtures/JSON/Dynamic/parent.json b/Tests/Fixtures/JSON/Dynamic/parent.json index 612a7f18..6c83335c 100644 --- a/Tests/Fixtures/JSON/Dynamic/parent.json +++ b/Tests/Fixtures/JSON/Dynamic/parent.json @@ -1 +1 @@ -{ "name": "Dan", "type": "Parent", "age": 33, "id": 1 } \ No newline at end of file +{ "name": "Dan", "type": "Parent", "age": 33, "id": 1 } diff --git a/Tests/Fixtures/JSON/DynamicKeys.json b/Tests/Fixtures/JSON/DynamicKeys.json index 6b944852..50c6df0b 100644 --- a/Tests/Fixtures/JSON/DynamicKeys.json +++ b/Tests/Fixtures/JSON/DynamicKeys.json @@ -9,4 +9,4 @@ "website": "http://www.twotoasters.com/" } } -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/DynamicKeysWithNestedRelationship.json b/Tests/Fixtures/JSON/DynamicKeysWithNestedRelationship.json index cd8e1088..e69f381d 100644 --- a/Tests/Fixtures/JSON/DynamicKeysWithNestedRelationship.json +++ b/Tests/Fixtures/JSON/DynamicKeysWithNestedRelationship.json @@ -30,4 +30,4 @@ } } ] -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/DynamicKeysWithRelationship.json b/Tests/Fixtures/JSON/DynamicKeysWithRelationship.json index f5a8a9f1..7ae1fe6d 100644 --- a/Tests/Fixtures/JSON/DynamicKeysWithRelationship.json +++ b/Tests/Fixtures/JSON/DynamicKeysWithRelationship.json @@ -13,4 +13,4 @@ } } } -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/NakedEvents.json b/Tests/Fixtures/JSON/NakedEvents.json index 4b2f57db..09d92f41 100644 --- a/Tests/Fixtures/JSON/NakedEvents.json +++ b/Tests/Fixtures/JSON/NakedEvents.json @@ -11,4 +11,4 @@ "location": "Your House", "summary": "Hootnanny" } -] \ No newline at end of file +] diff --git a/Tests/Fixtures/JSON/RailsUser.json b/Tests/Fixtures/JSON/RailsUser.json index 3a5c90ef..45386105 100644 --- a/Tests/Fixtures/JSON/RailsUser.json +++ b/Tests/Fixtures/JSON/RailsUser.json @@ -13,4 +13,4 @@ "user_interests": ["Tennis", "Magic", "Football", "Basketball", "Computers", "Programming", "Computer Science", "Music", "Movies"] } -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/error.json b/Tests/Fixtures/JSON/error.json index e5ddd95f..50538a24 100644 --- a/Tests/Fixtures/JSON/error.json +++ b/Tests/Fixtures/JSON/error.json @@ -1 +1 @@ -{error: "this is an error"} \ No newline at end of file +{error: "this is an error"} diff --git a/Tests/Fixtures/JSON/errors.json b/Tests/Fixtures/JSON/errors.json index 19dc24bf..97107d2b 100644 --- a/Tests/Fixtures/JSON/errors.json +++ b/Tests/Fixtures/JSON/errors.json @@ -1 +1 @@ -{ "errors" : ["error1", "error2"] } \ No newline at end of file +{ "errors" : ["error1", "error2"] } diff --git a/Tests/Fixtures/JSON/humans/1.json b/Tests/Fixtures/JSON/humans/1.json index 62ba3621..96d2488c 100644 --- a/Tests/Fixtures/JSON/humans/1.json +++ b/Tests/Fixtures/JSON/humans/1.json @@ -1 +1 @@ -{"human":{"birthday":null,"created_at":null,"updated_at":null,"sex":null,"name":"Blake Watters","id":null,"age":28}} \ No newline at end of file +{"human":{"birthday":null,"created_at":null,"updated_at":null,"sex":null,"name":"Blake Watters","id":null,"age":28}} diff --git a/Tests/Fixtures/JSON/humans/all.json b/Tests/Fixtures/JSON/humans/all.json index ba80f2f8..d8011807 100644 --- a/Tests/Fixtures/JSON/humans/all.json +++ b/Tests/Fixtures/JSON/humans/all.json @@ -1 +1 @@ -[{"human":{"birthday":null,"created_at":null,"updated_at":null,"sex":null,"name":"Blake Watters","id":123,"age":null}},{"human":{"birthday":null,"created_at":null,"updated_at":null,"sex":null,"name":"Other","id":456,"age":null}}] \ No newline at end of file +[{"human":{"birthday":null,"created_at":null,"updated_at":null,"sex":null,"name":"Blake Watters","id":123,"age":null}},{"human":{"birthday":null,"created_at":null,"updated_at":null,"sex":null,"name":"Other","id":456,"age":null}}] diff --git a/Tests/Fixtures/JSON/humans/with_to_one_relationship.json b/Tests/Fixtures/JSON/humans/with_to_one_relationship.json index de06d946..3c2b500f 100644 --- a/Tests/Fixtures/JSON/humans/with_to_one_relationship.json +++ b/Tests/Fixtures/JSON/humans/with_to_one_relationship.json @@ -1 +1 @@ -{"human":{"name":"Blake Watters","id":null,"age":28,"favorite_cat":{"name": "Asia"}}} \ No newline at end of file +{"human":{"name":"Blake Watters","id":null,"age":28,"favorite_cat":{"name": "Asia"}}} diff --git a/Tests/Fixtures/JSON/nested_user.json b/Tests/Fixtures/JSON/nested_user.json index fb5e20f7..882493dd 100644 --- a/Tests/Fixtures/JSON/nested_user.json +++ b/Tests/Fixtures/JSON/nested_user.json @@ -3,4 +3,4 @@ "id": 31337, "name": "Blake Watters" } -} \ No newline at end of file +} diff --git a/Tests/Fixtures/JSON/user.json b/Tests/Fixtures/JSON/user.json index e3e7ca25..b0ef7c16 100644 --- a/Tests/Fixtures/JSON/user.json +++ b/Tests/Fixtures/JSON/user.json @@ -27,4 +27,4 @@ "name": "Rachit Shukla" } ] -} \ No newline at end of file +} diff --git a/Tests/Logic/CoreData/RKEntityByAttributeCacheTest.m b/Tests/Logic/CoreData/RKEntityByAttributeCacheTest.m index e798aa36..b50efc2c 100644 --- a/Tests/Logic/CoreData/RKEntityByAttributeCacheTest.m +++ b/Tests/Logic/CoreData/RKEntityByAttributeCacheTest.m @@ -26,9 +26,9 @@ { [RKTestFactory setUp]; self.objectStore = [RKTestFactory managedObjectStore]; - + NSEntityDescription *entity = [RKHuman entityDescriptionInContext:self.objectStore.primaryManagedObjectContext]; - self.cache = [[RKEntityByAttributeCache alloc] initWithEntity:entity + self.cache = [[RKEntityByAttributeCache alloc] initWithEntity:entity attribute:@"railsID" managedObjectContext:self.objectStore.primaryManagedObjectContext]; // Disable cache monitoring. Tested in specific cases. @@ -74,7 +74,7 @@ human.railsID = [NSNumber numberWithInteger:12345]; NSError *error = nil; [self.objectStore save:&error]; - + assertThat(error, is(nilValue())); [self.cache load]; assertThatInteger([self.cache count], is(equalToInteger(1))); @@ -87,7 +87,7 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; [self.cache flush]; @@ -102,7 +102,7 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; [self.cache flush]; @@ -117,9 +117,9 @@ human.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; [self.cache load]; - + NSManagedObject *object = [self.cache objectWithAttributeValue:[NSNumber numberWithInteger:12345]]; - assertThat(object, is(equalTo(human))); + assertThat(object, is(equalTo(human))); } - (void)testRetrievalOfNumericPropertyByStringValue @@ -141,10 +141,10 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; - + NSArray *objects = [self.cache objectsWithAttributeValue:[NSNumber numberWithInt:12345]]; assertThat(objects, hasCountOf(2)); assertThat([objects objectAtIndex:0], is(instanceOf([NSManagedObject class]))); @@ -155,7 +155,7 @@ RKHuman *human = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human]; assertThatBool([self.cache containsObject:human], is(equalToBool(YES))); } @@ -167,7 +167,7 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); @@ -179,7 +179,7 @@ RKHuman *human = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human]; assertThatBool([self.cache containsObject:human], is(equalToBool(YES))); [self.cache removeObject:human]; @@ -193,7 +193,7 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); @@ -218,7 +218,7 @@ human.railsID = [NSNumber numberWithInteger:12345]; RKChild *child = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; child.railsID = [NSNumber numberWithInteger:12345]; - + [self.cache addObject:human]; assertThatBool([self.cache containsObject:human], is(equalToBool(YES))); assertThatBool([self.cache containsObject:child], is(equalToBool(NO))); @@ -229,7 +229,7 @@ RKHuman *human = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human]; assertThatBool([self.cache containsObjectWithAttributeValue:[NSNumber numberWithInteger:12345]], is(equalToBool(YES))); } @@ -243,7 +243,7 @@ RKHuman *human3 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human3.railsID = [NSNumber numberWithInteger:123456]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; [self.cache addObject:human3]; @@ -259,7 +259,7 @@ RKHuman *human3 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human3.railsID = [NSNumber numberWithInteger:123456]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; [self.cache addObject:human3]; @@ -273,7 +273,7 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; assertThatInteger([self.cache countWithAttributeValue:[NSNumber numberWithInteger:12345]], is(equalToInteger(2))); @@ -300,11 +300,11 @@ self.cache.monitorsContextForChanges = YES; RKHuman *human1 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human1.railsID = [NSNumber numberWithInteger:12345]; - + NSEntityDescription *entity = [NSEntityDescription entityForName:@"RKCloud" inManagedObjectContext:self.objectStore.primaryManagedObjectContext]; NSManagedObject *cloud = [[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:self.objectStore.primaryManagedObjectContext]; [cloud setValue:@"Cumulus" forKey:@"name"]; - + [self.objectStore.primaryManagedObjectContext processPendingChanges]; assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); assertThatBool([self.cache containsObject:cloud], is(equalToBool(NO))); @@ -318,7 +318,7 @@ [self.objectStore.primaryManagedObjectContext processPendingChanges]; assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); [self.cache removeObject:human1]; - human1.name = @"Modified Name"; + human1.name = @"Modified Name"; assertThatBool([self.cache containsObject:human1], is(equalToBool(NO))); [self.objectStore.primaryManagedObjectContext processPendingChanges]; assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); @@ -344,7 +344,7 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore save:nil]; - + [self.cache addObject:human1]; [self.cache addObject:human2]; assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); @@ -355,22 +355,22 @@ - (void)testCreatingProcessingAndDeletingObjectsWorksAsExpected { self.cache.monitorsContextForChanges = YES; - + RKHuman *human1 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human1.railsID = [NSNumber numberWithInteger:12345]; RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; [self.objectStore.primaryManagedObjectContext processPendingChanges]; - + assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); assertThatBool([self.cache containsObject:human2], is(equalToBool(YES))); [self.objectStore.primaryManagedObjectContext deleteObject:human2]; - + // Save and reload the cache. This will result in the cached temporary // object ID's being released during the cache flush. [self.objectStore.primaryManagedObjectContext save:nil]; [self.cache load]; - + assertThatBool([self.cache containsObject:human1], is(equalToBool(YES))); assertThatBool([self.cache containsObject:human2], is(equalToBool(NO))); } diff --git a/Tests/Logic/CoreData/RKEntityCacheTest.m b/Tests/Logic/CoreData/RKEntityCacheTest.m index 654c368e..0ebb30da 100644 --- a/Tests/Logic/CoreData/RKEntityCacheTest.m +++ b/Tests/Logic/CoreData/RKEntityCacheTest.m @@ -27,7 +27,7 @@ - (void)setUp { [RKTestFactory setUp]; - + self.objectStore = [RKTestFactory managedObjectStore]; _cache = [[RKEntityCache alloc] initWithManagedObjectContext:self.objectStore.primaryManagedObjectContext]; self.entity = [RKHuman entityDescriptionInContext:self.objectStore.primaryManagedObjectContext]; @@ -49,7 +49,7 @@ - (void)testIsEntityCachedByAttribute { assertThatBool([_cache isEntity:self.entity cachedByAttribute:@"railsID"], is(equalToBool(NO))); - [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; + [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; assertThatBool([_cache isEntity:self.entity cachedByAttribute:@"railsID"], is(equalToBool(YES))); } @@ -74,7 +74,7 @@ human.railsID = [NSNumber numberWithInteger:12345]; NSError *error = nil; [self.objectStore save:&error]; - + [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; NSManagedObject *fetchedObject = [self.cache objectForEntity:self.entity withAttribute:@"railsID" value:[NSNumber numberWithInteger:12345]]; assertThat(fetchedObject, is(notNilValue())); @@ -88,7 +88,7 @@ human2.railsID = [NSNumber numberWithInteger:12345]; NSError *error = nil; [self.objectStore save:&error]; - + [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; NSArray *objects = [self.cache objectsForEntity:self.entity withAttribute:@"railsID" value:[NSNumber numberWithInteger:12345]]; assertThat(objects, hasCountOf(2)); @@ -103,22 +103,22 @@ RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; human2.name = @"Sarah"; - + [self.objectStore save:nil]; [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; [_cache cacheObjectsForEntity:self.entity byAttribute:@"name"]; - + NSArray *objects = [self.cache objectsForEntity:self.entity withAttribute:@"railsID" value:[NSNumber numberWithInteger:12345]]; assertThat(objects, hasCountOf(2)); assertThat(objects, containsInAnyOrder(human1, human2, nil)); - + objects = [self.cache objectsForEntity:self.entity withAttribute:@"name" value:@"Blake"]; assertThat(objects, hasCountOf(1)); assertThat(objects, contains(human1, nil)); - + [self.cache flush]; objects = [self.cache objectsForEntity:self.entity withAttribute:@"railsID" value:[NSNumber numberWithInteger:12345]]; - assertThat(objects, is(empty())); + assertThat(objects, is(empty())); objects = [self.cache objectsForEntity:self.entity withAttribute:@"name" value:@"Blake"]; assertThat(objects, is(empty())); } @@ -127,21 +127,21 @@ { [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; [_cache cacheObjectsForEntity:self.entity byAttribute:@"name"]; - + RKHuman *human1 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human1.railsID = [NSNumber numberWithInteger:12345]; human1.name = @"Blake"; RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; human2.name = @"Sarah"; - + [_cache addObject:human1]; [_cache addObject:human2]; - + NSArray *objects = [self.cache objectsForEntity:self.entity withAttribute:@"railsID" value:[NSNumber numberWithInteger:12345]]; assertThat(objects, hasCountOf(2)); assertThat(objects, containsInAnyOrder(human1, human2, nil)); - + objects = [self.cache objectsForEntity:self.entity withAttribute:@"name" value:@"Blake"]; assertThat(objects, hasCountOf(1)); assertThat(objects, contains(human1, nil)); @@ -151,21 +151,21 @@ { [_cache cacheObjectsForEntity:self.entity byAttribute:@"railsID"]; [_cache cacheObjectsForEntity:self.entity byAttribute:@"name"]; - + RKHuman *human1 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human1.railsID = [NSNumber numberWithInteger:12345]; human1.name = @"Blake"; RKHuman *human2 = [RKHuman createInContext:self.objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInteger:12345]; human2.name = @"Sarah"; - + [_cache addObject:human1]; [_cache addObject:human2]; - + NSArray *objects = [self.cache objectsForEntity:self.entity withAttribute:@"railsID" value:[NSNumber numberWithInteger:12345]]; assertThat(objects, hasCountOf(2)); assertThat(objects, containsInAnyOrder(human1, human2, nil)); - + RKEntityByAttributeCache *entityAttributeCache = [self.cache attributeCacheForEntity:[RKHuman entity] attribute:@"railsID"]; assertThatBool([entityAttributeCache containsObject:human1], is(equalToBool(YES))); [self.cache removeObject:human1]; diff --git a/Tests/Logic/CoreData/RKFetchRequestMappingCacheTest.m b/Tests/Logic/CoreData/RKFetchRequestMappingCacheTest.m index 49381739..c5270d7d 100644 --- a/Tests/Logic/CoreData/RKFetchRequestMappingCacheTest.m +++ b/Tests/Logic/CoreData/RKFetchRequestMappingCacheTest.m @@ -24,13 +24,13 @@ NSEntityDescription *entity = [RKCat entityDescription]; RKManagedObjectMapping *mapping = [RKManagedObjectMapping mappingForClass:[RKCat class] inManagedObjectStore:objectStore]; mapping.primaryKeyAttribute = @"railsID"; - + RKCat *reginald = [RKCat createInContext:objectStore.primaryManagedObjectContext]; reginald.name = @"Reginald"; reginald.railsID = [NSNumber numberWithInt:123456]; [objectStore.primaryManagedObjectContext save:nil]; - - NSManagedObject *cachedObject = [cache findInstanceOfEntity:entity + + NSManagedObject *cachedObject = [cache findInstanceOfEntity:entity withPrimaryKeyAttribute:mapping.primaryKeyAttribute value:[NSNumber numberWithInt:123456] inManagedObjectContext:objectStore.primaryManagedObjectContext]; @@ -39,13 +39,13 @@ - (void)testFetchRequestMappingCacheReturnsObjectsWithStringPrimaryKey { - // RKEvent entity. String primary key + // RKEvent entity. String primary key RKManagedObjectStore *objectStore = [RKTestFactory managedObjectStore]; RKFetchRequestManagedObjectCache *cache = [RKFetchRequestManagedObjectCache new]; NSEntityDescription *entity = [RKEvent entityDescription]; RKManagedObjectMapping *mapping = [RKManagedObjectMapping mappingForClass:[RKEvent class] inManagedObjectStore:objectStore]; mapping.primaryKeyAttribute = @"eventID"; - + RKEvent *birthday = [RKEvent createInContext:objectStore.primaryManagedObjectContext]; birthday.eventID = @"e-1234-a8-b12"; [objectStore.primaryManagedObjectContext save:nil]; diff --git a/Tests/Logic/CoreData/RKManagedObjectLoaderTest.m b/Tests/Logic/CoreData/RKManagedObjectLoaderTest.m index d1b894d0..efd461f1 100644 --- a/Tests/Logic/CoreData/RKManagedObjectLoaderTest.m +++ b/Tests/Logic/CoreData/RKManagedObjectLoaderTest.m @@ -90,7 +90,7 @@ [humanMapping mapAttributes:@"name", nil]; humanMapping.primaryKeyAttribute = @"railsID"; humanMapping.rootKeyPath = @"human"; - + // Create 3 objects, we will expect 2 after the load [RKHuman truncateAll]; assertThatUnsignedInteger([RKHuman count:nil], is(equalToInt(0))); @@ -221,15 +221,15 @@ id mockStore = [OCMockObject partialMockForObject:store]; BOOL success = NO; [[[mockStore stub] andReturnValue:OCMOCK_VALUE(success)] save:[OCMArg anyPointer]]; - + RKObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:store]; RKManagedObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/humans/1"]; objectLoader.objectMapping = mapping; - + RKTestResponseLoader *responseLoader = [RKTestResponseLoader responseLoader]; id mockResponseLoader = [OCMockObject partialMockForObject:responseLoader]; [[mockResponseLoader expect] objectLoaderDidFinishLoading:objectLoader]; - objectLoader.delegate = responseLoader; + objectLoader.delegate = responseLoader; [objectLoader sendAsynchronously]; [responseLoader waitForResponse]; [mockResponseLoader verify]; diff --git a/Tests/Logic/CoreData/RKManagedObjectMappingOperationTest.m b/Tests/Logic/CoreData/RKManagedObjectMappingOperationTest.m index d6024f4e..7eaded59 100644 --- a/Tests/Logic/CoreData/RKManagedObjectMappingOperationTest.m +++ b/Tests/Logic/CoreData/RKManagedObjectMappingOperationTest.m @@ -83,52 +83,52 @@ - (void)testConnectRelationshipsDoesNotLeakMemory { RKManagedObjectStore* objectStore = [RKTestFactory managedObjectStore]; - + RKManagedObjectMapping* catMapping = [RKManagedObjectMapping mappingForClass:[RKCat class] inManagedObjectStore:objectStore]; catMapping.primaryKeyAttribute = @"railsID"; [catMapping mapAttributes:@"name", nil]; - + RKManagedObjectMapping* humanMapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:objectStore]; humanMapping.primaryKeyAttribute = @"railsID"; [humanMapping mapAttributes:@"name", @"favoriteCatID", nil]; [humanMapping hasOne:@"favoriteCat" withMapping:catMapping]; [humanMapping connectRelationship:@"favoriteCat" withObjectForPrimaryKeyAttribute:@"favoriteCatID"]; - + // Create a cat to connect RKCat* cat = [RKCat object]; cat.name = @"Asia"; cat.railsID = [NSNumber numberWithInt:31337]; [objectStore save:nil]; - + NSDictionary* mappableData = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"Blake", @"favoriteCatID", [NSNumber numberWithInt:31337], nil]; RKHuman* human = [RKHuman object]; RKManagedObjectMappingOperation* operation = [[RKManagedObjectMappingOperation alloc] initWithSourceObject:mappableData destinationObject:human mapping:humanMapping]; operation.queue = [RKMappingOperationQueue new]; NSError* error = nil; [operation performMapping:&error]; - + assertThatInteger([operation retainCount], is(equalToInteger(1))); } - (void)testConnectionOfHasManyRelationshipsByPrimaryKey { RKManagedObjectStore* objectStore = [RKTestFactory managedObjectStore]; - + RKManagedObjectMapping* catMapping = [RKManagedObjectMapping mappingForClass:[RKCat class] inManagedObjectStore:objectStore]; catMapping.primaryKeyAttribute = @"railsID"; [catMapping mapAttributes:@"name", nil]; - + RKManagedObjectMapping* humanMapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:objectStore]; humanMapping.primaryKeyAttribute = @"railsID"; [humanMapping mapAttributes:@"name", @"favoriteCatID", nil]; [humanMapping hasOne:@"favoriteCat" withMapping:catMapping]; [humanMapping connectRelationship:@"favoriteCat" withObjectForPrimaryKeyAttribute:@"favoriteCatID"]; - + // Create a cat to connect RKCat* cat = [RKCat object]; cat.name = @"Asia"; cat.railsID = [NSNumber numberWithInt:31337]; [objectStore save:nil]; - + NSDictionary* mappableData = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"Blake", @"favoriteCatID", [NSNumber numberWithInt:31337], nil]; RKHuman* human = [RKHuman object]; RKManagedObjectMappingOperation* operation = [[RKManagedObjectMappingOperation alloc] initWithSourceObject:mappableData destinationObject:human mapping:humanMapping]; @@ -156,17 +156,17 @@ RKCat* asia = [RKCat object]; asia.name = @"Asia"; asia.railsID = [NSNumber numberWithInt:31337]; - + RKCat* roy = [RKCat object]; roy.name = @"Reginald Royford Williams III"; roy.railsID = [NSNumber numberWithInt:31338]; - + [objectStore save:nil]; NSArray *catIDs = [NSArray arrayWithObjects:[NSNumber numberWithInt:31337], [NSNumber numberWithInt:31338], nil]; NSDictionary* mappableData = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"Blake", @"catIDs", catIDs, nil]; RKHuman* human = [RKHuman object]; - + RKManagedObjectMappingOperation* operation = [[RKManagedObjectMappingOperation alloc] initWithSourceObject:mappableData destinationObject:human mapping:humanMapping]; NSError* error = nil; BOOL success = [operation performMapping:&error]; @@ -200,12 +200,12 @@ RKManagedObjectMapping* catMapping = [RKManagedObjectMapping mappingForClass:[RKCat class] inManagedObjectStore:objectStore]; catMapping.primaryKeyAttribute = @"railsID"; [catMapping mapAttributes:@"name", nil]; - + RKManagedObjectMapping* humanMapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:objectStore]; humanMapping.primaryKeyAttribute = @"railsID"; [humanMapping mapAttributes:@"name", @"favoriteCatID", nil]; [humanMapping mapKeyPath:@"cats" toRelationship:@"catsInOrderByAge" withMapping:catMapping]; - + NSArray* catsData = [NSArray arrayWithObject:[NSDictionary dictionaryWithObject:@"Asia" forKey:@"name"]]; NSDictionary* mappableData = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"Blake", @"favoriteCatID", [NSNumber numberWithInt:31337], @"cats", catsData, nil]; RKHuman* human = [RKHuman object]; @@ -366,26 +366,26 @@ - (void)testMappingAPayloadContainingRepeatedObjectsDoesNotYieldDuplicatesWithFetchRequestMappingCache { RKManagedObjectStore *store = [RKTestFactory managedObjectStore]; - store.cacheStrategy = [RKFetchRequestManagedObjectCache new]; - + store.cacheStrategy = [RKFetchRequestManagedObjectCache new]; + RKManagedObjectMapping* childMapping = [RKManagedObjectMapping mappingForClass:[RKChild class] inManagedObjectStore:store]; childMapping.primaryKeyAttribute = @"childID"; [childMapping mapAttributes:@"name", @"childID", nil]; - + RKManagedObjectMapping* parentMapping = [RKManagedObjectMapping mappingForClass:[RKParent class] inManagedObjectStore:store]; [parentMapping mapAttributes:@"parentID", @"name", nil]; parentMapping.primaryKeyAttribute = @"parentID"; [parentMapping mapRelationship:@"children" withMapping:childMapping]; - + RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider new]; // NOTE: This may be fragile. Reverse order seems to trigger them to be mapped parent first. NSDictionary // keys are not guaranteed to return in any particular order [mappingProvider setObjectMapping:parentMapping forKeyPath:@"parents"]; - + NSDictionary *JSON = [RKTestFixture parsedObjectWithContentsOfFixture:@"parents_and_children.json"]; RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:JSON mappingProvider:mappingProvider]; [mapper performMapping]; - + NSUInteger parentCount = [RKParent count:nil]; NSUInteger childrenCount = [RKChild count:nil]; assertThatInteger(parentCount, is(equalToInteger(2))); @@ -394,26 +394,26 @@ - (void)testMappingAPayloadContainingRepeatedObjectsDoesNotYieldDuplicatesWithInMemoryMappingCache { RKManagedObjectStore *store = [RKTestFactory managedObjectStore]; - store.cacheStrategy = [RKInMemoryManagedObjectCache new]; - + store.cacheStrategy = [RKInMemoryManagedObjectCache new]; + RKManagedObjectMapping* childMapping = [RKManagedObjectMapping mappingForClass:[RKChild class] inManagedObjectStore:store]; childMapping.primaryKeyAttribute = @"childID"; [childMapping mapAttributes:@"name", @"childID", nil]; - + RKManagedObjectMapping* parentMapping = [RKManagedObjectMapping mappingForClass:[RKParent class] inManagedObjectStore:store]; [parentMapping mapAttributes:@"parentID", @"name", nil]; parentMapping.primaryKeyAttribute = @"parentID"; [parentMapping mapRelationship:@"children" withMapping:childMapping]; - + RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider new]; // NOTE: This may be fragile. Reverse order seems to trigger them to be mapped parent first. NSDictionary // keys are not guaranteed to return in any particular order [mappingProvider setObjectMapping:parentMapping forKeyPath:@"parents"]; - + NSDictionary *JSON = [RKTestFixture parsedObjectWithContentsOfFixture:@"parents_and_children.json"]; RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:JSON mappingProvider:mappingProvider]; [mapper performMapping]; - + NSUInteger parentCount = [RKParent count:nil]; NSUInteger childrenCount = [RKChild count:nil]; assertThatInteger(parentCount, is(equalToInteger(2))); @@ -422,28 +422,28 @@ - (void)testMappingAPayloadContainingRepeatedObjectsPerformsAcceptablyWithFetchRequestMappingCache { RKManagedObjectStore *store = [RKTestFactory managedObjectStore]; - store.cacheStrategy = [RKFetchRequestManagedObjectCache new]; - + store.cacheStrategy = [RKFetchRequestManagedObjectCache new]; + RKManagedObjectMapping* childMapping = [RKManagedObjectMapping mappingForClass:[RKChild class] inManagedObjectStore:store]; childMapping.primaryKeyAttribute = @"childID"; [childMapping mapAttributes:@"name", @"childID", nil]; - + RKManagedObjectMapping* parentMapping = [RKManagedObjectMapping mappingForClass:[RKParent class] inManagedObjectStore:store]; [parentMapping mapAttributes:@"parentID", @"name", nil]; parentMapping.primaryKeyAttribute = @"parentID"; [parentMapping mapRelationship:@"children" withMapping:childMapping]; - + RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider new]; // NOTE: This may be fragile. Reverse order seems to trigger them to be mapped parent first. NSDictionary // keys are not guaranteed to return in any particular order [mappingProvider setObjectMapping:parentMapping forKeyPath:@"parents"]; - + NSDictionary *JSON = [RKTestFixture parsedObjectWithContentsOfFixture:@"benchmark_parents_and_children.json"]; RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:JSON mappingProvider:mappingProvider]; - + RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelOff); RKLogConfigureByName("RestKit/CoreData", RKLogLevelOff); - + [RKBenchmark report:@"Mapping with Fetch Request Cache" executionBlock:^{ for (NSUInteger i=0; i<50; i++) { [mapper performMapping]; @@ -457,28 +457,28 @@ - (void)testMappingAPayloadContainingRepeatedObjectsPerformsAcceptablyWithInMemoryMappingCache { RKManagedObjectStore *store = [RKTestFactory managedObjectStore]; - store.cacheStrategy = [RKInMemoryManagedObjectCache new]; - + store.cacheStrategy = [RKInMemoryManagedObjectCache new]; + RKManagedObjectMapping* childMapping = [RKManagedObjectMapping mappingForClass:[RKChild class] inManagedObjectStore:store]; childMapping.primaryKeyAttribute = @"childID"; [childMapping mapAttributes:@"name", @"childID", nil]; - + RKManagedObjectMapping* parentMapping = [RKManagedObjectMapping mappingForClass:[RKParent class] inManagedObjectStore:store]; [parentMapping mapAttributes:@"parentID", @"name", nil]; parentMapping.primaryKeyAttribute = @"parentID"; [parentMapping mapRelationship:@"children" withMapping:childMapping]; - + RKObjectMappingProvider *mappingProvider = [RKObjectMappingProvider new]; // NOTE: This may be fragile. Reverse order seems to trigger them to be mapped parent first. NSDictionary // keys are not guaranteed to return in any particular order [mappingProvider setObjectMapping:parentMapping forKeyPath:@"parents"]; - + NSDictionary *JSON = [RKTestFixture parsedObjectWithContentsOfFixture:@"benchmark_parents_and_children.json"]; RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:JSON mappingProvider:mappingProvider]; - + RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelOff); RKLogConfigureByName("RestKit/CoreData", RKLogLevelOff); - + [RKBenchmark report:@"Mapping with In Memory Cache" executionBlock:^{ for (NSUInteger i=0; i<50; i++) { [mapper performMapping]; diff --git a/Tests/Logic/CoreData/RKManagedObjectMappingTest.m b/Tests/Logic/CoreData/RKManagedObjectMappingTest.m index d36de5a7..8e367779 100644 --- a/Tests/Logic/CoreData/RKManagedObjectMappingTest.m +++ b/Tests/Logic/CoreData/RKManagedObjectMappingTest.m @@ -187,12 +187,12 @@ RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:store]; mapping.primaryKeyAttribute = @"railsID"; [mapping addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@"id" toKeyPath:@"railsID"]]; - + RKHuman* human = [RKHuman object]; human.railsID = [NSNumber numberWithInt:123]; [store save:nil]; assertThatBool([RKHuman hasAtLeastOneEntity], is(equalToBool(YES))); - + NSDictionary* data = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:123] forKey:@"id"]; id object = [mapping mappableObjectForData:data]; assertThat(object, isNot(nilValue())); @@ -206,13 +206,13 @@ RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:store]; mapping.primaryKeyAttribute = @"railsID"; [mapping addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@"monkey.id" toKeyPath:@"railsID"]]; - + [RKHuman truncateAll]; RKHuman* human = [RKHuman object]; human.railsID = [NSNumber numberWithInt:123]; [store save:nil]; assertThatBool([RKHuman hasAtLeastOneEntity], is(equalToBool(YES))); - + NSDictionary* data = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:123] forKey:@"id"]; NSDictionary* nestedDictionary = [NSDictionary dictionaryWithObject:data forKey:@"monkey"]; id object = [mapping mappableObjectForData:nestedDictionary]; @@ -229,12 +229,12 @@ RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:store]; mapping.primaryKeyAttribute = @"railsID"; [mapping addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@"id" toKeyPath:@"railsID"]]; - + RKHuman* human = [RKHuman createInContext:store.primaryManagedObjectContext]; human.railsID = [NSNumber numberWithInt:123]; [store save:nil]; assertThatBool([RKHuman hasAtLeastOneEntity], is(equalToBool(YES))); - + NSDictionary* data = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:123] forKey:@"id"]; NSManagedObject *object = [mapping mappableObjectForData:data]; assertThat([object managedObjectContext], is(equalTo(store.primaryManagedObjectContext))); @@ -250,13 +250,13 @@ RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class] inManagedObjectStore:store]; mapping.primaryKeyAttribute = @"railsID"; [mapping addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@"monkey.id" toKeyPath:@"railsID"]]; - + [RKHuman truncateAll]; RKHuman* human = [RKHuman object]; human.railsID = [NSNumber numberWithInt:123]; [store save:nil]; assertThatBool([RKHuman hasAtLeastOneEntity], is(equalToBool(YES))); - + NSDictionary* data = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:123] forKey:@"id"]; NSDictionary* nestedDictionary = [NSDictionary dictionaryWithObject:data forKey:@"monkey"]; id object = [mapping mappableObjectForData:nestedDictionary]; @@ -273,19 +273,19 @@ mapping.primaryKeyAttribute = @"name"; [RKHuman entity].primaryKeyAttribute = @"railsID"; [mapping addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@"monkey.name" toKeyPath:@"name"]]; - + [RKHuman truncateAll]; RKHuman* human = [RKHuman object]; human.name = @"Testing"; [store save:nil]; assertThatBool([RKHuman hasAtLeastOneEntity], is(equalToBool(YES))); - + NSDictionary* data = [NSDictionary dictionaryWithObject:@"Testing" forKey:@"name"]; NSDictionary* nestedDictionary = [NSDictionary dictionaryWithObject:data forKey:@"monkey"]; id object = [mapping mappableObjectForData:nestedDictionary]; assertThat(object, isNot(nilValue())); assertThat(object, is(equalTo(human))); - + id cachedObject = [store.cacheStrategy findInstanceOfEntity:[RKHuman entity] withPrimaryKeyAttribute:@"name" value:@"Testing" inManagedObjectContext:store.primaryManagedObjectContext]; assertThat(cachedObject, is(equalTo(human))); } @@ -299,19 +299,19 @@ mapping.primaryKeyAttribute = @"name"; [RKHuman entity].primaryKeyAttribute = @"railsID"; [mapping addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@"monkey.name" toKeyPath:@"name"]]; - + [RKHuman truncateAll]; RKHuman* human = [RKHuman object]; human.name = @"Testing"; [store save:nil]; assertThatBool([RKHuman hasAtLeastOneEntity], is(equalToBool(YES))); - + NSDictionary* data = [NSDictionary dictionaryWithObject:@"Testing" forKey:@"name"]; NSDictionary* nestedDictionary = [NSDictionary dictionaryWithObject:data forKey:@"monkey"]; id object = [mapping mappableObjectForData:nestedDictionary]; assertThat(object, isNot(nilValue())); assertThat(object, is(equalTo(human))); - + id cachedObject = [store.cacheStrategy findInstanceOfEntity:[RKHuman entity] withPrimaryKeyAttribute:@"name" value:@"Testing" inManagedObjectContext:store.primaryManagedObjectContext]; assertThat(cachedObject, is(equalTo(human))); } diff --git a/Tests/Logic/Network/RKOAuthClientTest.m b/Tests/Logic/Network/RKOAuthClientTest.m index f49c1bfc..ba88dd12 100644 --- a/Tests/Logic/Network/RKOAuthClientTest.m +++ b/Tests/Logic/Network/RKOAuthClientTest.m @@ -39,13 +39,13 @@ portCheck = [[RKPortCheck alloc] initWithHost:@"localhost" port:27017]; [portCheck run]; } - + return [portCheck isOpen]; } - (void)testShouldGetAccessToken{ RKOAuthClientTestSkipWithoutMongoDB(); - + RKTestResponseLoader *loader = [RKTestResponseLoader responseLoader]; RKOAuthClient *client = RKTestNewOAuthClient(loader); client.authorizationCode = @"4fa8182d7184797dd5000002"; @@ -57,7 +57,7 @@ - (void)testShouldNotGetAccessToken { RKOAuthClientTestSkipWithoutMongoDB(); - + RKTestResponseLoader *loader = [RKTestResponseLoader responseLoader]; RKOAuthClient *client = RKTestNewOAuthClient(loader); client.authorizationCode = @"someInvalidAuthorizationCode"; @@ -70,7 +70,7 @@ - (void)testShouldGetProtectedResource{ RKOAuthClientTestSkipWithoutMongoDB(); - + //TODO: Encapsulate this code in a correct manner RKTestResponseLoader *loader = [RKTestResponseLoader responseLoader]; RKOAuthClient *client = RKTestNewOAuthClient(loader); diff --git a/Tests/Logic/Network/RKRequestTest.m b/Tests/Logic/Network/RKRequestTest.m index 85126d1e..63a3c152 100644 --- a/Tests/Logic/Network/RKRequestTest.m +++ b/Tests/Logic/Network/RKRequestTest.m @@ -40,7 +40,7 @@ - (void)setUp { [RKTestFactory setUp]; - + // Clear the cache directory [RKTestFactory clearCacheDirectory]; _methodInvocationCounter = 0; @@ -842,7 +842,7 @@ request.timeoutInterval = 1.0; [request prepareURLRequest]; NSString *authorization = [request.URLRequest valueForHTTPHeaderField:@"Authorization"]; assertThat(authorization, isNot(nilValue())); - + RKTestResponseLoader *responseLoader = [RKTestResponseLoader responseLoader]; request.delegate = responseLoader; [request sendAsynchronously]; @@ -860,7 +860,7 @@ request.timeoutInterval = 1.0; [request prepareURLRequest]; NSString *authorization = [request.URLRequest valueForHTTPHeaderField:@"Authorization"]; assertThat(authorization, isNot(nilValue())); - + RKTestResponseLoader *responseLoader = [RKTestResponseLoader responseLoader]; request.delegate = responseLoader; [request sendAsynchronously]; @@ -942,7 +942,7 @@ request.timeoutInterval = 1.0; request.delegate = loaderMock; [[loaderMock expect] request:request didReceiveResponse:OCMOCK_ANY]; [request sendAsynchronously]; - [loaderMock waitForResponse]; + [loaderMock waitForResponse]; [request release]; [loaderMock verify]; } diff --git a/Tests/Logic/Network/RKResponseTest.m b/Tests/Logic/Network/RKResponseTest.m index fcd2f9a4..1a86fc99 100644 --- a/Tests/Logic/Network/RKResponseTest.m +++ b/Tests/Logic/Network/RKResponseTest.m @@ -282,15 +282,15 @@ - (void)testNoFollowRedirect { RKClient* client = [RKTestFactory client]; RKTestResponseLoader* loader = [RKTestResponseLoader responseLoader]; - + RKRequest* request = [client requestWithResourcePath:@"/redirection"]; request.method = RKRequestMethodGET; request.followRedirect = NO; request.delegate = loader; - + [request send]; [loader waitForResponse]; - + assertThatInteger(loader.response.statusCode, is(equalToInteger(302))); assertThat([loader.response.allHeaderFields objectForKey:@"Location"], is(equalTo(@"/redirection/target"))); } @@ -299,11 +299,11 @@ NSURL *URL = [[NSURL alloc] initWithString:@"http://localhost:5629"]; RKTestResponseLoader* loader = [RKTestResponseLoader responseLoader]; RKClient *client = [RKClient clientWithBaseURL:URL]; - + RKRequest *request = [client requestWithResourcePath:@"/invalid"]; request.method = RKRequestMethodGET; request.delegate = loader; - + [request sendAsynchronously]; [loader waitForResponse]; } diff --git a/Tests/Logic/ObjectMapping/RKObjectManagerTest.m b/Tests/Logic/ObjectMapping/RKObjectManagerTest.m index 2c74a234..c4cf0f39 100644 --- a/Tests/Logic/ObjectMapping/RKObjectManagerTest.m +++ b/Tests/Logic/ObjectMapping/RKObjectManagerTest.m @@ -87,7 +87,7 @@ } - (void)testShouldSetTheAcceptHeaderAppropriatelyForTheFormat { - + assertThat([_objectManager.client.HTTPHeaders valueForKey:@"Accept"], is(equalTo(@"application/json"))); } @@ -369,7 +369,7 @@ [objectManager.router routeClass:[RKObjectMapperTestModel class] toResourcePath:@"/human/1"]; objectManager.serializationMIMEType = RKMIMETypeJSON; RKTestResponseLoader *responseLoader = [RKTestResponseLoader responseLoader]; - + RKObjectMapperTestModel *object = [RKObjectMapperTestModel new]; [objectManager putObject:object usingBlock:^(RKObjectLoader *loader) { loader.delegate = responseLoader; diff --git a/Tests/Logic/ObjectMapping/RKObjectMappingNextGenTest.m b/Tests/Logic/ObjectMapping/RKObjectMappingNextGenTest.m index b13dc4a4..24fc769f 100644 --- a/Tests/Logic/ObjectMapping/RKObjectMappingNextGenTest.m +++ b/Tests/Logic/ObjectMapping/RKObjectMappingNextGenTest.m @@ -1261,10 +1261,10 @@ RKObjectMapping* addressMapping = [RKObjectMapping mappingForClass:[RKTestAddress class]]; RKObjectAttributeMapping* cityMapping = [RKObjectAttributeMapping mappingFromKeyPath:@"city" toKeyPath:@"city"]; [addressMapping addAttributeMapping:cityMapping]; - + RKObjectRelationshipMapping* hasOneMapping = [RKObjectRelationshipMapping mappingFromKeyPath:@"address" toKeyPath:@"friendsOrderedSet" withMapping:addressMapping]; [userMapping addRelationshipMapping:hasOneMapping]; - + RKObjectMapper* mapper = [RKObjectMapper new]; id userInfo = [RKTestFixture parsedObjectWithContentsOfFixture:@"user.json"]; RKTestUser* user = [RKTestUser user]; @@ -1323,10 +1323,10 @@ RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[RKTestUser class]]; RKObjectAttributeMapping* nameMapping = [RKObjectAttributeMapping mappingFromKeyPath:@"name" toKeyPath:@"name"]; [userMapping addAttributeMapping:nameMapping]; - + RKObjectRelationshipMapping* hasManyMapping = [RKObjectRelationshipMapping mappingFromKeyPath:@"friends" toKeyPath:@"friendsOrderedSet" withMapping:userMapping]; [userMapping addRelationshipMapping:hasManyMapping]; - + RKObjectMapper* mapper = [RKObjectMapper new]; id userInfo = [RKTestFixture parsedObjectWithContentsOfFixture:@"user.json"]; RKTestUser* user = [RKTestUser user]; @@ -1832,16 +1832,16 @@ assertThat([RKObjectMapping defaultDateFormatters], hasCountOf(4)); } -- (void)testShouldAllowNewlyAddedDateFormatterToRunFirst { +- (void)testShouldAllowNewlyAddedDateFormatterToRunFirst { [RKObjectMapping setDefaultDateFormatters:nil]; NSDateFormatter *newDateFormatter = [[NSDateFormatter new] autorelease]; [newDateFormatter setDateFormat:@"dd/MM/yyyy"]; [RKObjectMapping addDefaultDateFormatter:newDateFormatter]; - + RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[RKTestUser class]]; RKObjectAttributeMapping *birthDateMapping = [RKObjectAttributeMapping mappingFromKeyPath:@"favorite_date" toKeyPath:@"favoriteDate"]; [mapping addAttributeMapping:birthDateMapping]; - + NSDictionary *dictionary = [RKTestFixture parsedObjectWithContentsOfFixture:@"user.json"]; RKTestUser *user = [RKTestUser user]; RKObjectMappingOperation *operation = [[RKObjectMappingOperation alloc] initWithSourceObject:dictionary destinationObject:user mapping:mapping]; @@ -1873,7 +1873,7 @@ RKObjectMapping* mapping = [RKObjectMapping mappingForClass:[RKTestUser class]]; RKObjectAttributeMapping* birthDateMapping = [RKObjectAttributeMapping mappingFromKeyPath:@"birthdate" toKeyPath:@"birthDate"]; [mapping addAttributeMapping:birthDateMapping]; - + NSDictionary* dictionary = [RKTestFixture parsedObjectWithContentsOfFixture:@"user.json"]; NSMutableDictionary *mutableDictionary = [dictionary mutableCopy]; [mutableDictionary setValue:@"" forKey:@"birthdate"]; @@ -1882,7 +1882,7 @@ [mutableDictionary release]; NSError* error = nil; [operation performMapping:&error]; - + assertThat(user.birthDate, is(equalTo(nil))); } @@ -1979,20 +1979,20 @@ humanMapping.primaryKeyAttribute = @"railsID"; RKObjectMappingProvider *provider = [RKObjectMappingProvider mappingProvider]; [provider setObjectMapping:humanMapping forKeyPath:@"human"]; - + // Create instances that should match the fixture RKHuman *human1 = [RKHuman createInContext:objectStore.primaryManagedObjectContext]; human1.railsID = [NSNumber numberWithInt:201]; RKHuman *human2 = [RKHuman createInContext:objectStore.primaryManagedObjectContext]; human2.railsID = [NSNumber numberWithInt:202]; [objectStore save:nil]; - + RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:array mappingProvider:provider]; RKObjectMappingResult *result = [mapper performMapping]; assertThat(result, is(notNilValue())); - + NSArray *humans = [result asCollection]; - assertThat(humans, hasCountOf(2)); + assertThat(humans, hasCountOf(2)); assertThat([humans objectAtIndex:0], is(equalTo(human1))); assertThat([humans objectAtIndex:1], is(equalTo(human2))); } diff --git a/Tests/Logic/ObjectMapping/RKObjectMappingOperationTest.m b/Tests/Logic/ObjectMapping/RKObjectMappingOperationTest.m index 4871f3bb..1a7c5209 100644 --- a/Tests/Logic/ObjectMapping/RKObjectMappingOperationTest.m +++ b/Tests/Logic/ObjectMapping/RKObjectMappingOperationTest.m @@ -58,7 +58,7 @@ } else if ([(NSObject *)*ioValue isKindOfClass:[NSString class]] && [(NSString *)*ioValue isEqualToString:@"MODIFY"]) { *ioValue = @"modified value"; return YES; - } + } return YES; } diff --git a/Tests/Logic/ObjectMapping/RKParserRegistryTest.m b/Tests/Logic/ObjectMapping/RKParserRegistryTest.m index d5461ef4..0304510c 100644 --- a/Tests/Logic/ObjectMapping/RKParserRegistryTest.m +++ b/Tests/Logic/ObjectMapping/RKParserRegistryTest.m @@ -55,7 +55,7 @@ - (void)testRetrievalOfExactStringMatchForMIMEType { RKParserRegistry* registry = [[RKParserRegistry new] autorelease]; - [registry setParserClass:[RKJSONParserJSONKit class] forMIMEType:RKMIMETypeJSON]; + [registry setParserClass:[RKJSONParserJSONKit class] forMIMEType:RKMIMETypeJSON]; id parser = [registry parserForMIMEType:RKMIMETypeJSON]; assertThat(parser, is(instanceOf([RKJSONParserJSONKit class]))); } @@ -73,13 +73,13 @@ RKParserRegistry *registry = [[RKParserRegistry new] autorelease]; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"application/xml\\+\\w+" options:0 error:&error]; - [registry setParserClass:[RKJSONParserJSONKit class] forMIMETypeRegularExpression:regex]; + [registry setParserClass:[RKJSONParserJSONKit class] forMIMETypeRegularExpression:regex]; [registry setParserClass:[RKXMLParserXMLReader class] forMIMEType:@"application/xml+whatever"]; - + // Exact match id exactParser = [registry parserForMIMEType:@"application/xml+whatever"]; assertThat(exactParser, is(instanceOf([RKXMLParserXMLReader class]))); - + // Fallback to regex id regexParser = [registry parserForMIMEType:@"application/xml+different"]; assertThat(regexParser, is(instanceOf([RKJSONParserJSONKit class]))); diff --git a/Tests/Logic/Support/NSArray+RKAdditionsTest.m b/Tests/Logic/Support/NSArray+RKAdditionsTest.m index 850e4df8..4c376a26 100644 --- a/Tests/Logic/Support/NSArray+RKAdditionsTest.m +++ b/Tests/Logic/Support/NSArray+RKAdditionsTest.m @@ -29,7 +29,7 @@ user.name = @"Blake"; user.country = @"USA"; NSArray *users = [NSArray arrayWithObject:user]; - + NSArray *sections = [users sectionsGroupedByKeyPath:@"country"]; assertThat(sections, hasCountOf(1)); } @@ -39,17 +39,17 @@ RKTestUser *user1 = [RKTestUser new]; user1.name = @"Blake"; user1.country = @"USA"; - + RKTestUser *user2 = [RKTestUser new]; user2.name = @"Colin"; user2.country = @"USA"; - + RKTestUser *user3 = [RKTestUser new]; user3.name = @"Pepe"; - user3.country = @"Spain"; - + user3.country = @"Spain"; + NSArray *users = [NSArray arrayWithObjects:user1, user2, user3, nil]; - + NSArray *sections = [users sectionsGroupedByKeyPath:@"country"]; assertThat(sections, hasCountOf(2)); assertThat([sections objectAtIndex:0], contains(user1, user2, nil)); @@ -60,22 +60,22 @@ { RKTestUser *user1 = [RKTestUser new]; user1.name = @"Blake"; - user1.country = @"USA"; - + user1.country = @"USA"; + RKTestUser *user2 = [RKTestUser new]; user2.name = @"Expatriate"; user2.country = nil; - + RKTestUser *user3 = [RKTestUser new]; user3.name = @"John Doe"; user3.country = nil; - + RKTestUser *user4 = [RKTestUser new]; user4.name = @"Pepe"; user4.country = @"Spain"; - + NSArray *users = [NSArray arrayWithObjects:user1, user2, user3, user4, nil]; - + NSArray *sections = [users sectionsGroupedByKeyPath:@"country"]; assertThat(sections, hasCountOf(3)); assertThat([sections objectAtIndex:0], contains(user1, nil)); diff --git a/Tests/Logic/Support/RKCacheTest.m b/Tests/Logic/Support/RKCacheTest.m index 57606804..6520555c 100644 --- a/Tests/Logic/Support/RKCacheTest.m +++ b/Tests/Logic/Support/RKCacheTest.m @@ -21,7 +21,7 @@ NSString *subPath = [cachePath stringByAppendingPathComponent:@"TestPath"]; NSError *error = nil; [[NSFileManager defaultManager] removeItemAtPath:cachePath error:&error]; - + [[RKCache alloc] initWithPath:subPath subDirectories:nil]; BOOL isDirectory; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:subPath isDirectory:&isDirectory]; diff --git a/Tests/Logic/Support/RKDotNetDateFormatterTest.m b/Tests/Logic/Support/RKDotNetDateFormatterTest.m index caa3a2a5..de14dbf9 100644 --- a/Tests/Logic/Support/RKDotNetDateFormatterTest.m +++ b/Tests/Logic/Support/RKDotNetDateFormatterTest.m @@ -80,11 +80,11 @@ - (void)testShouldCreateADateWithGetObjectValueForString { RKDotNetDateFormatter *formatter = [RKDotNetDateFormatter dotNetDateFormatter]; NSString *dotNetString = @"/Date(1000212360000-0400)/"; - + NSDate *date = nil; - NSString *errorDescription = nil; + NSString *errorDescription = nil; BOOL success = [formatter getObjectValue:&date forString:dotNetString errorDescription:&errorDescription]; - + assertThatBool(success, is(equalToBool(YES))); assertThat([date description], is(equalTo(@"2001-09-11 12:46:00 +0000"))); } diff --git a/Tests/Models/RKMappableObject.h b/Tests/Models/RKMappableObject.h index 5645115c..4c40a3ec 100644 --- a/Tests/Models/RKMappableObject.h +++ b/Tests/Models/RKMappableObject.h @@ -37,4 +37,4 @@ @property (nonatomic, retain) RKMappableAssociation* hasOne; @property (nonatomic, retain) NSSet* hasMany; -@end \ No newline at end of file +@end diff --git a/Tests/Models/RKSearchable.h b/Tests/Models/RKSearchable.h index 369cbb87..c1e5f935 100644 --- a/Tests/Models/RKSearchable.h +++ b/Tests/Models/RKSearchable.h @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/26/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Tests/Models/RKSearchable.m b/Tests/Models/RKSearchable.m index d7900719..13c9501f 100644 --- a/Tests/Models/RKSearchable.m +++ b/Tests/Models/RKSearchable.m @@ -4,13 +4,13 @@ // // Created by Blake Watters on 7/26/11. // Copyright (c) 2009-2012 RestKit. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Tests/Models/RKTestAddress.m b/Tests/Models/RKTestAddress.m index dd4715f3..e05865bb 100644 --- a/Tests/Models/RKTestAddress.m +++ b/Tests/Models/RKTestAddress.m @@ -29,4 +29,4 @@ } } -@end \ No newline at end of file +@end diff --git a/Tests/Models/RKTestUser.m b/Tests/Models/RKTestUser.m index 6c1422ee..ddb5689f 100644 --- a/Tests/Models/RKTestUser.m +++ b/Tests/Models/RKTestUser.m @@ -43,7 +43,7 @@ return [[(RKTestUser*)object userID] isEqualToNumber:self.userID]; } } - + return NO; } diff --git a/Tests/RKTestEnvironment.h b/Tests/RKTestEnvironment.h index 7271efb4..132ba834 100644 --- a/Tests/RKTestEnvironment.h +++ b/Tests/RKTestEnvironment.h @@ -31,7 +31,7 @@ RKOAuthClient* RKTestNewOAuthClient(RKTestResponseLoader* loader); -/* +/* Base class for RestKit test cases. Provides initialization of testing infrastructure. */