Reputation: 4980
It's been years since I've done iOS, but I'm jumping back into it and have a quick, beginners question. When the app launches, it will launch with a search field. You type in a persons name, hit enter, and info about the name will appear. I'm thinking about storing all the most common names in a plist, and having the search run through the plist after the user hits "enter", then display info about the name they typed in. This is where I'm stuck. After you type in the name and hit enter, I have no clue about how to make it display the info about the name, or even where to store data about the name. Any help is much appreciated, thanks!
Upvotes: 0
Views: 146
Reputation: 89559
I'll give you half of the answer you need here, the "loading" and "saving" part.
The "plist" you're talking about here is actually an array of names.
And -- how handy! -- "NSArray
" has both an "initWithContentsOfURL:
" method and a "writeToURL:atomically:
" method.
Any more than just a few names and people will start suggesting using Core Data.
Also, if you want to be able to change and/or save the names while the app is running, you'll need to use a "NSMutableArray
" instead of an immutable array.
As for the displaying part, you should probably learn how to use table views (UITableView) and binding (i.e. you "bind" to the array and values get displayed based on whatever the user typed into the search field). There are lots of tutorials and examples on this, as well as related questions here on StackOverflow.
Upvotes: 5