• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableDictionary and retirieving data from web
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary and retirieving data from web


  • Subject: Re: NSMutableDictionary and retirieving data from web
  • From: Pandaa <email@hidden>
  • Date: Tue, 13 Apr 2004 09:35:34 +0200

Hi all,

I have a problems with filling my tableview with data from my
NSMutableDictionary object. The problem is I get hold of the data from
an url wich is tab seperated data stream. Is there any way to fill a
NSDictionary object with this data and give the key names to the data
fields?

If I understand what you want, something like this should work:

NSArray *keyArray = [[NSArray alloc] initWithObjects:@"programStart", @"programEnd", @"programChannel", @"programTitle", @"programDescription", @"programAlarm", nil];
NSString *data2 = [[NSString alloc] initWithContentsOfURL:[[NSURL alloc] initWithString:theUrl]];
NSArray *myArray = [[NSArray alloc] initWithArray:[data2 componentsSeparatedByString:@"\t"];
NSDictionary *rowData = [[NSDictionary alloc] initWithObjects:myArray forKeys:keyArray];
[channelData addObject:rowData];

Does that look about right?


Hi again :)

Your example works for only for a single "row" at a time, so made a loop and grabbed one "line" of my data at time and added it to the tableview datasource.

Now it works perfectly.

Thanks for the help!

Now, of course, for performance, you would never do something like [[NSArray alloc] initWithArray:[data2 componentsSeparatedByString:@"\t"], but that's really beside the point, sorry. ^^'

( Not to mention that if part of your data isn't textual, but rather a textual representation of numerical values, you would want to use NSScanner so you can avoid creating lots of temporary string objects. )

(( And if you have many rows - remember to cache method pointers for every method call you need to make on a per-row basis!! ))

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . earth water fire air software - the five elements . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. email@hidden . . www.synapticpulse.net .
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSMutableDictionary and retirieving data from web (From: Ibrahim Bulut <email@hidden>)
 >Re: NSMutableDictionary and retirieving data from web (From: Larry Fransson <email@hidden>)
 >Re: NSMutableDictionary and retirieving data from web (From: Ibrahim Bulut <email@hidden>)

  • Prev by Date: Re: User independent code
  • Next by Date: what is best for a "simple" (?) application to process word files ?
  • Previous by thread: Re: NSMutableDictionary and retirieving data from web
  • Next by thread: Re: NSMutableDictionary and retirieving data from web
  • Index(es):
    • Date
    • Thread