zoukankan      html  css  js  c++  java
  • iCloud基础知识

    本文由cocoachina会员1056975026分享

     iCloud需要xcode4.2 IOS5 sdk 请先做好准备工作:

    1.需要传件一个新的app id,要是有了一个的话,保证着个app id 不是一个通配符的那种。

    2.创建完成之后,你要做的是开启这项功能,就跟开发推送一样,然后在创建一个新的Provisional Profile


    3.选择工程的summary,滚动到entitlement点击entitlements,xcode会自动的创建一个*.entitlements


    4.点击创建的*.entitlements,分别把pist列表里的三个字段都添上内容,格式为 (Team_ID.com.yourcompany.icloudtest),不要把team_id 跟 app_id弄混了啊,team_id是你创建完Provisional的时候,在最前面显示的那10个字符。


    5.然后就可以在delegate里面写下面的代码了


    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    NSFileManager *fileManager = [NSFileManager defaultManager];
    // Team-ID + Bundle Identifier
    NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:@"ZZZZ826ZZ2.com.yourcompany.icloudtest"];
    NSLog(@"%@", [iCloudURL absoluteString]);

    NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore defaultStore];
    [cloudStore setString:[iCloudURL absoluteString] forKey:@"iCloudURL"];
    [cloudStore synchronize]; // Important as it stores the values you set before on iCloud

    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,round(self.window.bounds.size.height/4.0),self.window.bounds.size.width,round(self.window.bounds.size.height/8.0))];
    myLabel.font = [UIFont fontWithName:@"Marker Felt" size:round(self.window.bounds.size.width/20.0)];
    myLabel.numberOfLines = 4;
    myLabel.text =[ @"iCloudURL=" stringByAppendingFormat:@"%@", [cloudStore stringForKey:@"iCloudURL"]];
    myLabel.backgroundColor = [UIColor clearColor];
    myLabel.textColor = [UIColor whiteColor];
    myLabel.textAlignment = UITextAlignmentCenter;
    [self.window addSubview:myLabel];

    [self.window makeKeyAndVisible];
    return YES;
    }

       

    原帖地址:http://www.cocoachina.com/bbs/read.php?tid=81242

  • 相关阅读:
    Windows Vs2010 + Qt5
    Java基础1
    关键字volatile
    内联函数
    Const详解2
    模板特化
    引用
    旧代码中的"enum hack"
    angularjs之ngoption
    angularjs之向下一个页面传参
  • 原文地址:https://www.cnblogs.com/ligun123/p/2276487.html
Copyright © 2011-2022 走看看