Fast kernel data does not store data permanently

I have an Entity called "Friend". Attributes are name and age. I implemented the bridge because the NSManagedObject class for Friend has .h and .m files. My code for storing data:

var err: NSError? var delegate:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate var friend:Friend = Friend(entity: NSEntityDescription.entityForName("Friend", inManagedObjectContext: delegate.managedObjectContext), insertIntoManagedObjectContext: delegate.managedObjectContext) friend.friendName = "Mani" friend.friendAge = "23" delegate.managedObjectContext.save(&err) 

My code to retrieve data

 var result: Array = delegate.managedObjectContext.executeFetchRequest(NSFetchRequest(entityName: "Friend"), error: &err) println("reslut \(result)") 

Therefore, when I return, it gives a result with data. But it is not saved forever .. If I leave and run the application, then the previous data has disappeared. Tell me what the problem is with my code ...

Here is an example project https://github.com/rnystrom/Swift-CoreData I got it from Github .. this project also has the same problem.

-one
ios8 swift xcode6 core-data
source share
1 answer

What is the return value of the save method, is it true or false? Can you show what output the following line has if you put it right in front of the line using the save method:

 println("delegate: \(delegate); MOC: \(delegate.managedObjectContext)") 
+1
source share

All Articles