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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-10-2010, 11:11 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Location: Paris
Posts: 26
albh is on a distinguished road
Default Dynamic name of ns mutable dictionary

Hi everyone

I load from a txt file many info, and I would like, if possible, to dynamically create NSmutable dictionary with the elements of the txt.

For example, each is like that:
id of element | date | text

What I'm asking is the equivalent of the NSString stringWithFormat:.
Can we do the same for an Mutable Dictionary?

To be more practical, let's say the NSString *date is equal to "23/12/2009" (for europe). I want to create a dictionary called 23/12/2009 without declaring *23/12/2009 but just something like dictionaryWithFormat: @"%@", date];

I'm stuck on this, and I don't even know if it is possible. If not, what's the best way to approach that?

Thanks everyone

Regards
albh is offline   Reply With Quote
Old 05-10-2010, 11:30 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

What's the point of dynamically naming your variables?
smithdale87 is offline   Reply With Quote
Old 05-11-2010, 02:44 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Location: Paris
Posts: 26
albh is on a distinguished road
Default

It's to automatically create table view with headers and rows easily
albh is offline   Reply With Quote
Old 04-14-2011, 10:44 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
TeenVoice is on a distinguished road
Default Did You Get an Answer to Your Question?

I also want to change the name of cells in my NSMutable array dictionary without having to send a change to the App Store every time.

Were you ever able to do that?
TeenVoice is offline   Reply With Quote
Old 04-14-2011, 11:04 AM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

you can download from web an xml with your informations.

So that you can parse it and update your arrays that represent the name of the cell and the other things.
__________________
dany_dev is offline   Reply With Quote
Old 04-14-2011, 12:01 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
TeenVoice is on a distinguished road
Smile XML download to update array

Quote:
Originally Posted by dany_dev View Post
you can download from web an xml with your informations.

So that you can parse it and update your arrays that represent the name of the cell and the other things.
***

Thank you. Can you send me a sample script of how to do that? I need to replace the "Revolution in Libya" name with a link to the XML file.

[topArea addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:
@"Revolution in Libya",@"name",
@"hottopic.png",@"picture",
@"http://www.WHERE THE LINK FILE IS LOCATED",@"url",nil]];
TeenVoice is offline   Reply With Quote
Old 04-14-2011, 02:30 PM   #7 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

first thing you don't need a "script" because objective-c is not a scripting language.

however i have no ready code for you.

google NSURLConnection or ASIHTTPRequest to understand how you can download a file xml, then google NSXMLParser to understand how you can parse a file xml.......then should be trivial to create objects dinamically.
__________________
dany_dev is offline   Reply With Quote
Old 04-14-2011, 03:43 PM   #8 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by albh View Post
Hi everyone

I load from a txt file many info, and I would like, if possible, to dynamically create NSmutable dictionary with the elements of the txt.

For example, each is like that:
id of element | date | text

What I'm asking is the equivalent of the NSString stringWithFormat:.
Can we do the same for an Mutable Dictionary?

To be more practical, let's say the NSString *date is equal to "23/12/2009" (for europe). I want to create a dictionary called 23/12/2009 without declaring *23/12/2009 but just something like dictionaryWithFormat: @"%@", date];

I'm stuck on this, and I don't even know if it is possible. If not, what's the best way to approach that?

Thanks everyone

Regards


Sounds to me like you should use a single dictionary to store all of your records.

A dictionary stores key/value pairs. The key is almost always a string. The value is any object.

So you could use either the date or the id of the item as the key, and save the data as the value.

I don't quite understand what you're trying to do, though.

Don't describe creating a dictionary, because I think you misunderstand how to use dictionaries. Instead, describe the type of information you want to store, and how you want to retrieve it. e.g. I want to create a database of records using an ID number as a key. Each record would contain a date and a text string.

If you want to be able to look up these records using multiple keys the problem is more complicated. (If you want to be able to find items by ID number or by date, for example). In that case you might want to create an SQL database.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Reply

Bookmarks

Tags
dictionary, dynamic, iphone

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: 322
14 members and 308 guests
Abidullah, baja_yu, cgokey, Duncan C, Fstuff, gbenna, guusleijsten, jbro, mdpauley, n00b, newDev, Sami Gh, seokwon lee, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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