Created
September 29, 2014 11:25
-
-
Save dminchev/23fc2ea51a2d7c63024c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
var appDel:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate | |
var context:NSManagedObjectContext = appDel.managedObjectContext! | |
/* | |
var newUser = NSEntityDescription.insertNewObjectForEntityForName("Users", inManagedObjectContext: context) as NSManagedObject | |
newUser.setValue("Rob", forKey: "username") | |
newUser.setValue("Pass", forKey: "password") | |
context.save(nil) | |
*/ | |
var request = NSFetchRequest(entityName: "Users") | |
request.returnsObjectsAsFaults = false | |
var results = context.executeFetchRequest(request, error: nil)! as Array<Users> | |
if results.count > 0 { | |
for result: Users in results { | |
println(result.password) | |
println(result.username) | |
} | |
} else { | |
println("no results") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment