Trailing whitespace cleanup from files in the Code directory.

Used the following command from within the Code dir:
git ls-files *.m *.h *.json | xargs /usr/bin/sed -i '' -E 's/[[:space:]]*$//'
This commit is contained in:
Jawwad Ahmad
2012-09-02 12:47:54 -04:00
parent c70ab49457
commit 8cbdb5f7ed
46 changed files with 250 additions and 250 deletions

View File

@@ -23,10 +23,10 @@
/**
Determines if the receiver has been deleted from the persistent store
and removed from the object graph.
Unlike isDeleted, will return YES after a save event or if the managed object was deleted
Unlike isDeleted, will return YES after a save event or if the managed object was deleted
in another managed object context that was then merged to the persistent store.
@return YES if the object has been deleted from the persistent store, else NO.
*/
- (BOOL)hasBeenDeleted;

View File

@@ -76,7 +76,7 @@
with a nil parent is found. If the final ancestor context does not have a reference to the persistent store
coordinator, then a warning is generated and the method returns NO.
@param error If there is a problem saving the receiver or any of its ancestor contexts, upon return contains an
@param error If there is a problem saving the receiver or any of its ancestor contexts, upon return contains an
pointer to an instance of NSError that describes the problem.
@return YES if the save to the persistent store was successful, else NO.
*/

View File

@@ -150,7 +150,7 @@
/**
Returns the collection of objects with a matching value for the cache key attribute
in a given managed object context.
@param attributeValue A value for the cache key attribute.
@return An array of objects with the value of attribute matching attributeValue or
an empty array.

View File

@@ -40,7 +40,7 @@
selector:@selector(managedObjectContextDidChange:)
name:NSManagedObjectContextObjectsDidChangeNotification
object:context];
#if TARGET_OS_IPHONE
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveMemoryWarning:)
@@ -153,10 +153,10 @@
if (error) {
RKLogError(@"Failed to retrieve managed object with ID %@. Error %@\n%@", objectID, [error localizedDescription], [error userInfo]);
}
return nil;
}
return object;
}

View File

@@ -36,7 +36,7 @@
/**
Initializes the receiver with a given entity.
@param entity An entity with which to initialize the receiver.
@returns The receiver, initialized with the given entity.
*/
@@ -45,12 +45,12 @@
/**
A convenience initializer that creates and returns an entity mapping for the entity with the given name in
the managed object model of the given managed object store.
This method is functionally equivalent to the following example code:
NSEntityDescription *entity = [[managedObjectStore.managedObjectModel entitiesByName] objectForKey:entityName];
return [RKEntityMapping mappingForEntity:entity];
@param entityName The name of the entity in the managed object model for which an entity mapping is to be created.
@param managedObjectStore A managed object store containing the managed object model in which an entity with the given name is defined.
@return A new entity mapping for the entity with the given name in the managed object model of the given managed object store.
@@ -84,14 +84,14 @@
/**
Retrieves an array of RKConnectionMapping objects for connecting the receiver's relationships
by primary key.
@see RKConnectionMapping
*/
@property (weak, nonatomic, readonly) NSArray *connectionMappings;
/**
Adds a connection mapping to the receiver.
@param connectionMapping The connection mapping to be added.
*/
- (void)addConnectionMapping:(RKConnectionMapping *)connectionMapping;
@@ -105,7 +105,7 @@
/**
Removes a connection mapping from the receiver.
@param connectionMapping The connection mapping to be added.
*/
- (void)removeConnectionMapping:(RKConnectionMapping *)connectionMapping;

View File

@@ -64,7 +64,7 @@
inManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
{
NSArray *objects = [self findInstancesOfEntity:entity withPrimaryKeyAttribute:primaryKeyAttribute value:primaryKeyValue inManagedObjectContext:managedObjectContext];
NSManagedObject *object = nil;
if ([objects count] > 0) {
object = [objects objectAtIndex:0];

View File

@@ -19,7 +19,7 @@
Initializes the receiver with a managed object context that is to be observed
and used to populate the in memory cache. The receiver may then be used to fulfill
cache requests for child contexts of the given managed object context.
@param managedObjectContext The managed object context with which to initialize the receiver.
@return The receiver, initialized with the given managed object context.
*/

View File

@@ -30,7 +30,7 @@
if (self) {
self.entityCache = [[RKEntityCache alloc] initWithManagedObjectContext:managedObjectContext];
}
return self;
}
@@ -65,7 +65,7 @@
inManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
{
NSAssert(self.entityCache, @"Entity cache cannot be nil.");
if (! [self.entityCache isEntity:entity cachedByAttribute:primaryKeyAttribute]) {
RKLogInfo(@"Caching instances of Entity '%@' by primary key attribute '%@'", entity.name, primaryKeyAttribute);
[self.entityCache cacheObjectsForEntity:entity byAttribute:primaryKeyAttribute];

View File

@@ -16,7 +16,7 @@
operations where the mapped objects exist within a Core Data managed object context. The class
is responsible for finding exist managed object instances by primary key, instantiating new managed
objects, and connecting relationships for mapped objects.
@see RKMappingOperationDataSource
@see RKConnectionMapping
*/
@@ -31,7 +31,7 @@
The managed object cache utilized by the receiver to find existing managed object instances
by primary key. A nil managed object cache will result in the insertion of new managed objects for
all mapped content.
@see RKFetchRequestManagedObjectCache
@see RKInMemoryManagedObjectCache
*/
@@ -45,7 +45,7 @@
/**
Initializes the receiver with a given managed object context and managed object cache.
@param managedObjectContext The managed object context with which to associate the receiver. Cannot be nil.
@param managedObjectCache The managed object cache used by the receiver to find existing object instances by primary key.
@return The receiver, initialized with the given managed object context and managed objet cache.

View File

@@ -27,13 +27,13 @@
- (id)initWithManagedObjectContext:(NSManagedObjectContext *)managedObjectContext cache:(id<RKManagedObjectCaching>)managedObjectCache
{
NSParameterAssert(managedObjectContext);
self = [self init];
if (self) {
self.managedObjectContext = managedObjectContext;
self.managedObjectCache = managedObjectCache;
}
return self;
}
@@ -42,19 +42,19 @@
{
NSAssert(mappableContent, @"Mappable data cannot be nil");
NSAssert(self.managedObjectContext, @"%@ must be initialized with a managed object context.", [self class]);
if (! [mapping isKindOfClass:[RKEntityMapping class]]) {
return [mapping.objectClass new];
}
RKEntityMapping *entityMapping = (RKEntityMapping *)mapping;
id object = nil;
id primaryKeyValue = nil;
NSString *primaryKeyAttribute;
NSEntityDescription *entity = [entityMapping entity];
RKAttributeMapping *primaryKeyAttributeMapping = nil;
primaryKeyAttribute = [entityMapping primaryKeyAttribute];
if (primaryKeyAttribute) {
// If a primary key has been set on the object mapping, find the attribute mapping
@@ -65,7 +65,7 @@
break;
}
}
// 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...");
@@ -79,7 +79,7 @@
}
}
}
if (! self.managedObjectCache) {
RKLogWarning(@"Performing managed object mapping with a nil managed object cache:\n"
"Unable to update existing object instances by primary key. Duplicate objects may be created.");
@@ -90,29 +90,29 @@
object = [self.managedObjectCache findInstanceOfEntity:entity
withPrimaryKeyAttribute:primaryKeyAttribute
value:primaryKeyValue
inManagedObjectContext:self.managedObjectContext];
inManagedObjectContext:self.managedObjectContext];
if (object && [self.managedObjectCache respondsToSelector:@selector(didFetchObject:)]) {
[self.managedObjectCache didFetchObject:object];
}
}
if (object == nil) {
object = [[NSManagedObject alloc] initWithEntity:entity
insertIntoManagedObjectContext:self.managedObjectContext];
if (primaryKeyAttribute && primaryKeyValue && ![primaryKeyValue isEqual:[NSNull null]]) {
[object setValue:primaryKeyValue forKey:primaryKeyAttribute];
}
if ([self.managedObjectCache respondsToSelector:@selector(didCreateObject:)]) {
[self.managedObjectCache didCreateObject:object];
}
}
return object;
}
/*
/*
Mapping operations should be executed against managed object contexts with NSPrivateQueueConcurrencyType
*/
- (BOOL)executingConnectionOperationsWouldDeadlock
@@ -134,7 +134,7 @@
{
if ([mappingOperation.mapping isKindOfClass:[RKEntityMapping class]]) {
[self emitDeadlockWarningIfNecessary];
for (RKConnectionMapping *connectionMapping in [(RKEntityMapping *)mappingOperation.mapping connectionMappings]) {
RKRelationshipConnectionOperation *operation = [[RKRelationshipConnectionOperation alloc] initWithManagedObject:mappingOperation.destinationObject
connectionMapping:connectionMapping

View File

@@ -30,46 +30,46 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
THe RKManagedObjectStore class encapsulates a Core Data stack including a
managed object model, a persistent store coordinator, and a set of managed
object contexts. The managed object store simplifies the task of properly
object contexts. The managed object store simplifies the task of properly
setting up a Core Data stack and provides some additional functionality, such
as the use of a seed database to initialize a SQLite backed persistent store and
a simple code path for resetting the store by destroying and recreating the persistent
stores.
## Initialization
The managed object store is designed to easily initialize a Core Data stack in a recommended
configuration. A store object must always be initialized with a managed object model, but this
managed object model can be directly provided, inferred from an already configured persistent
store coordinator, or read from the currently available bundles within the application. Note
that several features provided by the framework rely on the store being initialized with a mutable
managed object model. Please refer to the documentation in the initWithManagedObjectModel: for details.
## Managed Object Contexts
The managed object store provides the application developer with a pair of managed
objects with which to work with Core Data. The store configures a primary managed object
context with the NSPrivateQueueConcurrencyType that is associated with the
context with the NSPrivateQueueConcurrencyType that is associated with the
persistent store coordinator for handling Core Data persistence. A second context is also
created with the NSMainQueueConcurrencyType that is a child of the primary managed object
context for doing work on the main queue. Additional child contexts can be created directly
or via a convenience method interface provided by the store (see newChildManagedObjectContextWithConcurrencyType:).
The managed object context hierarchy is designed to isolate the main thread from disk I/O
and avoid deadlocks. Because the primary context manages its own private queue, saving the
main queue context will not result in the objects being saved to the persistent store. The primary
context must be saved as well for objects to be persisted to disk.
It is also worth noting that because of the parent/child context hierarchy, objects created on the main
thread will not obtain permanent managed object ID's even after the primary context has been saved.
context must be saved as well for objects to be persisted to disk.
It is also worth noting that because of the parent/child context hierarchy, objects created on the main
thread will not obtain permanent managed object ID's even after the primary context has been saved.
If you need to refer to the permanent representations of objects created on the main thread after a save,
you may ask the main queue context to obtain permanent managed objects for your objects via `obtainPermanentIDsForObjects:error:`.
Be warned that when obtaining permanent managed object ID's, you must include all newly created objects
you may ask the main queue context to obtain permanent managed objects for your objects via `obtainPermanentIDsForObjects:error:`.
Be warned that when obtaining permanent managed object ID's, you must include all newly created objects
that are reachable from the object you are concerned with in the set of objects provided to `obtainPermanentIDsForObjects:error:`.
This means any newly created object in a one-to-one or one-to-many relationship must be provided or you
will face a crash from the managed object context. This is due to a bug in Core Data present as of iOS 6
(see Open Radar http://openradar.appspot.com/11478919).
@see NSManagedObjectContext (RKAdditions)
@see NSEntityDescription (RKAdditions)
*/
@@ -81,14 +81,14 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Returns the default managed object store for the application.
@return The default managed object store.
*/
+ (RKManagedObjectStore *)defaultStore;
/**
Sets the default managed object store for the application.
@param managedObjectStore The new default managed object store.
*/
+ (void)setDefaultStore:(RKManagedObjectStore *)managedObjectStore;
@@ -99,15 +99,15 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Initializes the receiver with a given managed object model. This is the designated initializer for RKManagedObjectStore.
@param managedObjectModel The managed object model with which to initialize the receiver.
@return The receiver, initialized with the given managed object model.
@bug Several features require that the managed object model used to initialize the store be mutable so
that entities may be changed before the persistent store coordinator is created. Since iOS 5, managed object models
initialized via initWithContentsOfURL: return an immutable model. The application developer must send the returned
initialized via initWithContentsOfURL: return an immutable model. The application developer must send the returned
managed object model a mutable copy message to ensure that it is mutable before initializing the managed object store.
The recommended approach for initializing a managed object store is as follows:
NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MyApplication" ofType:@"momd"]];
// NOTE: Due to an iOS 5 bug, the managed object model returned is immutable.
NSManagedObjectModel *managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy];
@@ -117,13 +117,13 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Initializes the receiver with an existing persistent store coordinator.
The managed object model from the persistent store coordinator will be used to initialize the receiver
The managed object model from the persistent store coordinator will be used to initialize the receiver
and the given persistent store coordinator will be configured as the persistent store coordinator for the
managed object store.
This initialization method provides for easy integration with an existing Core Data stack.
@param persistentStoreCoordinator The persistent store coordinator with which to initialize the receiver.
@return The receiver, initialized with the managed object model of the given persistent store coordinator and
the persistent store coordinator.
@@ -133,10 +133,10 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Initializes the receiver with a managed object model obtained by merging the models from all of
the application's non-framework bundles.
@see [NSBundle allBundles]
@see [NSManagedObjectModel mergedModelFromBundles:]
@warning Obtaining a managed object model by merging all bundles may result in an application error
if versioned object models are in use.
*/
@@ -149,7 +149,7 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Creates a persistent store coordinator with the receiver's managed object model. After invocation,
the persistentStoreCoordinator property will no longer be nil.
@warning Creating the persistent store coordinator will render the managed object model
immutable. Attempts to use functionality that requires a mutable managed object model after
the persistent store coordinator has been created will raise an application error.
@@ -158,10 +158,10 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Adds a new in memory persistent store to the persistent store coordinator of the receiver.
This method will invoke createPersistentStore if a persistent store coordinator has not yet been created.
@param error On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error
@param error On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error
object containing the error information. You may specify nil for this parameter if you do not want the error information.
@returns The new persistent store, or nil in the event of an error.
*/
@@ -169,12 +169,12 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Adds a new SQLite persistent store, optionally initialized with a seed database, to the persistent store coordinator of the receiver.
@param storePath The path at which to save the persistent store on disk.
@param seedPath An optional path to a seed database to copy to the given storePath in the event that a store does not yet exist.
@param error On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error
object containing the error information. You may specify nil for this parameter if you do not want the error information.
@warning If the seed database at the given path was created with an incompatible managed object model an application error
may be raised.
*/
@@ -184,13 +184,13 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
Resets the persistent stores in the receiver's persistent store coordinator and recreates them. If a store being reset
is backed by a file on disk (such as a SQLite file), the file will be removed prior to recreating the store. If the
store was originally created using a seed database, the seed will be recopied to reset the store to its seeded state.
@param error On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error
object containing the error information. You may specify nil for this parameter if you do not want the error information.
@return A Boolean value indicating if the reset was successful.
@warning This method will implictly result in the managed object contexts associated with the receiver to be discarded
and recreated. Any managed objects or additional child contexts associated with the store will need to be discarded or else
and recreated. Any managed objects or additional child contexts associated with the store will need to be discarded or else
exceptions may be raised (i.e. NSObjectInaccessibleException).
*/
- (BOOL)resetPersistentStores:(NSError **)error;
@@ -201,24 +201,24 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Returns the managed object model of the receiver.
@return The managed object model of the receiver.
*/
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;
/**
Returns the persistent store coordinator of the receiver.
@return The persistent store coordinator of the receiver.
*/
@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
/**
The managed object cache associated with the receiver.
The managed object cache is used to accelerate intensive Core Data operations by
caching managed objects by their primary key value.
@see RKManagedObjectCaching
@warning A nil managed object cache will result in a store that is unable to uniquely identify
existing objects by primary key attribute value and may result in the creation of duplicate objects
@@ -232,7 +232,7 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Creates the primary and main queue managed object contexts for the receiver.
@see primaryManagedObjectContext
@see mainQueueManagedObjectContext
@raises NSInternalInconsistencyException Raised if the managed object contexts have already been created.
@@ -241,20 +241,20 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
The primary managed object context of the receiver.
The primary context is responsible for managing persistence to the persistent store coordinator for the
managed object store. The context is created with the NSPrivateQueueConcurrencyType and as such must
be interacted with using [NSManagedObjectContext performBlock:] or [NSManagedObjectContext performBlockAndWait:].
The primary context is useful as the parent context for scratch contexts or main queue contexts for interacting
with the user interface. Created by the invocation of createManagedObjectContexts.
@see createManagedObjectContexts
*/
@property (nonatomic, strong, readonly) NSManagedObjectContext *primaryManagedObjectContext;
/**
The main queue managed object context of the receiver.
The main queue context is available for usage on the main queue to drive user interface needs. The context is
created with the NSMainQueueConcurrencyType and as such may be messaged directly from the main thread. The context
is a child context of the primaryManagedObjectContext and can persist changes up to the parent via a save.
@@ -263,7 +263,7 @@ extern NSString * const RKSQLitePersistentStoreSeedDatabasePathOption;
/**
Creates a new child managed object context of the primary managed object context with a given concurrency type.
@param concurrencyType The desired concurrency type for the new context.
@return A newly created managed object context with the given concurrency type whose parent is the primaryManagedObjectContext.
*/

View File

@@ -105,20 +105,20 @@ static RKManagedObjectStore *defaultStore = nil;
- (NSPersistentStore *)addInMemoryPersistentStore:(NSError **)error
{
if (! self.persistentStoreCoordinator) [self createPersistentStoreCoordinator];
return [self.persistentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:error];
}
- (NSPersistentStore *)addSQLitePersistentStoreAtPath:(NSString *)storePath fromSeedDatabaseAtPath:(NSString *)seedPath error:(NSError **)error
{
if (! self.persistentStoreCoordinator) [self createPersistentStoreCoordinator];
NSURL *storeURL = [NSURL fileURLWithPath:storePath];
if (seedPath) {
BOOL success = [self copySeedDatabaseIfNecessaryFromPath:seedPath toPath:storePath error:error];
if (! success) return nil;
}
// Allow inferred migration from the original version of the application.
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
(seedPath ? seedPath : [NSNull null]), RKSQLitePersistentStoreSeedDatabasePathOption,
@@ -152,7 +152,7 @@ static RKManagedObjectStore *defaultStore = nil;
managedObjectContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy;
managedObjectContext.managedObjectStore = self;
}];
return managedObjectContext;
}
@@ -166,13 +166,13 @@ static RKManagedObjectStore *defaultStore = nil;
self.primaryManagedObjectContext.persistentStoreCoordinator = self.persistentStoreCoordinator;
self.primaryManagedObjectContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy;
self.primaryManagedObjectContext.managedObjectStore = self;
// Create an MOC for use on the main queue
self.mainQueueManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
self.mainQueueManagedObjectContext.parentContext = self.primaryManagedObjectContext;
self.mainQueueManagedObjectContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy;
self.mainQueueManagedObjectContext.managedObjectStore = self;
// Merge changes from a primary MOC back into the main queue when complete
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handlePrimaryManagedObjectContextDidSaveNotification:)
@@ -183,7 +183,7 @@ static RKManagedObjectStore *defaultStore = nil;
- (void)recreateManagedObjectContexts
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:self.primaryManagedObjectContext];
self.primaryManagedObjectContext = nil;
self.mainQueueManagedObjectContext = nil;
[self createManagedObjectContexts];

View File

@@ -76,7 +76,7 @@
[collection addObject:subObject];
}
}
[self setValue:collection forKeyPathOrKey:keyPath object:argument];
}
}
@@ -110,7 +110,7 @@
[collection addObject:subObject];
}
}
[self setValue:collection forKeyPathOrKey:keyPath object:argument];
}

View File

@@ -13,16 +13,16 @@
/**
The RKRelationshipConnectionOperation class is a subclass of NSOperation that manages the connection
of NSManagedObject relationships as described by an RKConnectionMapping object. When executed, the
of NSManagedObject relationships as described by an RKConnectionMapping object. When executed, the
operation will find related objects by searching the associated managed object cache for a matching object
whose destination attribute value matches that of the associated managed object's source attribute.
For example, given a managed object for the `Employee` entity with a one-to-one relationship to a `Company` named `company`
(with an inverse relationship one-to-many relationship named `employees`) and a connection mapping specifying that
the relationship can be connected by finding the `Company` managed object whose `companyID` attribute matches the
the relationship can be connected by finding the `Company` managed object whose `companyID` attribute matches the
`companyID` of the `Employee`, the operation would find the Company that employs the Employee by primary key and set
the Core Data relationship to reflect the relationship appropriately.
@see RKConnectionMapping
*/
@interface RKRelationshipConnectionOperation : NSOperation
@@ -45,7 +45,7 @@
/**
Initializes the receiver with a given managed object, connection mapping, and managed object cache.
@param managedObject The object to attempt to connect a relationship to.
@param connectionMapping A mapping describing the relationship and attributes necessary to perform the connection.
@param managedObjectCache The managed object cache from which to attempt to fetch a matching object to satisfy the connection.

View File

@@ -38,7 +38,7 @@
self.connectionMapping = connectionMapping;
self.managedObjectCache = managedObjectCache;
}
return self;
}
@@ -103,14 +103,14 @@
- (NSMutableSet *)findAllConnectedWithSourceValue:(id)sourceValue
{
NSMutableSet *result = [NSMutableSet set];
id values = nil;
if ([sourceValue conformsToProtocol:@protocol(NSFastEnumeration)]) {
values = sourceValue;
} else {
values = [NSArray arrayWithObject:sourceValue];
}
for (id value in values) {
NSArray *objects = [self.managedObjectCache findInstancesOfEntity:self.connectionMapping.relationship.destinationEntity
withPrimaryKeyAttribute:self.connectionMapping.destinationKeyPath

View File

@@ -33,7 +33,7 @@
if (self) {
self.baseURL = baseURL;
}
return self;
}
@@ -43,7 +43,7 @@
if (self) {
self.routeSet = [RKRouteSet new];
}
return self;
}
@@ -66,7 +66,7 @@
- (RKURL *)URLForRelationship:(NSString *)relationshipName ofObject:(id)object method:(RKRequestMethod)method
{
RKRoute *route = [self.routeSet routeForRelationship:relationshipName ofClass:[object class] method:method];
if (! route) return nil;
if (! route) return nil;
return [RKURL URLWithString:[self pathFromRoute:route forObject:object] relativeToURL:self.baseURL];
}

View File

@@ -29,29 +29,29 @@
/**
Creates and returns a new attribute mapping specifying that data is to be read from a given key path on a source object
and set to a given key path on a destination object.
Attribute mappings define transformation between key paths in the source and destination object beings mapped. In the simplest
case, an attribute mapping may simply specify that data from one object is to be copied to another. A common example of this
type of transformation is copying the `name` key from a JSON payload onto a local object. In this case, the source and
type of transformation is copying the `name` key from a JSON payload onto a local object. In this case, the source and
destination key paths are identical, as are the source and destination types (NSString), so a simple get and set operation
has been defined.
has been defined.
The next most common use-case is the transformation of identical data between two different key paths in the
source and destination objects. This is typically encountered when you wish to transform inbound data to conform with the naming
conventions of the platform or the data model of your application. An example of this type of transformation would be from the
conventions of the platform or the data model of your application. An example of this type of transformation would be from the
source key path of `first_name` to the destination key path of `firstName`. In this transformation, the key paths have diverged
but both sides of the mapping correspond to NSString properties.
The final type of transformation to be specified via an attribute mapping involves the transformation between types in the mapping.
By far, the most common example of this use-case is the transformation of a inbound string or numeric property into a date on
the target object. For example, consider a backend system that returns the creation date of a piece of content in a JSON payload.
This data might be returned in JSON as `{"created_on": "2012-08-27"}`. In a given application, the developer may wish to model this
data as an NSDate `createdOn` property on the target object. An attribute mapping to support this mapping would specify a source
data as an NSDate `createdOn` property on the target object. An attribute mapping to support this mapping would specify a source
key path of `created_on` and a destination key path of `createdOn`. On the destination object, the `createdOn` property would be defined
as `@property (nonatomic, strong) NSDate *createdOn;`. At mapping time, the mapping operation inspects the type of the content being
mapped and attempts to transform the source content into the type of the desination property specified by the mapping. In this case,
mapped and attempts to transform the source content into the type of the desination property specified by the mapping. In this case,
an NSDateFormatter object would be used to process the inbound NSString into an outbound NSDate object.
@param sourceKeyPath The key path on the source object from which to read the data being mapped.
@param destinationKeyPath The key path on the destination object on which to set the mapped data.
@return A newly created attribute mapping object that is ready to be added to an object mapping.

View File

@@ -33,25 +33,25 @@ typedef id(^RKObjectConnectionBlock)(RKConnectionMapping *mapping, id source);
appropriate target object(s). It does this by using the value of the object's
fromKeyPath attribute to query instances of the target entity that have the
same value in their toKeyPath attribute.
Note that connectRelationship runs *after* an object's attributes have been
mapped and is dependent upon the results of those mappings. Also, connectRelationship
will never create a new object - it simply looks up existing objects. In effect,
connectRelationship allows foreign key relationships between managed objects
to be automatically maintained from the server to the underlying Core Data object graph.
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" withMapping:userMapping fromKeyPath:@"userId" toKeyPath:@"id"];
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.
You can also do the reverse. Given a User object associated with a Project, with a
'project' relationship:
[mapping connectRelationship:@"project" fromKeyPath:@"id" toKeyPath:@"userId" withMapping:projectMapping];
*/
//- (void)connectRelationship:(NSString *)relationshipName fromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKMapping *)objectOrDynamicMapping DEPRECATED_ATTRIBUTE;
@@ -59,17 +59,17 @@ typedef id(^RKObjectConnectionBlock)(RKConnectionMapping *mapping, id source);
/**
Conditionally connect a relationship of the object being mapped when the object being mapped has
keyPath equal to a specified value.
For example, given a Project object associated with a User, where the 'admin' relationship is
specified by a adminID property on the managed object:
[mapping connectRelationship:@"admin" fromKeyPath:@"adminId" toKeyPath:@"id" withMapping:userMapping whenValueOfKeyPath:@"userType" isEqualTo:@"Admin"];
Will hydrate the 'admin' 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. Note that this connection will only occur when the Product's 'userType'
property equals 'Admin'. In cases where no match occurs, the relationship connection is skipped.
@see connectRelationship:withObjectForPrimaryKeyAttribute:
*/
// - (void)connectRelationship:(NSString *)relationshipName fromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKMapping *)objectOrDynamicMapping whenValueOfKeyPath:(NSString *)keyPath isEqualTo:(id)value DEPRECATED_ATTRIBUTE;
@@ -77,19 +77,19 @@ typedef id(^RKObjectConnectionBlock)(RKConnectionMapping *mapping, id source);
Conditionally connect a relationship of the object being mapped when the object being mapped has
block evaluate to YES. This variant is useful in cases where you want to execute an arbitrary
block to determine whether or not to connect a relationship.
For example, given a Project object associated with a User, where the 'admin' relationship is
specified by a adminID property on the managed object:
[mapping connectRelationship:@"admin" fromKeyPath:@"adminId" toKeyPath:@"adminID" withMapping:userMapping usingEvaluationBlock:^(id data) {
return [User isAuthenticated];
}];
Will hydrate the 'admin' 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. Note that this connection will only occur when the provided block evalutes to YES.
In cases where no match occurs, the relationship connection is skipped.
@see connectRelationship:withObjectForPrimaryKeyAttribute:
*/

View File

@@ -26,7 +26,7 @@ RKRequestMethod RKRequestMethodFromString(NSString *);
/**
The HTTP status code classes
See http://tools.ietf.org/html/rfc2616#section-10
*/
enum {
@@ -40,7 +40,7 @@ typedef NSUInteger RKStatusCodeClass;
/**
Creates a new range covering the status codes in the given class.
@param statusCodeClass The status code class to create a range covering.
@return A new range covering the status codes in the given class.
*/
@@ -48,7 +48,7 @@ NSRange RKStatusCodeRangeForClass(RKStatusCodeClass statusCodeClass);
/**
Creates a new index set covering the status codes in the given class.
@param statusCodeClass The status code class to create an index set covering.
@return A new index set covering the status codes in the given class.
*/

View File

@@ -26,31 +26,31 @@ NSString *RKStringFromRequestMethod(RKRequestMethod method)
case RKRequestMethodGET:
return @"GET";
break;
case RKRequestMethodPOST:
return @"POST";
break;
case RKRequestMethodPUT:
return @"PUT";
break;
case RKRequestMethodPATCH:
return @"PATCH";
break;
case RKRequestMethodDELETE:
return @"DELETE";
break;
case RKRequestMethodHEAD:
return @"HEAD";
break;
default:
break;
}
return nil;
}
@@ -69,6 +69,6 @@ RKRequestMethod RKRequestMethodFromString(NSString *methodName)
} else if ([methodName isEqualToString:@"PATCH"]) {
return RKRequestMethodPATCH;
}
return RKRequestMethodInvalid;
}

View File

@@ -38,7 +38,7 @@ typedef NSFetchRequest * (^RKFetchRequestBlock)(NSURL *URL);
/**
A Boolean value that determines if the receiver will delete orphaned objects upon
completion of the operation.
**Default**: NO
*/
@property (nonatomic, assign) BOOL deletesOrphanedObjects;

View File

@@ -148,7 +148,7 @@
RKLogDebug(@"Skipping deletion of orphaned objects: deletesOrphanedObjects=NO");
return YES;
}
if (! [[self.requestOperation.request.HTTPMethod uppercaseString] isEqualToString:@"GET"]) {
RKLogDebug(@"Skipping cleanup of objects via managed object cache: only used for GET requests.");
return YES;

View File

@@ -85,13 +85,13 @@
/**
Tells the delegate that the mapping operation has selected a concrete object mapping with which to map the source object.
Only sent if the receiver was initialized with an instance of RKDynamicMapping as the mapping.
@param operation The mapping operation.
@param objectMapping The concrete object mapping with which to perform the mapping.
@param dynamicMapping The dynamic source mapping from which the object mapping was determined.
@since 0.11.0
*/
- (void)mappingOperation:(RKMappingOperation *)operation didSelectObjectMapping:(RKObjectMapping *)objectMapping forDynamicMapping:(RKDynamicMapping *)dynamicMapping;
@@ -121,7 +121,7 @@
/**
The mapping defining how values contained in the source object should be transformed to the destination object via key-value coding.
Will either be an instance of RKObjectMapping or RKDynamicMapping.
*/
@property (nonatomic, strong, readonly) RKMapping *mapping;

View File

@@ -643,12 +643,12 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
{
RKLogDebug(@"Starting mapping operation...");
RKLogTrace(@"Performing mapping operation: %@", self);
// Determine the concrete mapping if we were initialized with a dynamic mapping
if ([self.mapping isKindOfClass:[RKDynamicMapping class]]) {
self.objectMapping = [(RKDynamicMapping *)self.mapping objectMappingForDictionary:self.sourceObject];
RKLogDebug(@"RKObjectMappingOperation was initialized with a dynamic mapping. Determined concrete mapping = %@", self.objectMapping);
if ([self.delegate respondsToSelector:@selector(mappingOperation:didSelectObjectMapping:forDynamicMapping:)]) {
[self.delegate mappingOperation:self didSelectObjectMapping:self.objectMapping forDynamicMapping:(RKDynamicMapping *)self.mapping];
}
@@ -662,7 +662,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
BOOL mappedRelationships = [self applyRelationshipMappings];
if ((mappedAttributes || mappedRelationships) && _validationError == nil) {
RKLogDebug(@"Finished mapping operation successfully...");
if ([self.dataSource respondsToSelector:@selector(commitChangesForMappingOperation:)]) {
[self.dataSource commitChangesForMappingOperation:self];
}

View File

@@ -75,14 +75,14 @@ static NSOperationQueue *defaultMappingQueue = nil;
if (self) {
self.HTTPClient = client;
[self.HTTPClient registerHTTPOperationClass:[RKHTTPRequestOperation class]];
self.router = [[RKRouter alloc] initWithBaseURL:client.baseURL];
self.acceptMIMEType = RKMIMETypeJSON;
self.operationQueue = [NSOperationQueue new];
self.mutableRequestDescriptors = [NSMutableArray new];
self.mutableResponseDescriptors = [NSMutableArray new];
self.mutableFetchRequestBlocks = [NSMutableArray new];
self.serializationMIMEType = RKMIMETypeFormURLEncoded;
self.mappingQueue = [RKObjectManager defaultMappingQueue];
@@ -234,7 +234,7 @@ static NSOperationQueue *defaultMappingQueue = nil;
} else {
requestParameters = parameters;
}
return [self.HTTPClient requestWithMethod:stringMethod path:requestPath parameters:requestParameters];
}
@@ -257,7 +257,7 @@ static NSOperationQueue *defaultMappingQueue = nil;
} else {
requestParameters = parameters;
}
return [self.HTTPClient multipartFormRequestWithMethod:stringMethod path:requestPath parameters:requestParameters constructingBodyWithBlock:block];
}
@@ -300,7 +300,7 @@ static NSOperationQueue *defaultMappingQueue = nil;
TODO: Test cases...
1) Managed object
2) Non managed object, request descriptors with entity
Does it make sense to assume the main queue MOC here?
*/
- (id)objectRequestOperationWithObject:(id)object method:(RKRequestMethod)method path:(NSString *)path parameters:(NSDictionary *)parameters
@@ -314,7 +314,7 @@ static NSOperationQueue *defaultMappingQueue = nil;
RKLogInfo(@"Asked to perform object request with NSManagedObject with temporary object ID: Obtaining permanent ID before proceeding.");
__block BOOL _blockSuccess;
__block NSError *_blockError;
[[object managedObjectContext] performBlockAndWait:^{
_blockSuccess = [[object managedObjectContext] obtainPermanentIDsForObjects:@[object] error:&_blockError];
}];

View File

@@ -49,7 +49,7 @@ NSString * const RKMappingErrorKeyPathErrorKey = @"keyPath";
self.mappingErrors = [NSMutableArray new];
self.mappingOperationDataSource = [RKObjectMappingOperationDataSource new];
}
return self;
}
@@ -238,7 +238,7 @@ NSString * const RKMappingErrorKeyPathErrorKey = @"keyPath";
{
NSAssert([mapping isKindOfClass:[RKMapping class]], @"Expected an RKMapping object");
NSAssert(self.mappingOperationDataSource, @"Cannot find or instantiate objects without a data source");
RKObjectMapping *objectMapping = nil;
if ([mapping isKindOfClass:[RKDynamicMapping class]]) {
objectMapping = [(RKDynamicMapping *)mapping objectMappingForDictionary:mappableData];

View File

@@ -144,7 +144,7 @@ relationship. Relationships are processed using an object mapping as well.
/**
Removes an instance of an attribute or relationship mapping from the object mapping
@param attributeOrRelationshipMapping The attribute or relationship mapping to remove
*/
- (void)removePropertyMapping:(RKPropertyMapping *)propertyMapping;
@@ -154,7 +154,7 @@ relationship. Relationships are processed using an object mapping as well.
/**
Adds attribute mappings from a given dictionary wherein the keys represent the source key path
and the values represent the names of the target attributes on the destination object.
@param keyPathToAttributeNames A dictionary keyed by source key to destination attribute name.
*/
- (void)addAttributeMappingsFromDictionary:(NSDictionary *)keyPathToAttributeNames;

View File

@@ -41,11 +41,11 @@
/**
Compares the receiving property mapping to another property mapping.
Two property mappings are equal if they are of the same type (i.e. an attribute or a
relationship mapping) and specify a mapping from the same source key path to the
relationship mapping) and specify a mapping from the same source key path to the
same destination key path.
@param otherMapping The property mapping object with which to compare the receiver.
@return YES if otherMapping specifies the same mapping as the receiver, otherwise NO.
*/

View File

@@ -22,7 +22,7 @@
{
NSParameterAssert(mapping);
NSParameterAssert(objectClass);
RKRequestDescriptor *requestDescriptor = [self new];
requestDescriptor.mapping = mapping;
requestDescriptor.objectClass = objectClass;

View File

@@ -24,7 +24,7 @@
// Cloned from AFStringFromIndexSet -- method should be non-static for reuse
static NSString * RKStringFromIndexSet(NSIndexSet *indexSet) {
NSMutableString *string = [NSMutableString string];
NSRange range = NSMakeRange([indexSet firstIndex], 1);
while (range.location != NSNotFound) {
NSUInteger nextIndex = [indexSet indexGreaterThanIndex:range.location];
@@ -32,11 +32,11 @@ static NSString * RKStringFromIndexSet(NSIndexSet *indexSet) {
range.length++;
nextIndex = [indexSet indexGreaterThanIndex:nextIndex];
}
if (string.length) {
[string appendString:@","];
}
if (range.length == 1) {
[string appendFormat:@"%u", range.location];
} else {
@@ -44,11 +44,11 @@ static NSString * RKStringFromIndexSet(NSIndexSet *indexSet) {
NSUInteger lastIndex = firstIndex + range.length - 1;
[string appendFormat:@"%u-%u", firstIndex, lastIndex];
}
range.location = nextIndex;
range.length = 1;
}
return string;
}
@@ -67,13 +67,13 @@ static NSString * RKStringFromIndexSet(NSIndexSet *indexSet) {
statusCodes:(NSIndexSet *)statusCodes
{
NSParameterAssert(mapping);
RKResponseDescriptor *mappingDescriptor = [self new];
mappingDescriptor.mapping = mapping;
mappingDescriptor.pathPattern = pathPattern;
mappingDescriptor.keyPath = keyPath;
mappingDescriptor.statusCodes = statusCodes;
return mappingDescriptor;
}

View File

@@ -22,23 +22,23 @@
#import <RestKit/RKSearchIndexer.h>
/**
The search additions category provides support for configuring search indexing
The search additions category provides support for configuring search indexing
for entities in a managed object store.
*/
@interface RKManagedObjectStore (RKSearchAdditions)
/**
Adds search indexing to the entity for the given name in the receiver's managed object model.
Invocation of this method will result in the entity for the given name being updated to include a new
to-many relationship with the name 'searchWords'. The receiver's search indexer will also be instructed
to begin monitoring changes to the specified entity's searchable attributes to maintain the collection
of search words. If no search indexer exists, a new
of search words. If no search indexer exists, a new
@param entityName The name of the entity in the receiver's managed object model that should be made searchable.
@param attributes An array of NSAttributeDescription objects or NSString attribute names specifying the
@param attributes An array of NSAttributeDescription objects or NSString attribute names specifying the
NSStringAttributeType attributes that are to be indexed for searching.
@warning Must be invoked before adding persistent stores as the managed object model will become
immutable once the persistent store coordinator is created.
*/
@@ -46,7 +46,7 @@
/**
The search indexer for the receiver's primary managed object context.
A search indexer is instantiated when search indexing is added to an entity
in the receiver's managed object model.
*/
@@ -55,24 +55,24 @@
/**
Tells the search indexer to begin observing the primary managed object context for changes to searchable
entities and updating the search words.
This is a convenience method that is equivalent to the following example code:
RKSearchIndexer *searchIndexer = managedObjectStore.searchIndexer;
[searchIndexer startObservingManagedObjectContext:managedObjectStore.primaryManagedObjectContext];
@see RKSearchIndexer
*/
- (void)startIndexingPrimaryManagedObjectContext;
/**
Tells the search indexer to stop observing the primary managed object context for changes to searchable entities.
This is a convenience method that is equivalent to the following example code:
RKSearchIndexer *searchIndexer = managedObjectStore.searchIndexer;
[searchIndexer stopObservingManagedObjectContext:managedObjectStore.primaryManagedObjectContext];
@see RKSearchIndexer
*/
- (void)stopIndexingPrimaryManagedObjectContext;

View File

@@ -36,9 +36,9 @@ static char searchIndexerAssociationKey;
- (void)addSearchIndexingToEntityForName:(NSString *)entityName onAttributes:(NSArray *)attributes
{
NSAssert(! self.persistentStoreCoordinator, @"Add indexing to your entities before adding persistent stores. The managed object model must be mutable to add indexing.");
if (! self.searchIndexer) [self createSearchIndexer];
NSEntityDescription *entity = [[self.managedObjectModel entitiesByName] objectForKey:entityName];
[RKSearchIndexer addSearchIndexingToEntity:entity onAttributes:attributes];
}

View File

@@ -40,15 +40,15 @@ extern NSString * const RKSearchableAttributeNamesUserInfoKey;
/**
Adds search indexing to the given entity for a given list of attributes identified by
name. The entity will have a to-many relationship to the RKSearchWordEntity added and
the list of searchable attributes stored into the user info dictionary.
the list of searchable attributes stored into the user info dictionary.
Managed objects for entities that have had indexing added to them can be indexed by instances of
RKSearchIndexer and searched via an RKSearchPredicate in a fetch request.
The given entity must exist in a mutable managed object model (that is, one that has not
been used to create an object graph in a managed object context). The given list of attributes
must identify attributes of the given entity with the attribute type of NSStringAttributeType.
@param entity The entity to which search indexing support is to be added.
@param attributes An array of NSAttributeDescription objects or NSString attribute names specifying the
NSStringAttributeType attributes that are to be indexed for searching.
@@ -70,12 +70,12 @@ extern NSString * const RKSearchableAttributeNamesUserInfoKey;
///-----------------------------------------------------------------------------
/**
Tells the receiver to tart monitoring the given managed object context for the
Tells the receiver to tart monitoring the given managed object context for the
NSManagedObjectContextWillSaveNotification and to index any changed objects prior
to the completion of the save.
@param managedObjectContext The managed object context to be monitored for save notifications.
@see indexChangedObjectsInManagedObjectContext:
*/
- (void)startObservingManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;
@@ -84,8 +84,8 @@ extern NSString * const RKSearchableAttributeNamesUserInfoKey;
Tells the receiver to stop monitoring the given managed object context for the
NSManagedObjectContextWillSaveNotification and cease indexing changed objects prior to
the completion of the save.
@param managedObjectContext The managed object context that is no longer to be monitored for
@param managedObjectContext The managed object context that is no longer to be monitored for
save notifications.
*/
- (void)stopObservingManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;
@@ -93,10 +93,10 @@ extern NSString * const RKSearchableAttributeNamesUserInfoKey;
/**
Tells the receiver to build a list of all inserted or updated managed objects in the given
context and index each one. Objects for entities that are not indexed are silently ignored.
Invoked by the indexer in response to a NSManagedObjectContextWillSaveNotification if the
context is being observed.
@param managedObjectContext The managed object context that is to be indexed.
*/
- (void)indexChangedObjectsInManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;
@@ -107,7 +107,7 @@ extern NSString * const RKSearchableAttributeNamesUserInfoKey;
/**
Tells the receiver to index a given managed object instance.
@param managedObject The managed object that is to be indexed.
@return A count of the number of search words that were indexed from the given object's
searchable attributes.

View File

@@ -24,17 +24,17 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
{
NSParameterAssert(entity);
NSParameterAssert(attributes);
// Create a relationship from the RKSearchWordEntity to the given searchable entity
NSEntityDescription *searchWordEntity = [[entity.managedObjectModel entitiesByName] objectForKey:RKSearchWordEntityName];
if (! searchWordEntity) {
searchWordEntity = [[RKSearchWordEntity alloc] init];
// Add the entity to the model
NSArray *entities = [entity.managedObjectModel entities];
[entity.managedObjectModel setEntities:[entities arrayByAddingObject:searchWordEntity]];
}
NSMutableArray *attributeNames = [NSMutableArray arrayWithCapacity:[attributes count]];
for (id attributeIdentifier in attributes) {
NSAttributeDescription *attribute = nil;
@@ -49,26 +49,26 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
reason:[NSString stringWithFormat:@"Unable to configure search indexing: Invalid attribute identifier of type '%@' given, expected an NSString or NSAttributeDescription. (Value: %@)", [attributeIdentifier class], attributeIdentifier]
userInfo:nil];
}
NSAssert(attribute.attributeType == NSStringAttributeType, @"Invalid attribute identifier given: Expected an attribute of type NSStringAttributeType, got %d.", attribute.attributeType);
[attributeNames addObject:attribute.name];
}
// Store the searchable attributes into the user info dictionary
NSMutableDictionary *userInfo = [[entity userInfo] mutableCopy];
[userInfo setObject:attributeNames forKey:RKSearchableAttributeNamesUserInfoKey];
[entity setUserInfo:userInfo];
// Create a relationship from our indexed entity to the RKSearchWord entity
NSRelationshipDescription *relationship = [[NSRelationshipDescription alloc] init];
[relationship setName:RKSearchWordsRelationshipName];
[relationship setDestinationEntity:searchWordEntity];
[relationship setMaxCount:0]; // Make it to-many
[relationship setDeleteRule:NSNullifyDeleteRule];
NSArray *properties = [entity properties];
[entity setProperties:[properties arrayByAddingObject:relationship]];
// Create an inverse relationship from the searchWords to the searchable entity
NSRelationshipDescription *inverseRelationship = [[NSRelationshipDescription alloc] init];
[inverseRelationship setName:entity.name];
@@ -76,17 +76,17 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
[inverseRelationship setDeleteRule:NSNullifyDeleteRule];
NSArray *searchWordProperties = [searchWordEntity properties];
[searchWordEntity setProperties:[searchWordProperties arrayByAddingObject:inverseRelationship]];
// Connect the relationships as inverses
[relationship setInverseRelationship:inverseRelationship];
[inverseRelationship setInverseRelationship:relationship];
}
- (void)startObservingManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
{
NSParameterAssert(managedObjectContext);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleManagedObjectContextWillSaveNotification:)
name:NSManagedObjectContextWillSaveNotification
@@ -96,30 +96,30 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
- (void)stopObservingManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
{
NSParameterAssert(managedObjectContext);
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextWillSaveNotification object:managedObjectContext];
}
- (NSUInteger)indexManagedObject:(NSManagedObject *)managedObject
{
@autoreleasepool {
RKLogDebug(@"Indexing searchable attributes of managed object: %@", managedObject);
NSArray *searchableAttributes = [managedObject.entity.userInfo objectForKey:RKSearchableAttributeNamesUserInfoKey];
if (! searchableAttributes) {
[NSException raise:NSInvalidArgumentException format:@"The given managed object %@ is for an entity (%@) that does not define any searchable attributes. Perhaps you forgot to invoke addSearchIndexingToEntity:onAttributes:?", managedObject, managedObject.entity];
return NSNotFound;
}
RKSearchTokenizer *searchTokenizer = [RKSearchTokenizer new];
searchTokenizer.stopWords = self.stopWords;
__block NSUInteger searchWordCount;
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:RKSearchWordEntityName];
fetchRequest.fetchLimit = 1;
NSPredicate *predicateTemplate = [NSPredicate predicateWithFormat:@"%K == $SEARCH_WORD", RKSearchWordAttributeName];
NSManagedObjectContext *managedObjectContext = managedObject.managedObjectContext;
[managedObjectContext performBlockAndWait:^{
NSMutableSet *searchWords = [NSMutableSet set];
for (NSString *searchableAttribute in searchableAttributes) {
@@ -140,7 +140,7 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
} else {
searchWord = [results objectAtIndex:0];
}
[searchWords addObject:searchWord];
} else {
RKLogError(@"Failed to retrieve search word: %@", error);
@@ -149,13 +149,13 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
}
}
}
[managedObject setValue:searchWords forKey:RKSearchWordsRelationshipName];
RKLogTrace(@"Indexed search words: %@", [searchWords valueForKey:RKSearchWordAttributeName]);
searchWordCount = [searchWords count];
}];
return searchWordCount;
}
}
@@ -165,7 +165,7 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
NSArray *candidateObjects = [[[NSSet setWithSet:managedObjectContext.insertedObjects] setByAddingObjectsFromSet:managedObjectContext.updatedObjects] allObjects];
NSUInteger totalObjects = [candidateObjects count];
RKLogInfo(@"Indexing %d changed objects in managed object context: %@", totalObjects, managedObjectContext);
for (NSManagedObject *managedObject in candidateObjects) {
NSUInteger index = [candidateObjects indexOfObject:managedObject];
double percentage = (((float)index + 1) / (float)totalObjects) * 100;
@@ -175,7 +175,7 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
RKLogTrace(@"Skipping indexing for managed object for entity '%@': no searchable attributes found.", managedObject.entity.name);
continue;
}
for (NSString *attribute in searchableAttributes) {
if ([[managedObject changedValues] objectForKey:attribute]) {
RKLogTrace(@"Detected change to searchable attribute '%@' for managed object '%@': updating search index.", attribute, managedObject);
@@ -192,7 +192,7 @@ NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttr
{
NSManagedObjectContext *managedObjectContext = [notification object];
RKLogInfo(@"Managed object context will save notification received. Checking changed and inserted objects for searchable entities...");
[self indexChangedObjectsInManagedObjectContext:managedObjectContext];
}

View File

@@ -23,17 +23,17 @@
/**
RKSearchPredicate is a suclass of NSCompoundPredicate used to represent
textual search operations against entities indexed by an instance of RKSearchIndexer.
@see RKSearchIndexer
*/
@interface RKSearchPredicate : NSCompoundPredicate
/**
Creates and returns a new predicate for performing a full text search on an entity indexed
by an instance of RKSearchIndexer. The given search text will be tokenized, normalized and
used to construct a collection of subpredicates specifying a BEGINSWITH match against the
by an instance of RKSearchIndexer. The given search text will be tokenized, normalized and
used to construct a collection of subpredicates specifying a BEGINSWITH match against the
searchWords relationship of the searchable entity.
@param searchText A string of text with which to construct subpredicates for searching.
@param type The type of the new compound predicate.
@return A new compound predicate for performing a full text search with the given search text and type.
@@ -42,11 +42,11 @@
/**
Initializes the receiver with a string of search text and a compound predicate type.
The search text will be tokenized, normalized and then used to construct an array of
subpredicates specifying a BEGINSWITH match against the searchWords relationship of the
subpredicates specifying a BEGINSWITH match against the searchWords relationship of the
searchable entity.
@param searchText A string of text with which to construct subpredicates for searching.
@param type The type of the new compound predicate.
@return The receiver with its type set to the given type and its subpredicates set to an

View File

@@ -20,12 +20,12 @@
{
RKSearchTokenizer *tokenizer = [RKSearchTokenizer new];
NSSet *searchWords = [tokenizer tokenize:searchText];
NSMutableArray *subpredicates = [NSMutableArray arrayWithCapacity:[searchWords count]];
for (NSString *searchWord in searchWords) {
[subpredicates addObject:[NSPredicate predicateWithFormat:@"(ANY searchWords.word beginswith %@)", searchWord]];
}
return [super initWithType:type subpredicates:subpredicates];
}

View File

@@ -34,7 +34,7 @@
/**
The set of stop words that are to be removed from the token set.
Defaults to nil.
*/
@property (nonatomic, strong) NSSet *stopWords;
@@ -47,7 +47,7 @@
Tokenizes the given string by folding it case and diacritic insensitively and then
splitting it apart using the the word unit delimiters for the current locale. If a set
of stop words has been provided, the resulting token set will have the stop words subtracted.
@param string A string of text you wish to tokenize.
@returns A set of searchable text tokens extracted from the given string.
*/

View File

@@ -13,29 +13,29 @@
- (NSSet *)tokenize:(NSString *)string
{
NSMutableSet *tokens = [NSMutableSet set];
CFLocaleRef locale = CFLocaleCopyCurrent();
// Remove diacratics and lowercase our input text
NSString *tokenizeText = string = [string stringByFoldingWithOptions:kCFCompareCaseInsensitive|kCFCompareDiacriticInsensitive locale:[NSLocale systemLocale]];
CFStringTokenizerRef tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault, (__bridge CFStringRef)tokenizeText, CFRangeMake(0, CFStringGetLength((__bridge CFStringRef)tokenizeText)), kCFStringTokenizerUnitWord, locale);
CFStringTokenizerTokenType tokenType = kCFStringTokenizerTokenNone;
while(kCFStringTokenizerTokenNone != (tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer))) {
CFRange tokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer);
NSRange range = NSMakeRange(tokenRange.location, tokenRange.length);
NSString *token = [string substringWithRange:range];
[tokens addObject:token];
}
CFRelease(tokenizer);
CFRelease(locale);
// Remove any stop words
if (self.stopWords) [tokens minusSet:self.stopWords];
return tokens;
}

View File

@@ -24,7 +24,7 @@
RKSearchWord implements a managed object subclass for representing
search words contained in designated string attributes of entities indexed
by an instance of RKSearchIndexer.
@see RKSearchIndexer
*/
@interface RKSearchWord : NSManagedObject

View File

@@ -26,7 +26,7 @@ NSString * const RKSearchWordsRelationshipName = @"searchWords";
[attribute setAttributeType:NSStringAttributeType];
[self setProperties:[NSArray arrayWithObject:attribute]];
}
return self;
}

View File

@@ -137,7 +137,7 @@ RK_FIX_CATEGORY_BUG(NSDictionary_RKAdditions)
[result setObject:obj forKey:key];
}
}];
return [NSDictionary dictionaryWithDictionary:result];
}

View File

@@ -12,7 +12,7 @@
Returns the path to the Application Data directory for the executing application. On iOS,
this is a sandboxed path specific for the executing application. On OS X, this is an application
specific path under NSApplicationSupportDirectory (i.e. ~/Application Support).
@return The full path to the application data directory.
*/
NSString * RKApplicationDataDirectory(void);
@@ -21,7 +21,7 @@ NSString * RKApplicationDataDirectory(void);
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 * RKCachesDirectory(void);
@@ -29,7 +29,7 @@ NSString * RKCachesDirectory(void);
/**
Ensures that a directory exists at a given path by checking for the existence
of the directory and creating it if it does not exist.
@param path The path to ensure a directory exists at.
@param error On input, a pointer to an error object.
@returns A Boolean value indicating if the directory exists.

View File

@@ -19,21 +19,21 @@ NSString * RKApplicationDataDirectory(void)
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) {
appDirectory = [appSupportDir URLByAppendingPathComponent:RKExecutableName()];
return [appDirectory path];
}
return nil;
#endif
}
@@ -45,7 +45,7 @@ NSString * RKExecutableName(void)
RKLogWarning(@"Unable to determine CFBundleExecutable: storing data under RestKit directory name.");
executableName = @"RestKit";
}
return executableName;
}
@@ -59,7 +59,7 @@ NSString * RKCachesDirectory(void)
if ([paths count]) {
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:RKExecutableName()];
}
return path;
#endif
}
@@ -74,13 +74,13 @@ BOOL RKEnsureDirectoryExistsAtPath(NSString *path, NSError **error)
return YES;
}
}
// Create the directory and any intermediates
NSError *errorReference = (error == nil) ? nil : *error;
if (! [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&errorReference]) {
RKLogError(@"Failed to create requested directory at path '%@': %@", path, errorReference);
return NO;
}
return YES;
}

View File

@@ -23,7 +23,7 @@
#define RestKit_RKMacros_h
/**
Instead of using the normal DEPRECATED_ATTRIBUTE use DEPRECATED_ATTRIBUTE_MESSAGE(message)
Instead of using the normal DEPRECATED_ATTRIBUTE use DEPRECATED_ATTRIBUTE_MESSAGE(message)
to display a helpful recommendation message along with the deprecation message.
*/
#ifndef DEPRECATED_ATTRIBUTE_MESSAGE

View File

@@ -157,7 +157,7 @@
/**
A data source for the mapping operation.
Defaults to an instance of RKObjectMappingOperationDataSource.
*/
@property (nonatomic, strong) id<RKMappingOperationDataSource> mappingOperationDataSource;

View File

@@ -95,7 +95,7 @@
self.awaitingNotification = NO;
}
}
[self removeObserver];
}