Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
casademora committed Oct 1, 2012
2 parents 9167b64 + da39710 commit 545a946
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Expand Up @@ -39,7 +39,7 @@ - (id) MR_valueForKeyPath:(NSString *)keyPath fromObjectData:(id)objectData;
NSString *dateFormat = [[self userInfo] valueForKey:kMagicalRecordImportCustomDateFormatKey];
value = dateFromString([value description], dateFormat ?: kMagicalRecordImportDefaultDateFormatString);
}
value = adjustDateForDST(value);
// value = adjustDateForDST(value);
}
}

Expand Down
Expand Up @@ -31,7 +31,7 @@ - (NSString *) MR_lookupKeyForAttribute:(NSAttributeDescription *)attributeInfo;

for (NSUInteger i = 1; i < kMagicalRecordImportMaximumAttributeFailoverDepth && value == nil; i++)
{
attributeName = [NSString stringWithFormat:@"%@.%ld", kMagicalRecordImportAttributeKeyMapKey, i];
attributeName = [NSString stringWithFormat:@"%@.%lu", kMagicalRecordImportAttributeKeyMapKey, (unsigned long)i];
lookupKey = [[attributeInfo userInfo] valueForKey:attributeName];
if (lookupKey == nil)
{
Expand Down
Expand Up @@ -39,7 +39,7 @@ - (BOOL) MR_importValue:(id)value forKey:(NSString *)key
return NO;
}

- (void) MR_setAttributes:(NSDictionary *)attributes forKeysWithDictionary:(id)objectData
- (void) MR_setAttributes:(NSDictionary *)attributes forKeysWithObject:(id)objectData
{
for (NSString *attributeName in attributes)
{
Expand Down Expand Up @@ -125,7 +125,7 @@ - (void) MR_addObject:(NSManagedObject *)relatedObject forRelationship:(NSRelati
}
}

- (void) MR_setRelationships:(NSDictionary *)relationships forKeysWithDictionary:(NSDictionary *)relationshipData withBlock:(void(^)(NSRelationshipDescription *,id))setRelationshipBlock
- (void) MR_setRelationships:(NSDictionary *)relationships forKeysWithObject:(id)relationshipData withBlock:(void(^)(NSRelationshipDescription *,id))setRelationshipBlock
{
for (NSString *relationshipName in relationships)
{
Expand Down Expand Up @@ -203,33 +203,31 @@ - (BOOL) MR_performDataImportFromObject:(id)objectData relationshipBlock:(void(^
if (!didStartimporting) return NO;

NSDictionary *attributes = [[self entity] attributesByName];
[self MR_setAttributes:attributes forKeysWithDictionary:objectData];
[self MR_setAttributes:attributes forKeysWithObject:objectData];

NSDictionary *relationships = [[self entity] relationshipsByName];
[self MR_setRelationships:relationships
forKeysWithDictionary:objectData
withBlock:relationshipBlock];
[self MR_setRelationships:relationships forKeysWithObject:objectData withBlock:relationshipBlock];

return [self MR_postImport:objectData];
}

- (BOOL) MR_importValuesForKeysWithObject:(id)objectData
{
void (^importRelationshipLogic)(NSRelationshipDescription *, id) = ^(NSRelationshipDescription *relationshipInfo, id localObjectData) {
typeof(self) weakself = self;
return [self MR_performDataImportFromObject:objectData
relationshipBlock:^(NSRelationshipDescription *relationshipInfo, id localObjectData) {

NSManagedObject *relatedObject = [self MR_findObjectForRelationship:relationshipInfo withData:localObjectData];
NSManagedObject *relatedObject = [weakself MR_findObjectForRelationship:relationshipInfo withData:localObjectData];

if (relatedObject == nil)
{
NSEntityDescription *entityDescription = [relationshipInfo destinationEntity];
relatedObject = [entityDescription MR_createInstanceInContext:[self managedObjectContext]];
relatedObject = [entityDescription MR_createInstanceInContext:[weakself managedObjectContext]];
}
[relatedObject MR_importValuesForKeysWithObject:localObjectData];

[self MR_addObject:relatedObject forRelationship:relationshipInfo];
};

return [self MR_performDataImportFromObject:objectData relationshipBlock:importRelationshipLogic];
[weakself MR_addObject:relatedObject forRelationship:relationshipInfo];
} ];
}

+ (id) MR_importFromObject:(id)objectData inContext:(NSManagedObjectContext *)context;
Expand Down
Expand Up @@ -118,7 +118,7 @@ + (NSArray *) MR_propertiesNamed:(NSArray *)properties
}
else
{
MRLog(@"Property '%@' not found in %ld properties for %@", propertyName, [propDict count], NSStringFromClass(self));
MRLog(@"Property '%@' not found in %lx properties for %@", propertyName, (unsigned long)[propDict count], NSStringFromClass(self));
}
}
}
Expand Down
Expand Up @@ -172,7 +172,7 @@ - (void)contextWillSave:(NSNotification *)notification
NSManagedObjectContext *context = (NSManagedObjectContext *)notification.object;
if (context.insertedObjects.count > 0) {
NSArray *insertedObjects = [[context insertedObjects] allObjects];
MRLog(@"Context %@ is about to save. Obtaining permanent IDs for new %d inserted objects", [context MR_description], insertedObjects.count);
MRLog(@"Context %@ is about to save. Obtaining permanent IDs for new %lu inserted objects", [context MR_description], (unsigned long)[insertedObjects count]);
NSError *error;
[context obtainPermanentIDsForObjects:insertedObjects error:&error];
[MagicalRecord handleErrors:error];
Expand Down
2 changes: 2 additions & 0 deletions MagicalRecord/CoreData+MagicalRecord.h
Expand Up @@ -51,10 +51,12 @@

#if TARGET_OS_IPHONE
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
#undef MRDispatchQueueRelease
#define MRDispatchQueueRelease(q)
#endif
#else
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
#undef MRDispatchQueueRelease
#define MRDispatchQueueRelease(q)
#endif
#endif

0 comments on commit 545a946

Please sign in to comment.