II am trying to use Core Data for my iOS application and have been reading many tutorials and still really confused. Is using the iphone to add reference or adding them programmatically the only 2 ways to add row? I mean if I had a product catalog of 20 items I would need to type the code 20 times? Or could I just add row because the application is supposed to be read-only. Or am I just better off wth sqlite instead of Core Data? thanks in advance.
Share
The easiest way is to write a quick Mac app to do the editing, using the same data model file.
If you’re using Xcode 3, do this. Create a new Mac app that uses Core Data, and drag in your data model (removing the default data model it creates for you). Then, open the .xib file for the Mac app’s main window in Interface Builder. Switch back to Xcode and open the data model.
Pick the entity you want an editor for. Then hold down option (alt), and drag the entity from the data model editor into Interface Builder. It automatically creates a user interface for editing the database, which you can then save and run through Xcode.
Make sure that your Mac app is creating an sqlite data store (look through the code that Xcode created for you by default, it may have defaulted to XML and you’ll have to change it). The file that app creates can then be dropped straight into an iPhone app.
Sadly, Xcode 4 can’t do the automatic laying out of a database editing UI. If you’re using Xcode 4, you’d have to lay out the UI manually.