Skip to content

Instantly share code, notes, and snippets.

@MariuszWisniewski
Created March 1, 2016 02:14
Show Gist options
  • Save MariuszWisniewski/0ff8bf01c460996ca86f to your computer and use it in GitHub Desktop.
Save MariuszWisniewski/0ff8bf01c460996ca86f to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// iOS
//
// Created by Mariusz Wisniewski on 2/18/16.
// Copyright © 2016 Mariusz Wisniewski. All rights reserved.
//
import UIKit
import syncano_ios
class Author : SCDataObject {
var first_name = ""
var last_name = ""
var picture : SCFile? = nil
}
class ViewController: UIViewController {
let syncano = Syncano.sharedInstanceWithApiKey("API_KEY", instanceName: "INSTANCE_NAME")
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.testAuthor()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func testAuthor() {
func saveAuthor() {
let author = Author()
author.first_name = "First name"
author.last_name = "Last name"
author.owner_permissions = .Full
author.other_permissions = .Read
let data = "Some text that will be converted to NSData".dataUsingEncoding(NSUTF8StringEncoding)
author.picture = SCFile(withaData: data)
author.saveWithCompletionBlock { error in
print("\(author)")
print("\(error)")
}
}
let _ = SCUser.loginWithUsername("login", password: "password") { error in
saveAuthor()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment