iPad app accessing a Database


Hello all,
not sure if any of you have ever coded in C++,C#,Foxpro etc. but text fields there has this property called “Control Source”. That lets you specify what field the text box should display. Example the control source of your age field will be student.age (where student is the name of the table).

Im just wondering if something similar can be done in Xcode and is it covered in the nerd ranch book 2nd edition

Thank you


I think (though I’d be happy to be corrected by others) that the short answer is “no.”

The general mechanism you describe sounds like “bindings” in Cocoa, and when combined with a database would include Core Data.

You already see Core Data at work in the 1st edition chapter 27 (2nd edition chapter 17), but bindings do not yet exist for iOS.

If you want to see bindings and Core Data work together, check out chapter 11 on Basic Core Data in Aaron’s 3rd edition of Cocoa Programming for Mac OS X, but note that a 4th edition may be here in time for the holidays.


well if core data is the database (per say)
you saying there is no way to have a textbox on your iPad get that value?


Not without code.


Ah but it can be done.Great.Is it covered in the nerd ranch book on IOS programming 2nd edition?


Of course; data from any source can be displayed. XML data, JSON data, data from a web service, data from a database — whatever. I must have misunderstood the original question. It sounded like the goal was to display data from a database without writing any Objective C code. (And again, this is possible with Mac programming, just not with iOS.)

The 2nd edition does indeed cover Core Data to pull data from an SQLite database (chapter 17), but be forewarned it’s not for the faint of heart. For my little brain it’s probably the most difficult part of the book (but it’s something I need to become comfortable with).

Core Data is covered in the 1st edition as well (chapter 27). The 1st edition also has an interesting chapter on getting down and dirty with SQLite directly (chapter 26) so you can get a feel for everything that’s involved. It’s good to understand this but you’ll probably actually use it only in other development environments (which I suspect is part of the reason that chapter was dropped from the 2nd edition).

Remember the fun you had way back in chapter 6 with drawing, where it was very un-Cocoa-like (because, uh, it didn’t use Cocoa)? SQLite is like that; not pretty. So developers who need access at this level may use something like fmdb as an Objective C wrapper around SQLite. It’s still good to understand what’s really happening behind the scenes; you just probably won’t use it that way.

(I still recommend the 2nd edition, of course. With the updated code and techniques [like “blocks” — a fascinating construct] and greater emphasis on the iPad, plus focus on Xcode 4 [so pretty much every screenshot had to be updated] which otherwise seemed so obtuse to me, I’ve found it very useful.)