Hello everybody. can nybody give me an example which will explain the process of storing the data in coredata which is received from webservice. i dont want to use sqlite DB. perhaps a link which demonstrates this kind of example.
There really isn't any particular trick related to web services in particular. Once you get the data from the service, you create instances of your Core Data classes and then populate them using the data just as you would with data from any other source such as the UI.
For example, most JSON implementations provide the returned data is a dictionary. You just set the properties in the core data object to the appropriate values in the dictionary.
If you're not familiar with how to setup and use core data, you should learn that first.
Edit:
From comment:
oh ok. so i understand how to assign a location of the file if it is in documents folder. but in this case i am getting the data from a webservice which is received in the form of a response. so wat do i do in this case? there will be no location to assign the store
There is no connection between the source of the data and location of the store file. In the normal case, you won't be connecting to a Core Data managed store on the webserver (possible but rare.) Instead the data will be coming from the server is a standard format such as JSON, REST, etc. Your app will create the local store (wherever you decide to put it) and initialize the Core Data stack. Then it will take the output of the JSON parser and create NSManagedObjects to represent the data. Then it will save those objects to the store just as it would with data form any other source.
So, in pseudocode it would look something like:
Core Data{
Create local persistent store in desired location;
Create managed object context;
Load managed object model:
}
Network Inteface {
Connect to Server;
Send request;
Parse request into objective-C data structure (array, dictionary, etc)
}
Load Data strucutre into Core Data{
Either {
Insert into context NSManageObject for entity that models recieved data
or
Insert into context instance of NSManagedObject subclass that models the recieved data
}
Set attributes of entity/instance to the appriopiate fields in the recieved data structure.
Save managed object context (which saves the entity/instance to the file on disk)
}
I think you're thinking this is a far more complex and involved process than it is. It is basically no different than saving data from a server to a local text file. The only difference is that you are saving to a Core Data stack instead.