How to register an Alibaba Cloud account with the code

Source: Internet
Author: User

Prepare for the xcode4.2 IOS5 sdk required by iCloud:

1. You need to upload a new app id. If you have one, ensure that the app id is not a wildcard.

2. After the creation is complete, you need to enable this function, just like development push, and then create a new Provisional Profile

3. Select the project's summary and scroll to entitlement and click entitlements. xcode will automatically create an *. entitlements

4. click *. entitlements: add the three fields in the pist list to the content in the format of Team_ID.com.yourcompany.icloudtest. Do not confuse team_id with app_id. When you have created Provisional, the top 10 characters.

5. Then you can write the following code in delegate.

 
 
  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
  2.  { 
  3.  // Override point for customization after application launch. 
  4.  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
  5.  
  6. NSFileManager *fileManager = [NSFileManager defaultManager]; 
  7.  // Team-ID + Bundle Identifier 
  8.  NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:@"ZZZZ826ZZ2.com.yourcompany.icloudtest"]; 
  9.  NSLog(@"%@", [iCloudURL absoluteString]); 
  10.  
  11. NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore defaultStore]; 
  12.  [cloudStore setString:[iCloudURL absoluteString] forKey:@"iCloudURL"]; 
  13.  [cloudStore synchronize]; // Important as it stores the values you set before on iCloud 
  14.  
  15. 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))]; 
  16.  myLabel.font = [UIFont fontWithName:@"Marker Felt" size:round(self.window.bounds.size.width/20.0)]; 
  17.  myLabel.numberOfLines = 4; 
  18.  myLabel.text =[ @"iCloudURL=" stringByAppendingFormat:@"%@", [cloudStore stringForKey:@"iCloudURL"]]; 
  19.  myLabel.backgroundColor = [UIColor clearColor]; 
  20.  myLabel.textColor = [UIColor whiteColor]; 
  21.  myLabel.textAlignment = UITextAlignmentCenter; 
  22.  [self.window addSubview:myLabel]; 
  23.  
  24. [self.window makeKeyAndVisible]; 
  25.  return YES; 
  26.  } 

Download DEMO: iCloudTest

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.