Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 05-12-2010, 01:32 PM   #6 (permalink)
Duncan C
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 5,989
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by WTFWJD View Post
Hi

Bit of a newbie question here. I'm trying to make a one row table view -> detail view app. The table is an alphabetical list of items and the detail view is a corresponding image of those items; ie.

User taps Apple in table view - detail view shows picture of an apple

User taps 'Back' button and is returned to the table view

User taps Bicycle in table view - detail view shows picture of a bicycle

Etc...


Am I right in thinking that I can store the list of items and corresponding images in a single plist file that is used to populate the table view and the detail view? ie.


Root (Array)

Item 1 (Dictionary)
name (String) Apple
image(String) apple.png

Item 2 (Dictionary)
name (String) Bicycle
image(String) bicycle.png

Etc...


If so, is a Navigation-based Application template in Xcode the best place to start? Or will I need to write custom code to access the plist in this way?

Any help or advice would be greatly appreciated, many thanks!

You've got the right idea. A plist would be one way to save your data and read it at start time. A plist will archive/unarchive dictionaries or NSArray objects. However, those dictionaries/arrays can only contain a small list of data types (including mutable or immutable variants)


NSDictionary
NSArray
NSData
NSString
NSNumber

Your image files can't be stored into a plist directly.

The simplest way to handle that is to just store the filenames of your images into your plist, and save the images as separate files in your app bundle. Then, when you need one, load it using UIImage imageNamed:

Loading your plist is really trivial. Just use the NSArray method +arrayWithContentsOfFile:

The same goes with saving your array. To save it, call the NSArray object writeToFile:atomically:


Given that you want to have a table view that links to a detail view, and then lets the user go back to the table view, a navigation based application sounds perfect. In your table view controller, you'd just use the method pushViewController:animated: to push your detail view controller, and then pop it off when you want to go back to your table view controller.



Regards,

Duncan C
WareTo
Duncan C is offline   Reply With Quote
 

» Advertisements
» Online Users: 492
19 members and 473 guests
and1, AppsImpact, baja_yu, brendaiv45, BuzzingDanZei, Chickenrig, croy1, Domele, dylanreich, Gaz, jbro, MaestroApps, MarkC, mer10, Mrclam, pgw3, sacha1996, stoone, Yoonoo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,548
Threads: 94,075
Posts: 402,716
Top Poster: BrianSlick (7,990)
Welcome to our newest member, mrtdmb
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.