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 08-23-2009, 04:46 PM   #1 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
Post store value in three dimensional NSMutableArrary

Hi all:
I am just clearifying my previous post. I have 5 different mutable arrays that I am using to store my information that I use as rgb numbers. I also have 3 sliders (red, green, blue). I then update all of the ui controls with the new colour. The problem that I have is I do not know how to store/get values from the different arrays. Lastly, I also need to be able to save and load the arrays by using NSUserDefaults.

Thank you all for any advice or suggestions
losingSkillz is offline   Reply With Quote
Old 08-23-2009, 05:26 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 253
Default

not is better use nsdictionary? an access the key for get and set?
gunther is offline   Reply With Quote
Old 08-23-2009, 10:04 PM   #3 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
Post

Quote:
Originally Posted by gunther View Post
not is better use nsdictionary? an access the key for get and set?
can u provide any sample code because i am not familiar with nsdictionary? thank you very much.
losingSkillz is offline   Reply With Quote
Old 08-24-2009, 09:08 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 253
Default

for set
Code:
advertiset = [[[NSMutableDictionary alloc]init]autorelease];
		[advertiset setObject:currentAdvertise.ciudad forKey:@"ciudad"];
where current.Advertise.ciudad is for example a nsstring

for get
Code:
lblciudad.text = [advertiset objectForKey:@"ciudad"];
gunther is offline   Reply With Quote
Old 08-24-2009, 09:43 AM   #5 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
Post

Quote:
Originally Posted by gunther View Post
for set
Code:
advertiset = [[[NSMutableDictionary alloc]init]autorelease];
		[advertiset setObject:currentAdvertise.ciudad forKey:@"ciudad"];
where current.Advertise.ciudad is for example a nsstring

for get
Code:
lblciudad.text = [advertiset objectForKey:@"ciudad"];
thanks for reply. but doesn't that require a seperate class? also, want to be able to store the rgb colours in the array. thank you again.
losingSkillz is offline   Reply With Quote
Old 08-24-2009, 10:23 AM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 253
Default

you can make the dictionary in a separatte class..for example Mydic and in MyDic you make the NSdictionary for set and get the rgb..

But i think what if you call this for others views you can make a plist and set and get this values more easy. and the advantage is what you can use the same data in all views..

Only need what make a class for sharing the code read a write plist and import to the view controller.
gunther is offline   Reply With Quote
Old 08-24-2009, 02:53 PM   #7 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
Default

Quote:
Originally Posted by gunther View Post
you can make the dictionary in a separatte class..for example Mydic and in MyDic you make the NSdictionary for set and get the rgb..

But i think what if you call this for others views you can make a plist and set and get this values more easy. and the advantage is what you can use the same data in all views..

Only need what make a class for sharing the code read a write plist and import to the view controller.
thanks for all the help. but i still have some other questions.
1:is there anyway to set the colour of the font of a button programmatically using [UIColour colourWithRed:redValue green:greenValue blue:blueValue];?
i know you can do this with a label but does it work for buttons too?

2:for the NSMutableDictionary, is it possible to have more than one object for one key? for example can you use something like this?:

Code:
[dictLabelFont setObject:[NSString stringWithFormat:@"%d", intRedColour] forKey:@"red"];
[dictLabelFont setObject:[NSString stringWithFormat:@"%d", intGreenColour] forKey:@"green"];
[dictLabelFont setObject:[NSString stringWithFormat:@"%d", intGreenColour] forKey:@"blue"];
actually for the second question i meant to say can you can store more than one object/key in a NSMutalbeDictionary right?
thanks for all of your help :-)

Last edited by losingSkillz; 08-24-2009 at 02:58 PM. Reason: wrong code
losingSkillz is offline   Reply With Quote
Old 08-24-2009, 03:04 PM   #8 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 253
Default

Ok

1. I dont have idea.. lol

2. yes its posible..ypur code that fine
gunther is offline   Reply With Quote
Old 08-25-2009, 01:47 PM   #9 (permalink)
iPhone Developer
 
Join Date: Aug 2009
Posts: 64
Post

Quote:
Originally Posted by gunther View Post
Ok

1. I dont have idea.. lol

2. yes its posible..ypur code that fine
thanks anyway :-)
losingSkillz is offline   Reply With Quote
Old 08-25-2009, 02:02 PM   #10 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
Default

Quote:
Originally Posted by losingSkillz View Post
1:is there anyway to set the colour of the font of a button programmatically using [UIColour colourWithRed:redValue green:greenValue blue:blueValue];?
i know you can do this with a label but does it work for buttons too?
UIButton setTitleColor:forState:

Quote:
2:for the NSMutableDictionary, is it possible to have more than one object for one key? for example can you use something like this?:

Code:
[dictLabelFont setObject:[NSString stringWithFormat:@"%d", intRedColour] forKey:@"red"];
[dictLabelFont setObject:[NSString stringWithFormat:@"%d", intGreenColour] forKey:@"green"];
[dictLabelFont setObject:[NSString stringWithFormat:@"%d", intGreenColour] forKey:@"blue"];
actually for the second question i meant to say can you can store more than one object/key in a NSMutalbeDictionary right?
thanks for all of your help :-)
yes, you can store any number of objects/keys in a NSMutableDictionary.

btw, if you want to store float values in a dictionary, you might consider using NSNumber numberWithFloat: instead of converting to/from strings all the time.
jsd is offline   Reply With Quote
Reply

Bookmarks

Tags
array, nsmutablearray, nsuserdefault, rgb, uislider

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
» Online Users: 231
15 members and 216 guests
ADY, AragornSG, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, Promo Dispenser, Punkjumper, Rudy, sacha1996, sneaky, spiderguy84, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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