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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-27-2009, 09:47 PM   #1 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 23
Default Return value from picker that is not the label

Is it possible to return a value from a picker that isn't what it has as it's label? I would like to return the primary key of the value listed in my picker. The values are loaded from sqlite.
SpyderDriver is offline   Reply With Quote
Old 01-27-2009, 09:55 PM   #2 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,122
Default

Look at it this way. You provided a picker view delegate that returned a title based on a row number and component number.

When the user picks a value you get notified with the same values - a component number and row number. Use the same logic to get your other data.
RickMaddy is offline   Reply With Quote
Old 01-27-2009, 10:01 PM   #3 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 23
Default

Are you saying to just fake the primary key by using the row number and hope that it is the same as the actual primary key? What if the query is reordered, it won't line up at that point. Is there a way to get the primary key of the record without having to do a whole query to get that?
SpyderDriver is offline   Reply With Quote
Old 01-27-2009, 10:13 PM   #4 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,122
Default

How did you get the data to begin with to populate the picker? I can't give too concrete of an answer because I don't know what you are doing. But in general I assume you are reading some data from a database to populate your pick view data model. Save enough info in that data model so that when a user picks a row from a component, you can grab enough data from the model to do whatever further query you need from the database.
RickMaddy is offline   Reply With Quote
Old 01-27-2009, 10:24 PM   #5 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 23
Default

Before the query I create an array. After the query I do

Code:
NSString *NameField = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
[myArray addObject:NameField];
I don't understand how I would go about adding another value to my array. I come from a web background and understand multidimensional arrays but I do not know the syntax to create one in Cocoa. That's why I asked if there was a way to setup the view picker like a select box on the web -- the label being different from the value.
SpyderDriver is offline   Reply With Quote
Old 01-27-2009, 10:27 PM   #6 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,122
Default

Two arrays would work or an array of dictionaries where each dictionary contains the label and key you need.
RickMaddy is offline   Reply With Quote
Old 01-27-2009, 10:32 PM   #7 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 23
Default

Thanks, I didn't realize that you could do an array of dictionaries.

I didn't really know the proper question to ask and I appreciate the help.
SpyderDriver is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,304
Threads: 89,032
Posts: 379,813
Top Poster: BrianSlick (7,086)
Welcome to our newest member, Azuresilver
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:35 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0