1. Get the managed context: let managedObjectContext = (NSApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext! //Change AppDelegate for the name of the class of your Application Delegate 2. Set a variable to store the data: var contentsOfTransactionFetchRequest = [] 3. Fetch the data you need let fetchRequest = NSFetchRequest(entityName: “Whatever”) …
Monthly Archives: January 2016
Working with NSUserDefaults in Swift 2
I was quite pleased to see than in Swift is even easier than in Objective-C. Here is how you do it: Create a variable that can access them: var userDefaults = NSUserDefaults.standardUserDefaults() Add values to dictionary: userDefaults.setObject(“StringText”, forKey: “KeyInDictionary”) Read values from dictionary: let text = userDefaults.objectForKey(“KeyInDictionary”) as! …