diff --git a/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h b/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h index d172b32..4a947b7 100644 --- a/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h +++ b/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h @@ -15,11 +15,11 @@ NSString * attributeNameFromString(NSString *value); NSString * primaryKeyNameFromString(NSString *value); #if TARGET_OS_IPHONE - +#import UIColor * UIColorFromString(NSString *serializedColor); #else - +#import NSColor * NSColorFromString(NSString *serializedColor); #endif diff --git a/MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m b/MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m index 9feaf23..8693df8 100644 --- a/MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m +++ b/MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m @@ -31,7 +31,7 @@ NSUInteger const kMagicalRecordImportMaximumAttributeFailoverDepth = 10; for (NSUInteger i = 1; i < kMagicalRecordImportMaximumAttributeFailoverDepth && value == nil; i++) { - attributeName = [NSString stringWithFormat:@"%@.%u", kMagicalRecordImportAttributeKeyMapKey, i]; + attributeName = [NSString stringWithFormat:@"%@.%d", kMagicalRecordImportAttributeKeyMapKey, i]; lookupKey = [[attributeInfo userInfo] valueForKey:attributeName]; if (lookupKey == nil) { diff --git a/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.h b/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.h index 76e0494..09da58a 100644 --- a/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.h +++ b/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.h @@ -10,6 +10,6 @@ @interface NSString (MagicalRecord_DataImport) -- (NSString *) MR_capitalizedFirstCharaterString; +- (NSString *) MR_capitalizedFirstCharacterString; @end diff --git a/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m b/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m index 8111a18..065ddc2 100644 --- a/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m +++ b/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m @@ -11,7 +11,7 @@ @implementation NSString (MagicalRecord_DataImport) -- (NSString *) MR_capitalizedFirstCharaterString; +- (NSString *) MR_capitalizedFirstCharacterString; { if ([self length] > 0) { diff --git a/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m b/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m index 273d6be..f56a55c 100644 --- a/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m +++ b/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m @@ -11,14 +11,15 @@ void MR_swapMethodsFromClass(Class c, SEL orig, SEL new); -NSString * const kMagicalRecordImportCustomDateFormatKey = @"dateFormat"; -NSString * const kMagicalRecordImportDefaultDateFormatString = @"yyyy-MM-dd'T'HH:mm:ss'Z'"; -NSString * const kMagicalRecordImportAttributeKeyMapKey = @"mappedKeyName"; -NSString * const kMagicalRecordImportAttributeValueClassNameKey = @"attributeValueClassName"; +NSString * const kMagicalRecordImportCustomDateFormatKey = @"dateFormat"; +NSString * const kMagicalRecordImportDefaultDateFormatString = @"yyyy-MM-dd'T'HH:mm:ss'Z'"; -NSString * const kMagicalRecordImportRelationshipMapKey = @"mappedKeyName"; -NSString * const kMagicalRecordImportRelationshipLinkedByKey = @"relatedByAttribute"; -NSString * const kMagicalRecordImportRelationshipTypeKey = @"type"; +NSString * const kMagicalRecordImportAttributeKeyMapKey = @"mappedKeyName"; +NSString * const kMagicalRecordImportAttributeValueClassNameKey = @"attributeValueClassName"; + +NSString * const kMagicalRecordImportRelationshipMapKey = @"mappedKeyName"; +NSString * const kMagicalRecordImportRelationshipLinkedByKey = @"relatedByAttribute"; +NSString * const kMagicalRecordImportRelationshipTypeKey = @"type"; //this needs to be revisited #pragma clang diagnostic push @@ -28,14 +29,11 @@ NSString * const kMagicalRecordImportRelationshipTypeKey = @"type"; - (BOOL) MR_importValue:(id)value forKey:(NSString *)key { - NSString *selectorString = [NSString stringWithFormat:@"import%@:", [key MR_capitalizedFirstCharaterString]]; + NSString *selectorString = [NSString stringWithFormat:@"import%@:", [key MR_capitalizedFirstCharacterString]]; SEL selector = NSSelectorFromString(selectorString); if ([self respondsToSelector:selector]) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" [self performSelector:selector withObject:value]; -#pragma clang diagnostic pop return YES; } return NO; @@ -93,10 +91,7 @@ NSString * const kMagicalRecordImportRelationshipTypeKey = @"type"; { //Need to get the ordered set NSString *selectorName = [[relationshipInfo name] stringByAppendingString:@"Set"]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" relationshipSource = [self performSelector:NSSelectorFromString(selectorName)]; -#pragma clang diagnostic pop addRelationMessageFormat = @"addObject:"; } } @@ -138,7 +133,7 @@ NSString * const kMagicalRecordImportRelationshipTypeKey = @"type"; continue; } - SEL shouldImportSelector = NSSelectorFromString([NSString stringWithFormat:@"shouldImport%@:", [relationshipName MR_capitalizedFirstCharaterString]]); + SEL shouldImportSelector = NSSelectorFromString([NSString stringWithFormat:@"shouldImport%@:", [relationshipName MR_capitalizedFirstCharacterString]]); BOOL implementsShouldImport = (BOOL)[self respondsToSelector:shouldImportSelector]; void (^establishRelationship)(NSRelationshipDescription *, id) = ^(NSRelationshipDescription *blockInfo, id blockData) { diff --git a/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m b/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m index 03d0ba8..f6fda1f 100644 --- a/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m +++ b/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m @@ -21,25 +21,29 @@ NSString * const kMagicalRecordDidMergeChangesFromiCloudNotification = @"kMagica - (void) MR_observeContext:(NSManagedObjectContext *)otherContext { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(MR_mergeChangesFromNotification:) - name:NSManagedObjectContextDidSaveNotification - object:otherContext]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter addObserver:self + selector:@selector(MR_mergeChangesFromNotification:) + name:NSManagedObjectContextDidSaveNotification + object:otherContext]; } - (void) MR_observeContextOnMainThread:(NSManagedObjectContext *)otherContext { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(MR_mergeChangesOnMainThread:) - name:NSManagedObjectContextDidSaveNotification - object:otherContext]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter addObserver:self + selector:@selector(MR_mergeChangesOnMainThread:) + name:NSManagedObjectContextDidSaveNotification + object:otherContext]; } - (void) MR_stopObservingContext:(NSManagedObjectContext *)otherContext { - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSManagedObjectContextDidSaveNotification - object:otherContext]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self + name:NSManagedObjectContextDidSaveNotification + object:otherContext]; } #pragma mark - Context iCloud Merge Helpers @@ -54,9 +58,11 @@ NSString * const kMagicalRecordDidMergeChangesFromiCloudNotification = @"kMagica [self mergeChangesFromContextDidSaveNotification:notification]; - [[NSNotificationCenter defaultCenter] postNotificationName:kMagicalRecordDidMergeChangesFromiCloudNotification - object:self - userInfo:[notification userInfo]]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter postNotificationName:kMagicalRecordDidMergeChangesFromiCloudNotification + object:self + userInfo:[notification userInfo]]; }]; } @@ -84,19 +90,21 @@ NSString * const kMagicalRecordDidMergeChangesFromiCloudNotification = @"kMagica - (void) MR_observeiCloudChangesInCoordinator:(NSPersistentStoreCoordinator *)coordinator; { if (![MagicalRecord isICloudEnabled]) return; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(MR_mergeChangesFromiCloud:) - name:NSPersistentStoreDidImportUbiquitousContentChangesNotification - object:coordinator]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter addObserver:self + selector:@selector(MR_mergeChangesFromiCloud:) + name:NSPersistentStoreDidImportUbiquitousContentChangesNotification + object:coordinator]; } - (void) MR_stopObservingiCloudChangesInCoordinator:(NSPersistentStoreCoordinator *)coordinator; { if (![MagicalRecord isICloudEnabled]) return; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSPersistentStoreDidImportUbiquitousContentChangesNotification - object:coordinator]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter removeObserver:self + name:NSPersistentStoreDidImportUbiquitousContentChangesNotification + object:coordinator]; } @end diff --git a/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.h b/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.h index d8a76ca..b17d8b2 100644 --- a/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.h +++ b/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.h @@ -23,7 +23,6 @@ extern NSString * const kMagicalRecordDidMergeChangesFromiCloudNotification; + (NSManagedObjectContext *) MR_rootSavingContext; + (NSManagedObjectContext *) MR_defaultContext; -+ (void) MR_cleanUp; - (NSString *) MR_description; @end diff --git a/MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m b/MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m index cafd0c9..35519f7 100644 --- a/MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m +++ b/MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m @@ -198,7 +198,8 @@ NSString * const kMagicalRecordPSCDidCompleteiCloudSetupNotification = @"kMagica { completionBlock(); } - [[NSNotificationCenter defaultCenter] postNotificationName:kMagicalRecordPSCDidCompleteiCloudSetupNotification object:nil]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:kMagicalRecordPSCDidCompleteiCloudSetupNotification object:nil]; }); }); } diff --git a/MagicalRecord/Core/MagicalRecord+Actions.h b/MagicalRecord/Core/MagicalRecord+Actions.h index 37e9f45..da902f8 100644 --- a/MagicalRecord/Core/MagicalRecord+Actions.h +++ b/MagicalRecord/Core/MagicalRecord+Actions.h @@ -11,8 +11,12 @@ @interface MagicalRecord (Actions) +/* For saving on the current thread as the caller, only with a seperate context. Useful when you're managing your own threads/queues and need a serial call to create or change data + */ + (void) saveWithBlock:(void(^)(NSManagedObjectContext *localContext))block; +/* For all background saving operations. These calls will be sent to a different thread/queue. + */ + (void) saveInBackgroundWithBlock:(void(^)(NSManagedObjectContext *localContext))block; + (void) saveInBackgroundWithBlock:(void(^)(NSManagedObjectContext *localContext))block completion:(void(^)(void))callback; diff --git a/MagicalRecord/Core/MagicalRecord+Actions.m b/MagicalRecord/Core/MagicalRecord+Actions.m index 7a8b334..654055b 100644 --- a/MagicalRecord/Core/MagicalRecord+Actions.m +++ b/MagicalRecord/Core/MagicalRecord+Actions.m @@ -9,47 +9,42 @@ #import "CoreData+MagicalRecord.h" #import "NSManagedObjectContext+MagicalRecord.h" +static dispatch_queue_t action_queue; + @implementation MagicalRecord (Actions) ++ (void) load; +{ + action_queue = dispatch_queue_create("com.magicalpanda.magicalrecord.actionQueue", DISPATCH_QUEUE_SERIAL); +} + + (void) saveInBackgroundWithBlock:(void (^)(NSManagedObjectContext *))block completion:(void (^)(void))completion errorHandler:(void (^)(NSError *))errorHandler; { NSManagedObjectContext *mainContext = [NSManagedObjectContext MR_defaultContext]; - NSManagedObjectContext *localContext = mainContext; - - if (![NSThread isMainThread]) - { - localContext = [NSManagedObjectContext MR_contextThatPushesChangesToDefaultContext]; - [mainContext setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy]; - [localContext setMergePolicy:NSOverwriteMergePolicy]; - } - - block(localContext); - - if ([localContext hasChanges]) - { - [localContext MR_saveInBackgroundErrorHandler:errorHandler completion:^{ - [mainContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy]; - - if (completion) - { - completion(); - } - }]; - } + NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextWithParent:mainContext]; + + dispatch_async(action_queue, ^{ + block(localContext); + + if ([localContext hasChanges]) + { + [localContext MR_saveInBackgroundErrorHandler:errorHandler completion:^{ + [mainContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy]; + + if (completion) + { + completion(); + } + }]; + } + }); } + (void) saveWithBlock:(void (^)(NSManagedObjectContext *localContext))block completion:(void (^)(void))completion errorHandler:(void (^)(NSError *))errorHandler; { NSManagedObjectContext *mainContext = [NSManagedObjectContext MR_defaultContext]; - NSManagedObjectContext *localContext = mainContext; + NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextWithParent:mainContext]; - if (![NSThread isMainThread]) - { - localContext = [NSManagedObjectContext MR_contextThatPushesChangesToDefaultContext]; - [mainContext setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy]; - [localContext setMergePolicy:NSOverwriteMergePolicy]; - } - block(localContext); if ([localContext hasChanges]) @@ -80,17 +75,4 @@ [self saveInBackgroundWithBlock:block completion:callback errorHandler:nil]; } -// -//+ (void) saveInBackgroundWithBlock:(void (^)(NSManagedObjectContext *localContext))block completion:(void (^)(void))callback errorHandler:(void (^)(NSError *))errorHandler -//{ -// dispatch_async(background_save_queue(), ^{ -// [self saveWithBlock:block errorHandler:errorHandler]; -// -// if (callback) -// { -// dispatch_async(dispatch_get_main_queue(), callback); -// } -// }); -//} - @end diff --git a/MagicalRecord/Core/MagicalRecord.m b/MagicalRecord/Core/MagicalRecord.m index da635df..9e79787 100644 --- a/MagicalRecord/Core/MagicalRecord.m +++ b/MagicalRecord/Core/MagicalRecord.m @@ -13,6 +13,12 @@ @end +@interface NSManagedObjectContext (MagicalRecordInternal) + ++ (void) MR_cleanUp; + +@end + @implementation MagicalRecord diff --git a/Project Files/Mac App Unit Tests/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h b/Project Files/Mac App Unit Tests/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h index afcb2da..b9624f9 100644 --- a/Project Files/Mac App Unit Tests/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h +++ b/Project Files/Mac App Unit Tests/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h @@ -626,4 +626,3 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@ address this. */ - \ No newline at end of file diff --git a/Project Files/Magical Record.xcodeproj/project.pbxproj b/Project Files/Magical Record.xcodeproj/project.pbxproj index 2d5b7e3..65a61e4 100644 --- a/Project Files/Magical Record.xcodeproj/project.pbxproj +++ b/Project Files/Magical Record.xcodeproj/project.pbxproj @@ -46,9 +46,9 @@ C76AF7FC13DBEB5500CE2E05 /* ImportSingleRelatedEntityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C76AF7FA13DBEB5500CE2E05 /* ImportSingleRelatedEntityTests.m */; }; C76AF82A13DBEE5A00CE2E05 /* SingleRelatedEntity.json in Resources */ = {isa = PBXBuildFile; fileRef = C76AF82913DBEE5A00CE2E05 /* SingleRelatedEntity.json */; }; C76AF82B13DBEE5A00CE2E05 /* SingleRelatedEntity.json in Resources */ = {isa = PBXBuildFile; fileRef = C76AF82913DBEE5A00CE2E05 /* SingleRelatedEntity.json */; }; + C76D3EF715718EBC00B2D163 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C76D3EF615718EBC00B2D163 /* UIKit.framework */; }; + C76D3EF915718EC800B2D163 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C76D3EF815718EC800B2D163 /* CoreGraphics.framework */; }; C77E5F9B13D0CA0A00298F87 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C721C7E213D0C3A00097AB6F /* CoreData.framework */; }; - C77E5F9E13D0CA2100298F87 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C77E5F9C13D0CA1800298F87 /* CoreGraphics.framework */; }; - C77E5FA113D0CA3000298F87 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C77E5F9F13D0CA2700298F87 /* UIKit.framework */; }; C77E5FA813D0CBDE00298F87 /* MagicalRecordTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FA713D0CBDE00298F87 /* MagicalRecordTests.m */; }; C77E5FB313D0D1D100298F87 /* SingleEntityWithNoRelationships.plist in Resources */ = {isa = PBXBuildFile; fileRef = C77E5FB213D0D1D100298F87 /* SingleEntityWithNoRelationships.plist */; }; C77E5FB513D0D1EC00298F87 /* SampleJSONDataForImport.json in Resources */ = {isa = PBXBuildFile; fileRef = C77E5FB413D0D1EC00298F87 /* SampleJSONDataForImport.json */; }; @@ -271,8 +271,8 @@ C763783113E10BEC0009A6CA /* GHUnitIOSTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHUnitIOSTestMain.m; sourceTree = ""; }; C76AF7FA13DBEB5500CE2E05 /* ImportSingleRelatedEntityTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImportSingleRelatedEntityTests.m; path = "Unit Tests/ImportSingleRelatedEntityTests.m"; sourceTree = ""; }; C76AF82913DBEE5A00CE2E05 /* SingleRelatedEntity.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = SingleRelatedEntity.json; path = "Unit Tests/Fixtures/SingleRelatedEntity.json"; sourceTree = ""; }; - C77E5F9C13D0CA1800298F87 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; - C77E5F9F13D0CA2700298F87 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + C76D3EF615718EBC00B2D163 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + C76D3EF815718EC800B2D163 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; C77E5FA613D0CBDE00298F87 /* MagicalRecordTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MagicalRecordTests.h; path = "Unit Tests/MagicalRecordTests.h"; sourceTree = ""; }; C77E5FA713D0CBDE00298F87 /* MagicalRecordTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MagicalRecordTests.m; path = "Unit Tests/MagicalRecordTests.m"; sourceTree = ""; }; C77E5FB213D0D1D100298F87 /* SingleEntityWithNoRelationships.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = SingleEntityWithNoRelationships.plist; path = "Unit Tests/Fixtures/SingleEntityWithNoRelationships.plist"; sourceTree = ""; }; @@ -418,8 +418,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C77E5FA113D0CA3000298F87 /* UIKit.framework in Frameworks */, - C77E5F9E13D0CA2100298F87 /* CoreGraphics.framework in Frameworks */, + C76D3EF915718EC800B2D163 /* CoreGraphics.framework in Frameworks */, + C76D3EF715718EBC00B2D163 /* UIKit.framework in Frameworks */, C721C82513D0C4660097AB6F /* Foundation.framework in Frameworks */, C77E5F9B13D0CA0A00298F87 /* CoreData.framework in Frameworks */, C74F8E611555E39D0008B054 /* OCHamcrestIOS.framework in Frameworks */, @@ -508,11 +508,11 @@ C721C82E13D0C6390097AB6F /* Frameworks */ = { isa = PBXGroup; children = ( + C76D3EF815718EC800B2D163 /* CoreGraphics.framework */, + C76D3EF615718EBC00B2D163 /* UIKit.framework */, C7D2DC29155AFE6D00B3A468 /* GHUnitIOS.framework */, C74F8E551555E39D0008B054 /* OCHamcrestIOS.framework */, C74F8E561555E39D0008B054 /* OCMockLibrary */, - C77E5F9F13D0CA2700298F87 /* UIKit.framework */, - C77E5F9C13D0CA1800298F87 /* CoreGraphics.framework */, ); path = Frameworks; sourceTree = ""; @@ -1302,7 +1302,6 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = "iOS App Unit Tests/iOS App Unit Tests.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; @@ -1362,7 +1361,6 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = "iOS App Unit Tests/iOS App Unit Tests.entitlements"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = ( diff --git a/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m b/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m index fb0cb59..590c978 100644 --- a/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m +++ b/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m @@ -130,12 +130,13 @@ - (void) testImportNSColorAttributeToEntity { - NSColor *actualColor = [testEntity colorTestAttribute]; +#warning Proper fix is to extract out color tests to seperate mac and iOS specific model files with proper configurations + NSColor *actualColor = (NSColor *)[testEntity colorTestAttribute]; - assertThatFloat([actualColor alphaComponent], is(equalToFloat(255./255.))); - assertThatFloat([actualColor redComponent], is(equalToFloat(64./255.))); - assertThatFloat([actualColor greenComponent], is(equalToFloat(128./255.))); - assertThatFloat([actualColor blueComponent], is(equalToFloat(225./255.))); + assertThatDouble([actualColor alphaComponent], is(equalToDouble(255.0/255.0))); + assertThatDouble([actualColor redComponent], is(equalToFloat(64.0f/255.0f))); + assertThatDouble([actualColor greenComponent], is(equalToFloat(128.0f/255.0f))); + assertThatDouble([actualColor blueComponent], is(equalToFloat(225.0f/255.0f))); } - (NSDate *) dateFromString:(NSString *)date diff --git a/Project Files/Unit Tests/MagicalRecordTests.m b/Project Files/Unit Tests/MagicalRecordTests.m index 531d1c1..bc1db76 100644 --- a/Project Files/Unit Tests/MagicalRecordTests.m +++ b/Project Files/Unit Tests/MagicalRecordTests.m @@ -37,7 +37,7 @@ - (void) testCreateDefaultCoreDataStack { - NSURL *testStoreURL = [NSPersistentStore MR_urlForStoreName:kMagicalRecordDefaultStoreFileName]; + NSURL *testStoreURL = [NSPersistentStore urlForStoreName:kMagicalRecordDefaultStoreFileName]; [[NSFileManager defaultManager] removeItemAtPath:[testStoreURL path] error:nil]; [MagicalRecord setupCoreDataStack]; diff --git a/Project Files/Unit Tests/NSManagedObjectHelperTests.m b/Project Files/Unit Tests/NSManagedObjectHelperTests.m index 5e11d16..e440799 100644 --- a/Project Files/Unit Tests/NSManagedObjectHelperTests.m +++ b/Project Files/Unit Tests/NSManagedObjectHelperTests.m @@ -94,10 +94,10 @@ - (void) createSampleData:(NSInteger)numberOfTestEntitiesToCreate { - for (NSInteger i = 0; i < numberOfTestEntitiesToCreate; i++) + for (int i = 0; i < numberOfTestEntitiesToCreate; i++) { SingleRelatedEntity *testEntity = [SingleRelatedEntity createEntity]; - testEntity.mappedStringAttribute = [NSString stringWithFormat:@"%ld", i / 5]; + testEntity.mappedStringAttribute = [NSString stringWithFormat:@"%d", i / 5]; } [[NSManagedObjectContext MR_defaultContext] MR_save];