Use and Make the core data compatible to iOS 8.0 to current Version

Core Data

Some time we need to use core data in application , for that we use in build core data provided by iOS but on the time of creation we select core data and default code attach to appdelegate class and its version is set to current , when we less the iOS version of application then the default code is not supported so we need such code that run from lower version to current version.

For this we need to add some code .

1: On creating a new project select core data.

2: add this code in appdelegate.swift class.

 

3: Now you can use the any function for insert or delete or update

exam:

Here is example for saving the data in core data “Person” is entity name and   “name”,”age” is attribute.

 

 

4: Select coredataxml file and click on editor and select create NSMangedsubclass.

5: then it will create a two file.

1: Person + CoreDataClass.swift

So write:

2: Person + CoreDataProperties.swift

write this:

6: for updation or view all .

create a Service.swift class

and write  this:

 

6: for update write this function:

in your viewcontroller class

 

7: For viewall data

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close