Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Updated for 10.8 deployment target #6

Merged
merged 1 commit into from

2 participants

@sakrist

Hi

I did update of code for 10.8 deployment target. And it can be builded for 10.7.

Thanks

@drewmccormack drewmccormack merged commit d74fbd6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 5, 2013
  1. @sakrist
This page is out of date. Refresh to see the latest.
View
16 iCloudCoreDataTester/AppDelegate.m
@@ -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
});
}
}
View
12 iCloudCoreDataTester/MCCloudResetSentinel.m
@@ -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
});
}];
});
View
2  iCloudCoreDataTester/NSURLExtensions.h
@@ -3,6 +3,6 @@
@interface NSURL (MCExtensions)
--(void)syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock;
+- (void) syncWithCloud:(void (^)(BOOL success, NSError *error))completionBlock;
@end
View
15 iCloudCoreDataTester/NSURLExtensions.m
@@ -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);
}
}
Something went wrong with that request. Please try again.