Skip to content

Commit 8d5e315

Browse files
committed
Merge branch 'hotfix/0.10.2'
2 parents f11a538 + 149edd9 commit 8d5e315

File tree

250 files changed

+8025
-6121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+8025
-6121
lines changed

Code/CoreData/CoreData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "NSManagedObject+ActiveRecord.h"
2424
#import "RKManagedObjectStore.h"
2525
#import "RKManagedObjectSeeder.h"
26+
#import "RKManagedObjectLoader.h"
2627
#import "RKManagedObjectMapping.h"
2728
#import "RKManagedObjectMappingOperation.h"
2829
#import "RKManagedObjectCaching.h"

Code/CoreData/NSEntityDescription+RKAdditions.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ extern NSString * const RKEntityDescriptionPrimaryKeyAttributeValuePredicateSubs
7171
value. This predicate is constructed by evaluating the cached predicate returned by the
7272
predicateForPrimaryKeyAttribute with a dictionary of substitution variables specifying that
7373
$PRIMARY_KEY_VALUE is equal to the given value.
74-
74+
7575
**NOTE**: This method considers the type of the receiver's primary key attribute when constructing
76-
the predicate. It will coerce the given value into either an NSString or an NSNumber as
76+
the predicate. It will coerce the given value into either an NSString or an NSNumber as
7777
appropriate. This behavior is a convenience to avoid annoying issues related to Core Data's
7878
handling of predicates for NSString and NSNumber types that were not appropriately casted.
79-
79+
8080
@return A predicate speciying that the value of the primary key attribute is equal to a given value.
8181
*/
8282
- (NSPredicate *)predicateForPrimaryKeyAttributeWithValue:(id)value;
8383

8484
/**
8585
Coerces the given value into the class representing the primary key. Currently support NSString
8686
and NSNumber coercsions.
87-
87+
8888
@bug **NOTE** This API is temporary and will be deprecated and replaced.
89-
@since 0.10.1
89+
@since 0.10.1
9090
*/
9191
- (id)coerceValueForPrimaryKey:(id)primaryKeyValue;
9292

Code/CoreData/NSEntityDescription+RKAdditions.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ - (Class)primaryKeyAttributeClass
3838
if (attributeDescription) {
3939
return NSClassFromString(attributeDescription.attributeValueClassName);
4040
}
41-
41+
4242
return nil;
4343
}
4444

4545
- (NSString *)primaryKeyAttributeName
4646
{
4747
// Check for an associative object reference
48-
NSString *primaryKeyAttribute = (NSString *) objc_getAssociatedObject(self, &primaryKeyAttributeNameKey);
48+
NSString *primaryKeyAttribute = (NSString *)objc_getAssociatedObject(self, &primaryKeyAttributeNameKey);
4949

5050
// Fall back to the userInfo dictionary
5151
if (! primaryKeyAttribute) {
@@ -71,7 +71,7 @@ - (void)setPrimaryKeyAttributeName:(NSString *)primaryKeyAttributeName
7171

7272
- (NSPredicate *)predicateForPrimaryKeyAttribute
7373
{
74-
return (NSPredicate *) objc_getAssociatedObject(self, &primaryKeyPredicateKey);
74+
return (NSPredicate *)objc_getAssociatedObject(self, &primaryKeyPredicateKey);
7575
}
7676

7777
- (id)coerceValueForPrimaryKey:(id)primaryKeyValue
@@ -92,7 +92,7 @@ - (id)coerceValueForPrimaryKey:(id)primaryKeyValue
9292
}
9393
}
9494
}
95-
95+
9696
return searchValue;
9797
}
9898

Code/CoreData/NSManagedObject+ActiveRecord.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,59 +31,59 @@
3131
* The NSEntityDescription for the Subclass
3232
* defaults to the subclass className, may be overridden
3333
*/
34-
+ (NSEntityDescription*)entity;
34+
+ (NSEntityDescription *)entity;
3535

3636
/**
3737
* Returns an initialized NSFetchRequest for the entity, with no predicate
3838
*/
39-
+ (NSFetchRequest*)fetchRequest;
39+
+ (NSFetchRequest *)fetchRequest;
4040

4141
/**
4242
* Fetches all objects from the persistent store identified by the fetchRequest
4343
*/
44-
+ (NSArray*)objectsWithFetchRequest:(NSFetchRequest*)fetchRequest;
44+
+ (NSArray *)objectsWithFetchRequest:(NSFetchRequest *)fetchRequest;
4545

4646
/**
4747
* Retrieves the number of objects that would be retrieved by the fetchRequest,
4848
* if executed
4949
*/
50-
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest*)fetchRequest;
50+
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest *)fetchRequest;
5151

5252
/**
5353
* Fetches all objects from the persistent store via a set of fetch requests and
5454
* returns all results in a single array.
5555
*/
56-
+ (NSArray*)objectsWithFetchRequests:(NSArray*)fetchRequests;
56+
+ (NSArray *)objectsWithFetchRequests:(NSArray *)fetchRequests;
5757

5858
/**
5959
* Fetches the first object identified by the fetch request. A limit of one will be
6060
* applied to the fetch request before dispatching.
6161
*/
62-
+ (id)objectWithFetchRequest:(NSFetchRequest*)fetchRequest;
62+
+ (id)objectWithFetchRequest:(NSFetchRequest *)fetchRequest;
6363

6464
/**
6565
* Fetches all objects from the persistent store by constructing a fetch request and
6666
* applying the predicate supplied. A short-cut for doing filtered searches on the objects
6767
* of this class under management.
6868
*/
69-
+ (NSArray*)objectsWithPredicate:(NSPredicate*)predicate;
69+
+ (NSArray *)objectsWithPredicate:(NSPredicate *)predicate;
7070

7171
/**
7272
* Fetches the first object matching a predicate from the persistent store. A fetch request
7373
* will be constructed for you and a fetch limit of 1 will be applied.
7474
*/
75-
+ (id)objectWithPredicate:(NSPredicate*)predicate;
75+
+ (id)objectWithPredicate:(NSPredicate *)predicate;
7676

7777
/**
7878
* Fetches all managed objects of this class from the persistent store as an array
7979
*/
80-
+ (NSArray*)allObjects;
80+
+ (NSArray *)allObjects;
8181

8282
/**
8383
* Returns a count of all managed objects of this class in the persistent store. On
8484
* error, will populate the error argument
8585
*/
86-
+ (NSUInteger)count:(NSError**)error;
86+
+ (NSUInteger)count:(NSError **)error;
8787

8888
/**
8989
* Returns a count of all managed objects of this class in the persistent store. Deprecated
@@ -124,7 +124,7 @@
124124

125125
////////////////////////////////////////////////////////////////////////////////////////////////////
126126

127-
+ (NSManagedObjectContext*)currentContext;
127+
+ (NSManagedObjectContext *)currentContext;
128128

129129
+ (void)handleErrors:(NSError *)error;
130130

@@ -152,8 +152,8 @@
152152
+ (NSNumber *)numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm;
153153
+ (NSNumber *)numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
154154

155-
+ (BOOL) hasAtLeastOneEntity;
156-
+ (BOOL) hasAtLeastOneEntityInContext:(NSManagedObjectContext *)context;
155+
+ (BOOL)hasAtLeastOneEntity;
156+
+ (BOOL)hasAtLeastOneEntityInContext:(NSManagedObjectContext *)context;
157157

158158
+ (NSFetchRequest *)requestAll;
159159
+ (NSFetchRequest *)requestAllInContext:(NSManagedObjectContext *)context;
@@ -180,8 +180,8 @@
180180
+ (NSArray *)findAllWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
181181

182182
+ (NSNumber *)maxValueFor:(NSString *)property;
183-
+ (id) objectWithMinValueFor:(NSString *)property;
184-
+ (id) objectWithMinValueFor:(NSString *)property inContext:(NSManagedObjectContext *)context;
183+
+ (id)objectWithMinValueFor:(NSString *)property;
184+
+ (id)objectWithMinValueFor:(NSString *)property inContext:(NSManagedObjectContext *)context;
185185

186186
+ (id)findFirst;
187187
+ (id)findFirstInContext:(NSManagedObjectContext *)context;

Code/CoreData/NSManagedObject+ActiveRecord.m

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@
2828

2929
@implementation NSManagedObjectContext (ActiveRecord)
3030

31-
+ (NSManagedObjectContext *)defaultContext {
31+
+ (NSManagedObjectContext *)defaultContext
32+
{
3233
return defaultContext;
3334
}
3435

35-
+ (void)setDefaultContext:(NSManagedObjectContext *)newDefaultContext {
36+
+ (void)setDefaultContext:(NSManagedObjectContext *)newDefaultContext
37+
{
3638
[newDefaultContext retain];
3739
[defaultContext release];
3840
defaultContext = newDefaultContext;
3941
}
4042

41-
+ (NSManagedObjectContext *)contextForCurrentThread {
43+
+ (NSManagedObjectContext *)contextForCurrentThread
44+
{
4245
NSAssert([RKManagedObjectStore defaultObjectStore], @"[RKManagedObjectStore defaultObjectStore] cannot be nil");
4346
return [[RKManagedObjectStore defaultObjectStore] managedObjectContextForCurrentThread];
4447
}
@@ -51,109 +54,125 @@ @implementation NSManagedObject (ActiveRecord)
5154

5255
#pragma mark - RKManagedObject methods
5356

54-
+ (NSEntityDescription*)entity {
55-
NSString* className = [NSString stringWithCString:class_getName([self class]) encoding:NSASCIIStringEncoding];
57+
+ (NSEntityDescription *)entity
58+
{
59+
NSString *className = [NSString stringWithCString:class_getName([self class]) encoding:NSASCIIStringEncoding];
5660
return [NSEntityDescription entityForName:className inManagedObjectContext:[NSManagedObjectContext contextForCurrentThread]];
5761
}
5862

59-
+ (NSFetchRequest*)fetchRequest {
63+
+ (NSFetchRequest *)fetchRequest
64+
{
6065
NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init] autorelease];
6166
NSEntityDescription *entity = [self entity];
6267
[fetchRequest setEntity:entity];
6368
return fetchRequest;
6469
}
6570

66-
+ (NSArray*)objectsWithFetchRequest:(NSFetchRequest*)fetchRequest {
67-
NSError* error = nil;
68-
NSArray* objects = [[NSManagedObjectContext contextForCurrentThread] executeFetchRequest:fetchRequest error:&error];
71+
+ (NSArray *)objectsWithFetchRequest:(NSFetchRequest *)fetchRequest
72+
{
73+
NSError *error = nil;
74+
NSArray *objects = [[NSManagedObjectContext contextForCurrentThread] executeFetchRequest:fetchRequest error:&error];
6975
if (objects == nil) {
7076
RKLogError(@"Error: %@", [error localizedDescription]);
7177
}
7278
return objects;
7379
}
7480

75-
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest*)fetchRequest {
76-
NSError* error = nil;
81+
+ (NSUInteger)countOfObjectsWithFetchRequest:(NSFetchRequest *)fetchRequest
82+
{
83+
NSError *error = nil;
7784
NSUInteger objectCount = [[NSManagedObjectContext contextForCurrentThread] countForFetchRequest:fetchRequest error:&error];
7885
if (objectCount == NSNotFound) {
7986
RKLogError(@"Error: %@", [error localizedDescription]);
8087
}
8188
return objectCount;
8289
}
8390

84-
+ (NSArray*)objectsWithFetchRequests:(NSArray*)fetchRequests {
85-
NSMutableArray* mutableObjectArray = [[NSMutableArray alloc] init];
86-
for (NSFetchRequest* fetchRequest in fetchRequests) {
91+
+ (NSArray *)objectsWithFetchRequests:(NSArray *)fetchRequests
92+
{
93+
NSMutableArray *mutableObjectArray = [[NSMutableArray alloc] init];
94+
for (NSFetchRequest *fetchRequest in fetchRequests) {
8795
[mutableObjectArray addObjectsFromArray:[self objectsWithFetchRequest:fetchRequest]];
8896
}
89-
NSArray* objects = [NSArray arrayWithArray:mutableObjectArray];
97+
NSArray *objects = [NSArray arrayWithArray:mutableObjectArray];
9098
[mutableObjectArray release];
9199
return objects;
92100
}
93101

94-
+ (id)objectWithFetchRequest:(NSFetchRequest*)fetchRequest {
102+
+ (id)objectWithFetchRequest:(NSFetchRequest *)fetchRequest
103+
{
95104
[fetchRequest setFetchLimit:1];
96-
NSArray* objects = [self objectsWithFetchRequest:fetchRequest];
105+
NSArray *objects = [self objectsWithFetchRequest:fetchRequest];
97106
if ([objects count] == 0) {
98107
return nil;
99108
} else {
100109
return [objects objectAtIndex:0];
101110
}
102111
}
103112

104-
+ (NSArray*)objectsWithPredicate:(NSPredicate*)predicate {
105-
NSFetchRequest* fetchRequest = [self fetchRequest];
113+
+ (NSArray *)objectsWithPredicate:(NSPredicate *)predicate
114+
{
115+
NSFetchRequest *fetchRequest = [self fetchRequest];
106116
[fetchRequest setPredicate:predicate];
107117
return [self objectsWithFetchRequest:fetchRequest];
108118
}
109119

110-
+ (id)objectWithPredicate:(NSPredicate*)predicate {
111-
NSFetchRequest* fetchRequest = [self fetchRequest];
120+
+ (id)objectWithPredicate:(NSPredicate *)predicate
121+
{
122+
NSFetchRequest *fetchRequest = [self fetchRequest];
112123
[fetchRequest setPredicate:predicate];
113124
return [self objectWithFetchRequest:fetchRequest];
114125
}
115126

116-
+ (NSArray*)allObjects {
127+
+ (NSArray *)allObjects
128+
{
117129
return [self objectsWithPredicate:nil];
118130
}
119131

120-
+ (NSUInteger)count:(NSError**)error {
121-
NSFetchRequest* fetchRequest = [self fetchRequest];
132+
+ (NSUInteger)count:(NSError **)error
133+
{
134+
NSFetchRequest *fetchRequest = [self fetchRequest];
122135
return [[NSManagedObjectContext contextForCurrentThread] countForFetchRequest:fetchRequest error:error];
123136
}
124137

125-
+ (NSUInteger)count {
138+
+ (NSUInteger)count
139+
{
126140
NSError *error = nil;
127141
return [self count:&error];
128142
}
129143

130-
+ (id)object {
144+
+ (id)object
145+
{
131146
id object = [[self alloc] initWithEntity:[self entity] insertIntoManagedObjectContext:[NSManagedObjectContext contextForCurrentThread]];
132147
return [object autorelease];
133148
}
134149

135-
- (BOOL)isNew {
150+
- (BOOL)isNew
151+
{
136152
NSDictionary *vals = [self committedValuesForKeys:nil];
137153
return [vals count] == 0;
138154
}
139155

140-
+ (id)findByPrimaryKey:(id)primaryKeyValue inContext:(NSManagedObjectContext *)context {
156+
+ (id)findByPrimaryKey:(id)primaryKeyValue inContext:(NSManagedObjectContext *)context
157+
{
141158
NSPredicate *predicate = [[self entityDescriptionInContext:context] predicateForPrimaryKeyAttributeWithValue:primaryKeyValue];
142159
if (! predicate) {
143160
RKLogWarning(@"Attempt to findByPrimaryKey for entity with nil primaryKeyAttribute. Set the primaryKeyAttributeName and try again! %@", self);
144161
return nil;
145162
}
146-
163+
147164
return [self findFirstWithPredicate:predicate inContext:context];
148165
}
149166

150-
+ (id)findByPrimaryKey:(id)primaryKeyValue {
167+
+ (id)findByPrimaryKey:(id)primaryKeyValue
168+
{
151169
return [self findByPrimaryKey:primaryKeyValue inContext:[NSManagedObjectContext contextForCurrentThread]];
152170
}
153171

154172
#pragma mark - MagicalRecord Ported Methods
155173

156-
+ (NSManagedObjectContext*)currentContext; {
174+
+ (NSManagedObjectContext *)currentContext;
175+
{
157176
return [NSManagedObjectContext contextForCurrentThread];
158177
}
159178

@@ -276,7 +295,7 @@ + (NSArray *)propertiesNamed:(NSArray *)properties
276295
}
277296
else
278297
{
279-
RKLogError(@"Property '%@' not found in %@ properties for %@", propertyName, [propDict count], NSStringFromClass(self));
298+
RKLogError(@"Property '%@' not found in %d properties for %@", propertyName, [propDict count], NSStringFromClass(self));
280299
}
281300
}
282301
}
@@ -292,7 +311,7 @@ + (NSArray *)sortAscending:(BOOL)ascending attributes:(id)attributesToSortBy, ..
292311
id attributeName;
293312
va_list variadicArguments;
294313
va_start(variadicArguments, attributesToSortBy);
295-
while ((attributeName = va_arg(variadicArguments, id))!= nil)
314+
while ((attributeName = va_arg(variadicArguments, id)) != nil)
296315
{
297316
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:attributeName ascending:ascending];
298317
[attributes addObject:sortDescriptor];
@@ -305,7 +324,7 @@ + (NSArray *)sortAscending:(BOOL)ascending attributes:(id)attributesToSortBy, ..
305324
{
306325
va_list variadicArguments;
307326
va_start(variadicArguments, attributesToSortBy);
308-
[attributes addObject:[[[NSSortDescriptor alloc] initWithKey:attributesToSortBy ascending:ascending] autorelease] ];
327+
[attributes addObject:[[[NSSortDescriptor alloc] initWithKey:attributesToSortBy ascending:ascending] autorelease]];
309328
va_end(variadicArguments);
310329
}
311330

@@ -457,7 +476,7 @@ + (NSFetchRequest *)requestAllSortedBy:(NSString *)sortTerm ascending:(BOOL)asce
457476
[request setIncludesSubentities:NO];
458477
[request setFetchBatchSize:[self defaultBatchSize]];
459478

460-
if (sortTerm != nil){
479+
if (sortTerm != nil) {
461480
NSSortDescriptor *sortBy = [[NSSortDescriptor alloc] initWithKey:sortTerm ascending:ascending];
462481
[request setSortDescriptors:[NSArray arrayWithObject:sortBy]];
463482
[sortBy release];

Code/CoreData/NSManagedObjectContext+RKAdditions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ @implementation NSManagedObjectContext (RKAdditions)
1515

1616
- (RKManagedObjectStore *)managedObjectStore
1717
{
18-
return (RKManagedObjectStore *) objc_getAssociatedObject(self, &NSManagedObject_RKManagedObjectStoreAssociatedKey);
18+
return (RKManagedObjectStore *)objc_getAssociatedObject(self, &NSManagedObject_RKManagedObjectStoreAssociatedKey);
1919
}
2020

2121
- (void)setManagedObjectStore:(RKManagedObjectStore *)managedObjectStore

0 commit comments

Comments
 (0)