Re: Enumerator and
Re: Enumerator and
- Subject: Re: Enumerator and
- From: Ondra Cada <email@hidden>
- Date: Tue, 9 Apr 2002 18:03:53 +0200
On Tuesday, April 9, 2002, at 05:40 , Onar Vikingstad wrote:
I'm trying to do something that's seeminly easy:
It's even considerably easier than you presumed ;)
to "convert" an array (records) into a special formatted string (I chose
to use enumerator and while function to have full control). But I keep
getting run errors when this action (doit) is executed:
- (IBAction)doit:(id)sender
{
NSEnumerator* enumerator = [records objectEnumerator];
NSMutableString *tempString = [NSMutableString stringWithCapacity:4];
id tempObject,index;
while ( (index = [enumerator nextObject]) ) {
tempObject = [records objectAtIndex:[index intValue]];
[tempString appendString:[[records objectAtIndex:[index intValue]]
componentsJoinedByString:@":"]];
}
...since enumerator returns array objects, not indices. You wanted
id o;
while (o=[en nextObject])
[tempString appendString:[o description]];
or something like that. I regret to say that I can't make sense of the part
appendString:[... componentsJoinedByString:@":"]
which would make sense only if your array (records) contained nested
arrays, whilst it seems to contain some dictionaries (since
"[NSCFDictionary intValue]: selector not recognized").
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.