First at all here is how you can enable iCloud support:http://www.raywenderlich.com/6015/beginning-icloud-in-ios-5-tutorial-part-1Howover I did got wawe of Entitlements issues, but finally I got fixed that too. Here is the final Entitlements content I used, putted in maually in noteblok:
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSBundle.h>
#import <string.h>
char iString[512]="";
const char* iCloudURL()
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *bundleID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
NSLog(@"bundleID is: %@", bundleID);
NSString *appID = [NSString stringWithFormat:@"N3L62N3PZ4.%@", bundleID];
NSLog(@"appID is: %@", appID);
NSURL *testCloudURL = [fileManager URLForUbiquityContainerIdentifier:appID];
if (testCloudURL==NULL)
return iString;
NSString *myURL = [testCloudURL absoluteString];
NSLog(@"testCloudURL is: %@", myURL);
strcpy(iString, [myURL UTF8String]);
return iString;
}
This will either return null or a url. The url is actuelly just a folder pointer , so there require no networking uploading and such. iOS doing that its self in a thread.
in GlBasic, you can check iCloud test doing something like this:
?IFDEF IPHONE
IMPORT "C" const char* iCloudURL()
LOCAL iCloud$=iCloudURL()
iCloud$=REPLACE$(iCloud$, "file://localhost/private", "")
iCloud$=URLDECODE$(iCloud$);
IF LEN(iCloud$)>3
CLOUDFILE$=iCloud$+"Save.ini"
ENDIF
?ENDIF
Howover remember you can NOT access files directly from the iClould folder. If you doing that, then GlBasic will crash out by a GLB Error 3. But you can do a COPYFILE from AppData file to your iCloud folder before use, something like this for saving:
FUNCTION LoadCloudStr: File$
DEPRINT("LoadCloudStr: "+File$)
LOCAL SaveFile2$=REPLACE$(SaveFile$, "save.ini", "save2.ini")
LOCAL SaveFile2$=REPLACE$(SaveFile$, "Save.ini", "Save2.ini")
COPYFILE File$, SaveFile2$
LOCAL si=GETFILESIZE(SaveFile2$)
IF si>0
DEPRINT("SaveFile2$: "+si)
LoadStr(SaveFile2$, "all", 1)
ENDIF
ENDFUNCTION
A Example for iCloud use:I use iCloud for sync the game by the scoring and stars progress between devices. Its checking if the scoring and stars got is higher on the cloud file and then eventuelly update it. Also I read the cloud file when exiting a level, before sync back again to avoid eventeully confict.
Another example could been updating savegame from a light to paid version of the game. YES, using iCloud will been possible to share data between app if user have enabled iCloud.
This is extractly why I looked Dropbox, but I still do that in later day. Howover I did got iCloud working first.
PS. TEAMID and APPID is NOT the same. Remember to replace those with your own of course.