Permalink
Browse files

Add a background data queue for saveInBackground action methods

Fix a typo method name
Fix compile warnings for Mac and iOS
  • Loading branch information...
1 parent 02a3ba6 commit e4cd1704cce796c25ac2d48f8ae703cd9e21ea23 @casademora casademora committed May 26, 2012
View
4 MagicalRecord/Categories/DataImport/MagicalImportFunctions.h
@@ -15,11 +15,11 @@ NSString * attributeNameFromString(NSString *value);
NSString * primaryKeyNameFromString(NSString *value);
#if TARGET_OS_IPHONE
-
+#import <UIKit/UIKit.h>
UIColor * UIColorFromString(NSString *serializedColor);
#else
-
+#import <AppKit/AppKit.h>
NSColor * NSColorFromString(NSString *serializedColor);
#endif
View
2 MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m
@@ -31,7 +31,7 @@ - (NSString *) MR_lookupKeyForAttribute:(NSAttributeDescription *)attributeInfo;
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)
{
View
2 MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.h
@@ -10,6 +10,6 @@
@interface NSString (MagicalRecord_DataImport)
-- (NSString *) MR_capitalizedFirstCharaterString;
+- (NSString *) MR_capitalizedFirstCharacterString;
@end
View
2 MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m
@@ -11,7 +11,7 @@
@implementation NSString (MagicalRecord_DataImport)
-- (NSString *) MR_capitalizedFirstCharaterString;
+- (NSString *) MR_capitalizedFirstCharacterString;
{
if ([self length] > 0)
{
View
25 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 @@ @implementation NSManagedObject (MagicalRecord_DataImport)
- (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 @@ - (void) MR_addObject:(NSManagedObject *)relatedObject forRelationship:(NSRelati
{
//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 @@ - (void) MR_setRelationships:(NSDictionary *)relationships forKeysWithDictionary
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)
{
View
50 MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m
@@ -21,25 +21,29 @@ @implementation NSManagedObjectContext (MagicalObserving)
- (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 @@ - (void) MR_mergeChangesFromiCloud:(NSNotification *)notification;
[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 @@ - (void) MR_mergeChangesOnMainThread:(NSNotification *)notification;
- (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
View
1 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
View
3 MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m
@@ -198,7 +198,8 @@ - (void) MR_addiCloudContainerID:(NSString *)containerID contentNameKey:(NSStrin
{
completionBlock();
}
- [[NSNotificationCenter defaultCenter] postNotificationName:kMagicalRecordPSCDidCompleteiCloudSetupNotification object:nil];
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter postNotificationName:kMagicalRecordPSCDidCompleteiCloudSetupNotification object:nil];
});
});
}
View
4 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;
View
68 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 @@ + (void) saveInBackgroundWithBlock:(void(^)(NSManagedObjectContext *localContext
[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
View
6 MagicalRecord/Core/MagicalRecord.m
@@ -13,6 +13,12 @@ + (void) cleanUpStack;
@end
+@interface NSManagedObjectContext (MagicalRecordInternal)
+
++ (void) MR_cleanUp;
+
+@end
+
@implementation MagicalRecord
View
1 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.
*/
-
View
18 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 = "<group>"; };
C76AF7FA13DBEB5500CE2E05 /* ImportSingleRelatedEntityTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImportSingleRelatedEntityTests.m; path = "Unit Tests/ImportSingleRelatedEntityTests.m"; sourceTree = "<group>"; };
C76AF82913DBEE5A00CE2E05 /* SingleRelatedEntity.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = SingleRelatedEntity.json; path = "Unit Tests/Fixtures/SingleRelatedEntity.json"; sourceTree = "<group>"; };
- 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 = "<group>"; };
C77E5FA713D0CBDE00298F87 /* MagicalRecordTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MagicalRecordTests.m; path = "Unit Tests/MagicalRecordTests.m"; sourceTree = "<group>"; };
C77E5FB213D0D1D100298F87 /* SingleEntityWithNoRelationships.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = SingleEntityWithNoRelationships.plist; path = "Unit Tests/Fixtures/SingleEntityWithNoRelationships.plist"; sourceTree = "<group>"; };
@@ -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 = "<group>";
@@ -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 = (
View
11 Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m
@@ -130,12 +130,13 @@ - (NSDate *) dateFromString:(NSString *)date
- (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
View
2 Project Files/Unit Tests/MagicalRecordTests.m
@@ -37,7 +37,7 @@ - (void) assertDefaultStack
- (void) testCreateDefaultCoreDataStack
{
- NSURL *testStoreURL = [NSPersistentStore MR_urlForStoreName:kMagicalRecordDefaultStoreFileName];
+ NSURL *testStoreURL = [NSPersistentStore urlForStoreName:kMagicalRecordDefaultStoreFileName];
[[NSFileManager defaultManager] removeItemAtPath:[testStoreURL path] error:nil];
[MagicalRecord setupCoreDataStack];
View
4 Project Files/Unit Tests/NSManagedObjectHelperTests.m
@@ -94,10 +94,10 @@ - (void) testCanDeleteEntityInstance
- (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];

0 comments on commit e4cd170

Please sign in to comment.