Sedikit Info Seputar
iCloud integration in Swift 3.0
Terbaru 2017
- Hay gaes kali ini team Game Android Apk, kali ini akan membahas artikel dengan judul iCloud integration in Swift 3.0, kami selaku Team Game Android Apk telah mempersiapkan artikel ini untuk sobat sobat yang menyukai Game Android Apk. semoga isi postingan tentang yang saya posting kali ini dapat dipahami dengan mudah serta memberi manfa'at bagi kalian semua, walaupun tidak sempurna setidaknya artikel kami memberi sedikit informasi kepada kalian semua. ok langsung simak aja sob
Judul:
Berbagi Info Seputar
iCloud integration in Swift 3.0
Terbaru
link: iCloud integration in Swift 3.0
Berbagi iCloud integration in Swift 3.0 Terbaru dan Terlengkap 2017
Introduction of iCloud :iCloud provide the free service to store data from device to iCloud platform,
(Note : Some of limitation also) , and user can access their data form any device via AppleID. The main purpose is users easily put own data like images, videos, etc and also access the all stored items from any Apple device like iPhone, iPad, Mac etc.
We are providing the full steps of iCloud integration, Here we store images and text items on iCloud, Edit and delete functionality also in this tutorials with demo app.
Make provisional profile for iCloud Enable :
1 : Open Apple developer official site : https://developer.apple.com/[1]
2 : Click on Member Centre and login developer centre.
3 : There are six options , Select Certificate , Identifier & Profile
4 : Select Identifier > App IDs list display.
5 : Click on right corner + button and adding new Identifier.
6 : Adding details like
Name : iCloudTest
Bundle ID : com.cloudone.userDetails
8 : You can see here , iCloud is configurable but not enable.
2: Check bundle Identifier which is same as developer account also check team of account.
import CloudKit let container = CKContainer.default() let publicDB = container.privateCloudDatabase @IBAction func click_AddCloud(_ sender: AnyObject) { let publicDB = container.privateCloudDatabase let userData = CKRecord(recordType: "UserDetails") userData.setValue(txtFirstName.text, forKey: "firstName") userData.setValue(txtLastName.text, forKey: "lastName") userData.setValue(txtEmailID.text, forKey: "emailID") if (self.imageURLs == nil) { self.imageURLs = URL(fileURLWithPath: Bundle.main.path(forResource: "ima", ofType: "jpg")!) } print(imageURLs) let imageAsset = CKAsset(fileURL: imageURLs) userData.setObject(imageAsset, forKey: "Photos") DispatchQueue.main.async { publicDB.save(userData, completionHandler: { (record, error) -> Void in // print("saved") if error != nil{ let alertController = UIAlertController(title: "Error", message: "Opps!. Somthing wrongs.", preferredStyle: .alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (action) in _ = self.navigationController?.popViewController(animated: true) }) alertController.addAction(action) self.present(alertController, animated: true, completion: nil) }else{ let alertController = UIAlertController(title: "Success", message: "Data Saved Successfully on cloud.", preferredStyle: .alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (action) in _ = self.navigationController?.popViewController(animated: true) }) alertController.addAction(action) self.present(alertController, animated: true, completion: nil) } }) } } func fetchResults(){ let container = CKContainer.default() let privateDatabase = container.privateCloudDatabase let predicate = NSPredicate(value: true) let query = CKQuery(recordType: "UserDetails", predicate: predicate) privateDatabase.perform(query, inZoneWith: nil) { (results, error) -> Void in if error != nil { print(error?.localizedDescription) MBProgressHUD.hide(for: self.view, animated: true) } else { print(results) for result in results! { self.arrayDetails.append(result) } OperationQueue.main.addOperation({ () -> Void in self.tableView.reloadData() self.tableView.isHidden = false MBProgressHUD.hide(for: self.view, animated: true) }) } } } @IBAction func click_EditCloud(_ sender: AnyObject) { let publicDB = container.privateCloudDatabase let userData = CKRecord(recordType: "UserDetails") userData.setValue(txtFirstName.text, forKey: "firstName") userData.setValue(txtLastName.text, forKey: "lastName") userData.setValue(txtEmailID.text, forKey: "emailID") print(imageURLs) let imageAsset = CKAsset(fileURL: imageURLs) userData.setObject(imageAsset, forKey: "Photos") let saveRecordsOperation = CKModifyRecordsOperation(recordsToSave: [userData], recordIDsToDelete: [editableData.recordID]) saveRecordsOperation.recordsToSave = [userData] saveRecordsOperation.savePolicy = .ifServerRecordUnchanged saveRecordsOperation.modifyRecordsCompletionBlock = { savedRecords, deletedRecordsIDs, error in OperationQueue.main.addOperation({ () -> Void in if error != nil { let alertController = UIAlertController(title: "Error", message: error!.localizedDescription, preferredStyle: .alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (action) in _ = self.navigationController?.popViewController(animated: true) }) alertController.addAction(action) self.present(alertController, animated: true, completion: nil) } else { let alertController = UIAlertController(title: "Success", message: "Data Saved Successfully on cloud.", preferredStyle: .alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (action) in _ = self.navigationController?.popViewController(animated: true) }) alertController.addAction(action) self.present(alertController, animated: true, completion: nil) } MBProgressHUD.hide(for: self.view, animated: true) }) } publicDB.add(saveRecordsOperation) } func deleteRecords(){ MBProgressHUD.showAdded(to: self.view, animated: true) let selectedRecordID = self.arrayDetails[indexPath.row].recordID let container = CKContainer.default() let privateDatabase = container.privateCloudDatabase privateDatabase.delete(withRecordID: selectedRecordID, completionHandler: { (recordID, error) -> Void in if error != nil { print(error) } else { OperationQueue.main.addOperation({ () -> Void in self.arrayDetails.remove(at: indexPath.row) MBProgressHUD.hideAllHUDs(for: self.view, animated: true) self.tableView.reloadData() }) } }) } OUTPUT :
Thanks
References
- ^ https://developer.apple.com/ (developer.apple.com)
- ^ https://icloud.developer.apple.com/dashboard/ (icloud.developer.apple.com)














