Permalink
Browse files

Merge pull request #6 from sakrist/master

Updated for 10.8 deployment target
  • Loading branch information...
2 parents f65af7a + fad16a3 commit d74fbd68fb412b7acf419fc0896ff8a31355f1aa @drewmccormack committed Feb 5, 2013
@@ -256,7 +256,10 @@ -(void)addStoreToPersistentStoreCoordinator:(void (^)(BOOL success, NSError *err
{
if ( completionBlock ) completionBlock = [completionBlock copy];
dispatch_queue_t completionQueue = dispatch_get_current_queue();
+
+#if !OS_OBJECT_USE_OBJC
dispatch_retain(completionQueue);
+#endif
// Use cloud storage if iCloud is enabled, and the user default is set to YES.
NSURL *storeURL = self.cloudStoreURL;
@@ -296,10 +299,13 @@ -(void)addStoreToPersistentStoreCoordinator:(void (^)(BOOL success, NSError *err
dispatch_async(completionQueue, ^{
completionBlock(nil != store, error);
+#if !OS_OBJECT_USE_OBJC
dispatch_release(completionQueue);
+#endif
});
-
+#if !OS_OBJECT_USE_OBJC
dispatch_release(serialQueue);
+#endif
});
}
@@ -316,13 +322,17 @@ -(void)makeManagedObjectContext
-(void)checkIfCloudDataHasBeenReset:(void (^)(BOOL hasBeenReset))completionBlock
{
dispatch_queue_t completionQueue = dispatch_get_current_queue();
+#if !OS_OBJECT_USE_OBJC
dispatch_retain(completionQueue);
+#endif
BOOL usingCloudStorage = [[NSUserDefaults standardUserDefaults] boolForKey:MCUsingCloudStorageDefault];
if ( usingCloudStorage && !self.cloudStoreURL ) {
dispatch_async(completionQueue, ^{
completionBlock(YES);
+#if !OS_OBJECT_USE_OBJC
dispatch_release(completionQueue);
+#endif
});
return;
}
@@ -334,14 +344,18 @@ -(void)checkIfCloudDataHasBeenReset:(void (^)(BOOL hasBeenReset))completionBlock
[tempSentinel checkCurrentDeviceRegistration:^(BOOL deviceIsPresent) {
dispatch_async(completionQueue, ^{
completionBlock(!deviceIsPresent);
+#if !OS_OBJECT_USE_OBJC
dispatch_release(completionQueue);
+#endif
});
}];
}
else {
dispatch_async(completionQueue, ^{
completionBlock(NO);
+#if !OS_OBJECT_USE_OBJC
dispatch_release(completionQueue);
+#endif
});
}
}
@@ -126,8 +126,10 @@ -(void)checkCurrentDeviceRegistration:(void (^)(BOOL deviceIsRegistered))complet
{
if ( completionBlock ) completionBlock = [completionBlock copy];
+#if !OS_OBJECT_USE_OBJC
dispatch_queue_t completionQueue = dispatch_get_current_queue();
dispatch_retain(completionQueue);
+#endif
NSURL *url = self.syncedDevicesListURL;
[url syncWithCloud:^(BOOL succeeded, NSError *error) {
@@ -144,9 +146,11 @@ -(void)checkCurrentDeviceRegistration:(void (^)(BOOL deviceIsRegistered))complet
NSString *defaultsDataset = [[NSUserDefaults standardUserDefaults] stringForKey:MCCloudResetSentinelSyncDataSetIDUserDefaultKey];
deviceIsRegistered &= [dataset isEqualToString:defaultsDataset];
- dispatch_async(completionQueue, ^{
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if ( completionBlock ) completionBlock(deviceIsRegistered);
+#if !OS_OBJECT_USE_OBJC
dispatch_release(completionQueue);
+#endif
});
}];
if ( error ) NSLog(@"%@", error);
@@ -178,8 +182,10 @@ -(void)updateDevicesList:(void (^)(void))completionBlock
if ( completionBlock ) completionBlock = [completionBlock copy];
+#if !OS_OBJECT_USE_OBJC
dispatch_queue_t completionQueue = dispatch_get_current_queue();
dispatch_retain(completionQueue);
+#endif
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[url syncWithCloud:^(BOOL succeeded, NSError *error) {
@@ -229,9 +235,11 @@ -(void)updateDevicesList:(void (^)(void))completionBlock
}];
}
- dispatch_async(completionQueue, ^{
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if ( completionBlock ) completionBlock();
+#if !OS_OBJECT_USE_OBJC
dispatch_release(completionQueue);
+#endif
});
}];
});
@@ -3,6 +3,6 @@
@interface NSURL (MCExtensions)
--(void)syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock;
+- (void) syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock;
@end
@@ -3,8 +3,8 @@
@implementation NSURL (MCExtensions)
--(void)syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock
-{
+- (void) syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock {
+
NSError *error;
NSNumber *downloaded;
BOOL success = [self getResourceValue:&downloaded forKey:NSURLUbiquitousItemIsDownloadedKey error:&error];
@@ -33,14 +33,21 @@ -(void)syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock
// Download not complete. Schedule another check.
double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
+
+#if !OS_OBJECT_USE_OBJC
dispatch_queue_t queue = dispatch_get_current_queue();
dispatch_retain(queue);
dispatch_after(popTime, queue, ^{
[self syncWithCloud:[completionBlock copy]];
dispatch_release(queue);
});
- }
- else {
+#else
+ dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ [self syncWithCloud:[completionBlock copy]];
+ });
+#endif
+
+ } else {
completionBlock(YES, nil);
}
}

0 comments on commit d74fbd6

Please sign in to comment.