I want to implement Core Data into my iPhone app. So what is the best way to learn Core Data specifically for the iPhone? I have 4ish hours that i can devote to this today, so ideally I would be competent enough to add this (however slightly) into my app.
The only way i retain data now is through NSUserDefaults, just so that when the app is closed and reopened, their data is still there. I want to give the user the ability to save sets of data, read them, edit them, delete them, etc.
Getting Started with Core Data in the iPhone Dev Center did the trick for me. :-)
No, seriously, it might seem like obvious advice, but that one-page document lays out a nice strategy for which documents and tutorials to read and in which order. Once you work through the first tutorial it recommends, the weird terminology will feel a lot less weird.
If you don't already know about this, this is very useful:
Core Data Tutorial for iPhone OS
Two books that are great references for Core Data are "Core Data: Apple's API for Persisting Data on Mac OS X" by Marcus Zarra and "iPhone SDK Development" by Bill Dudney and Chris Adamson. Both walk you through sample code for handling Core Data on the iPhone, with slightly different perspectives on the framework. The Core Data book provides the best overall reference on the subject that you'll find, outside of Apple's own documentation.
Additionally, if you purchase the iPhone video track from this year's WWDC, the presentations "Introduction to Core Data on iPhone" and "What's New in Core Data" are great resources. ADC Select members also have access to Core Data presentations from older WWDCs, including ones that explain the fundamental concepts of the framework and how to tune the performance of your Core Data application.
Make sure you don't stop after the first document - Core Data Turorial for iPhone OS is excellent but then I tried to change the model and everything crashed with fairly cryptic error messages. Getting Started with Core Data is the next place to go. Unless you read the sections on versioning the data model you will probably run into big problems as soon as you start to adapt the example code for your own use.
Related
I'm new to IOS programming, and I have had a great time learning it. It took me about 4 months to really get a good grasp on it. I have began creating my own app, and I ran in to a few questions. The app I'm creating is a live app like instagram, foursquare, etc. How do I store all of the information I need. Can I use Core-Data to create a real-time app that can handle updates from multiple users?
The app I'm creating is a live app like instagram, foursquare, etc.
How do I store all of the information I need.
You'll probably create some sort of server to manage the data. Having a single, central source of data is a lot easier than trying to sync data between multiple devices.
Can I use Core-Data to create a real-time app that can handle updates from multiple users?
You can -- Core Data works on MacOS X as well as on iOS, so you could write a Mac program that is the server for your iOS app. Whether that's the best approach is another question... I suppose it depends on how well you already know Core Data, whether there are any advantages to using the same Core Data data model on both the server and the client, how many clients you think you might have to support at once, etc.
If you're asking about using Core Data on the iOS client, then yes, you can certainly do that.
looking to make an iOS app where I can take a picture and then send it to a my own searchable database, website or wiki. What would be the easiest service to do this (I can do the iOS programming its just I don't know about the other side of it).
The easiest option would be to use CoreData. If you don't know about CoreData, Apple has a very comprehensive set of documentation located here: https://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/iPhoneCoreData01/Introduction/Introduction.html
Using CD, you can save the images as NSData in the persistent store, and then turn them back into images as you fetch them from the store. The most common implementation of CoreData uses SQLite as the backing store.
I am not quite sure how to answer your question without building a db for you. If you are just looking for resources on how to build a db, check out this stackoverflow question
I've built a simple iPhone app that parses data from a remote XML feed, converts the information into objects (they're videos), and displays the videos in a standard table view->detail view->"Play Video" UI. There are hundreds of videos, each with about ten attributes. (The videos are never downloaded, only streamed, using MPMoviePlayerController.) I've relied on the Apple sample application SeismicXML for much of the app's behavior.
Now I'm ready for the next step: saving the video metadata to the device, so that users aren't forced to wait for the XML retrieval and parsing every time they launch my app. I'm planning to use Core Data to save my Video objects (and their parent Channel objects), but it's all brand new to me.
My question is: Can folks recommend any sample application or design pattern for managing this data? I want to have the app automatically download and parse the XML at launch, but then it should refresh the data only when the user taps a Refresh button, or if the data is older than, say, a day.
Apps that model this behavior are NYTimes, AP, and many others.
Besides the excellent documentation that Apple provides for Core Data, are there any resources out there for architecting an iPhone app that needs to download, save, and periodically refresh its data?
Thanks.
Update on 11/12/2009: Between the Apple sample code for TheElements, TopSongs, CoreDataBooks, PhotoLocations, iPhoneCoreDataRecipes, and XMLPerformance, I've got plenty of grist for the mill here. I'm currently analyzing the samples, and slowly piecing together what I need.
Looks like you found all of the Apple samples, so that's good.
The Pragmatic Programmers have a book on Core Data, and several of the iPhone SDK books out (including theirs) touch on Core Data a little. See also this question.
Edit: forgot to mention Three20 (the guts of the Facebook app, Open Sourced) as an example of a way to do this that isn't Core Data. Rather than re-constructing the downloaded data in some object graph that's persisted with Core Data, Three20 implements disk caching and freshness dating on top of the URL loading system. The app basically still works by making HTTP API calls, and parsing the responses, but doesn't have to talk to the cloud on every screen display, which speeds things up immensely. If you're only downloading this information to display in a big table view, and not anything else, perhaps this model might be easier.
I am building an iPhone app that contains medical information for medical professionals.
The data has a sort of taxonomy which is easily represented in the form of e.g. a mind map on a piece of paper. On the device, the idea is to navigate through a series of items in table views to get to a detail view with text and picture information. The no of child views/nodes varies from 1-4, and the number of items on each table view varies from 2 to 20. The detail items/views are about 120 in total.
Now, I have reasonably strong Obc-C/Cocoa skills (mostly mac), but have about zero experience from working with actual databases. So far, I have hard coded the information in nested NSArray/NSDictionary structures (much the way Apple demonstrates in its table view tutorial). This has obvious disadvantages, and I am considering swithcing to use some sort of database instead.
How would you, experienced iPhone programmers, solve a problem like this? SQLite database? Base app on Core Data?
Thankful for all sorts of help and suggestions.
-Gregor, Sweden
edit: implemented navigation/table view hierarchy with plist. Works like a charm. Will look into core data, if not for this project then for another with larger amounts of data.
I've created an app with an SQLite3 backend that worked out quite well. Performance was good.
If I were to start a new project from scratch, I'd definitely look at Core Data, as long as it's okay the project only runs on 3.0+ devices, as Core Data is a new feature in 3.0.
Ask your client if it's a big deal that the app not support 2.2.1 (last I looked at AdMob, that's still about 25% of iPhone users and 50% of iPod Touch users). If it is a big deal, then your answer is forced upon you.
Core Data in the iPhone 3.0 SDK. Adoption rates of the 3.0 SDK are huge! It's a software upgrade, free on iPhone. Hardware updates of Open GL ES 2.0 are more costly, people are slower to adopt the new hardware. But research online shows adoption of 3.0 is high.
Improved performance, uses SQL Lite underneath, and it's cross platform to Mac OSX. Lots of how to's out there for it as well.
// :)
CoreData on the iPhone makes this trivial, have a look at the Introduction Tutorial, then take a look at some of the other examples (there's complete versions of the tutorial app and the extended versions in the Dev Centre).
Look into RDF and OWL, you might find some C libs to handle data in those formats, which I think is more adequate than trying to fit graphs into a relational database.
I'm currently in the process of deciding whether or not to use Core Data for managing the data in my iphone application.
The application involves putting together a fairly sizeable library of content which needs to be localised and has a fair few relationships. One benefit I thought of using core data would be that I could perhaps build a desktop client for managing the data of the application, then package the resulting file with the iPhone app to use as its content database.
With my fairly limited knowledge of Core Data I wanted to know if this is possible? Are their any best-practices people can point me in the direction of?
This is basically a dupe of this question:
Provide Base Data for Core Data Application?
Short answer is - YES. I've done it, Apple does it. Works well.
Core Data defines the interface for interacting with the database, not the storage itself. You can use XML, Binary, or SQLite as the storage file. If you want a quick-and-dirty solution, you could use a basic SQLite application such as Menial's Bases to create a database. You can then add this to your XCode project for use by the iPhone. If you intend for the desktop client to be used by your iPhone customers, you can can use much of the same Core Data code from your iPhone project.
Core Data is now included starting a SDK 3.0.