Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.swift
- // CloudApple
- //
- // Created by Jógvan Olsen on 3/1/16.
- // Copyright © 2016 Jógvan Olsen. All rights reserved.
- //
- import UIKit
- import CloudKit
- class ViewController: UIViewController {
- var db:CKDatabase?
- override func viewDidLoad() {
- super.viewDidLoad()
- db = CKContainer.defaultContainer().publicCloudDatabase
- insertUser("JohnDoe", password: "1234")
- }
- func insertUser(username:String, password:String){
- let record = CKRecord(recordType: "MyUsers"); // <-- DB Table in cloudkit
- record.setObject(username, forKey: "username"); // <-- Field name in the cloudkit table.
- record.setObject(password, forKey: "passsowrd");
- db?.saveRecord(record){
- record, error in
- if(error==nil){
- print("Sucessfully saved the record \(record)")
- }else{
- print("Failed to save record \(record)")
- }
- }
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement