Alternate between different views using Objective-C - iphone

I am preparing an iPad app using, obviously, Objetive-C and wich tries to deploy Data Base stored content inside a view.
Now comes the problem, it will be a huge amount of records to be shown, each of them deployed inside some kind of "container" inside the view so that I was considering to make a page browser and in every page I go to change the view I apply.
Take for example, I show the first 5 items using example1.xib, for the next 5 example2.xip and so til getting to the page 10 and starting again with example1.xib.
My question is how this can be achieved? Maybe storing diferent view class based objects inside an array and alternating them or so...
Any help or hint would be greatly apreciated.
Cheers!

Always assume others have made similar apps before you. Perhaps not exactly the same ones as you, but doing similar things that you can learn from. The iPod and Spotify apps navigate large amounts of data using indexed, searchable TableViews. Go hunting on App Store for apps that have the same kind of functionality as yours, and test them out and grab what's good and discard what's bad about them.
My advice is to get hold of a nested tables example using the built in SQLite, and go from there. I've no idea what your database looks like, but with a bit of luck you could adapt example code and just open (a converted) SQL database.
Most users by now are used to the drill down paradigm rather than the paginated paradigm, so it's worth checking out the Drill Down example that comes with XCode even if it's not for databases (at least I don't think it is, I learned from a book, like Manuel.)

I would subclass UIViewController or UITableViewController depending on what type of records you plan on using.
I would recommend checking all the Apple's Examples, and most of the available online tutorial
Here are some, may be old though...
http://www.edumobile.org/iphone/iphone-programming-tutorials/tabbarcontroller-with-navigationcontroller-and-tableview-in-iphone/
http://www.aboveground.com/tutorials/adding-a-uitableview-to-a-custom-uiview
http://www.icodeblog.com/2008/08/08/iphone-programming-tutorial-populating-uitableview-with-an-nsarray/
http://blog.webscale.co.in/?p=150
http://www.ioschef.com/2011/03/un-aperitivo-de-uitableview-y-uitableviewcontroller/ in spanish..
http://adeem.me/blog/2009/05/19/iphone-programming-tutorial-part-1-uitableview-using-nsarray/ with videotutorial

Related

How to set up an iOS app to have perpetual memory?

I am asking what code to use to save user data in the app so that it is perpetual, even after the app is closed and reopened. I watched a few videos but my code isn't working.
I'm not interested in fixing code, I want to understand the process so I can reapply. Can anyone help me to understand how to do this and explain it in a way that makes sense for long term app development.
It will differ by application, depending on how much data and how it's organized.
If it's simple stuff, look at NSUserDefaults. If it's complicated and represented as objects, look at Core Data. If there's a lot of it and you see it as table rows rather than objects, you can use the sqlite3 database directly. If it has to be shared with other users or by other apps, start thinking about an external server or "the cloud".
There's no single right answer but those options should get you thinking about requirements.

iPhone Database of People with Properties?

In the iPhone app I am developing, I need to have a list of people which is stored.
So the user go into the 'People' view and there I want a table view which the user can edit by adding and removing people to their list. Each person will also need to have properties, such as first name, last name, age etc as some examples.
I am unsure of how to approach this as its my first time. My main curiosities are how to have a list of people and go to a view displaying that persons unique properties. How to have each entry/person have its own unique properties (which I can define) and how to save/load them. It of course has to be persistent, so when the application is quit the data stays when reloaded.
Obviously code samples help understanding a lot, but any pointing in the right direction is really appreciated, thanks.
Too broad to really answer, but here's some pointers:
Use Core Data for storage.
Create a Person class, with each person being an NSManagedObject with various properties like first name, last name and so on.
Use an NSFetchedResultsController to populate a TableView with your people.
CoreData is the way to go. I have found this tutorial particularly helpful when I was learning iOS and CoreData.
http://www.raywenderlich.com/934/core-data-tutorial-getting-started
But Apple Documentation is good as well.
https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html
Easiest: Use NSUserDefaults. Define a class "Person". Store instances of "Person" in an NSArray and save it in NSUserDefaults. It'll give you persistence but little else. If you have any search or data modification operations, you'll have to write your own code and it can become cumbersome pretty soon. For very simple apps only.
SQLite3: You'll need to know/learn about SQL a bit and also know how to design tables, but will keep your life simpler if you need to do sophisticated searches, etc.
Core Data: Apple's recommended solution to all your database needs. Highest learning curve, but simplifies many sophisticated tasks (undo operations, etc.). A good choice for 90% of the apps.

UITableView theory help for a grizzled old web developer

I am a web developer who is trying to transition to Objective-C and Cocoa-touch. I am used to creating a table as a Dom element and then inserting it. If I wanted a link I did that as I went along. Obviously iPhone development is very different. I am looking for either a good explanation of hOw to wrap one's mind around the cocoa way of doing things.
Specifically I am looking to pull data from a web service and then make a drill down 3 or 4 levels deep. If there is a tutorial that shows how to do that perhaps I can learn through that.
Take a look at Apple's SeismicXML sample code. There's a lot in there, but it's basically what you asked for: an example of grabbing data from a web service and displaying it in a table.
There's a pretty big difference between creating a table on a web page and creating one in an iOS application. In the first case, you're actually writing down the data that gets rendered into a table by a browser. In the second case, you're creating a table object, and that table is like a living, breathing (compared to a web page, anyway) thing that can change through it's lifetime. The table will ask your code for data to display, and also what to do at certain points, such as when a user taps a cell.
Looking at a sample like SeismicXML is a good idea, but you'll still be mystified if you don't take the time to really understand what's going on. (I'm not saying you wouldn't, but there are plenty who don't and are confused to this day.) Go look, and then come back here if you have more questions.
The paradigm for iPhone tables is very different from HTML. On the web, you build the table and its elements and insert them into the DOM. On the iPhone, you have a proxy object that answers questions as the table builds itself. The table will ask the delegate how many entries it has and what it should put in each entry. That way, the delegate only needs to look up the information that is currently needed by the table, and not the whole thing, which may be only partially displayed. For instance, the delegate might to database queries as needed.
The simplest way is for your delegate to grab the info it needs from the web site and store it in an array for when the TableView asks for it.
The TableView itself is placed on the screen by calling addSubview: on a parent view.
You're asking more than one question here. You should split them up into multiple, more specific questions.
There are a variety of ways to make HTTP requests, anywhere from using the bundled classes like NSURL to using external libraries like ASIHTTPRequest. It also depends on what kind of data you are getting from the Web service -- there are various libraries to parse XML and JSON.
To make a "drill down" I assume you are describing table-based navigation. There are dozens of examples in the Apple sample code archive of projects showing off how to use UITableViewController, and probably hundreds available on Stack Overflow.

iOS/ObjC, storing user input and retrieving it

Pretty new to iOS dev, I feel I have a grasp of the basics. I was thinking through an app I would like to make and the steps involved, components needed... and I have no idea how to or what is the best method to save user input and retrieve it.
An example being (I don't plan to make this, but it illustrates what I want to know), say a simple to-do list, it has NSTableView that is populated from NSMutuableArray, to begin with it is blank as the user has added nothing. Once an item is added to the array, table reloads thanks to -reloadData. The item that is needed to-do is shown in the table. Great for this session... but not when the app is reopened.
I imagine I need to store the array and then reload it when the app next initialises, is this correct?
Or is there any other better method?
If you're just starting out. The best way to go is to use Core Data to save and display your data. You'll thank me in the end.
http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/CoreData/cdProgrammingGuide.html#//apple_ref/doc/uid/TP30001200-SW1
Tutorials
http://www.raywenderlich.com/934/core-data-tutorial-getting-started
http://developer.apple.com/cocoa/coredatatutorial/index.html
http://themikeswan.wordpress.com/2009/05/22/7/
Do a google search there are lots of resources.
In addition to Jordan's answer, mostly for completeness so you understand your options. You have at least another two options:
Serialization using NSCoding (Archives and Serializations Programming Guide
Property Lists (Property Lists Programming Guide)
Both these concepts are easier to understand than a proper relational database and are for simpler things worth considering. Especially since TODO lists are not likely to contain large amounts of data.
Property Lists is the easiest and most basic one in terms of functionality. It just lets you store primitives, but is good if your TODO list is just a collection of Strings.
Serilization using NSCoding is more powerful, but requires more work from the developer. With NSCoding you can create your own coders/decoders for your business objects that lets you persist the entire state. This would be good if you have your own Todo with a lot of properties, like title, priority, complete-by-date etc.

UIWebView - How does tabbed browsing work?

I've a noobish question. How does tabbed browsing work? I mean that you save the current webView with it's content in an array and show it later.
like you can read here http://www.iphonedevsdk.com/forum/iphone-sdk-development/24521-please-need-help-webview.html I made few attempts but no luck so far.
as anyone a nice suggestion? Thanks in advance
Implementing a tabbed web browser is more of a design challenge than a pure programming challenge. You need to consider how the user will switch between different tabs. From a data structure perspective, you can store multiple instances of UIWebView in an array, as you mention.
From a design perspective, you should look at the way Apple implements their web browser. Their approach seems to be more of a multiple window system than a multiple tab system.
One thing to keep in mind, UIWebView's use a lot of RAM, so be careful keeping too many stored in memory.
PS: if you are interested in checking out a tutorial on UIWebView check out this tutorial