Re: Cocoa-dev Digest, Vol 1, Issue 303
Re: Cocoa-dev Digest, Vol 1, Issue 303
- Subject: Re: Cocoa-dev Digest, Vol 1, Issue 303
- From: Lorenzo <email@hidden>
- Date: Fri, 19 Nov 2004 15:01:41 +0100
Hi,
I can tell you that, for the same purpose, I use NSMutableDictionary*
I set the key with the codeIndex string and the object with the real string.
And it works well and fast all the time.
Best Regards
--
Lorenzo
email: email@hidden
> From: email@hidden
> Reply-To: email@hidden
> Date: Fri, 19 Nov 2004 05:48:03 -0800 (PST)
> To: email@hidden
> Subject: Cocoa-dev Digest, Vol 1, Issue 303
>
> Message: 1
> Date: Fri, 19 Nov 2004 10:52:09 +0100
> From: Jesus De Meyer <email@hidden>
> Subject: Problems with retreiving objects from an array
> To: cocoadev List <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> I'm currently creating a project where I use 2 arrays. One array
> contains single character strings which define symbols and/or
> characters with accents. The second array represents the codes for the
> elements in the first array.
>
> Now, when I select a text file I go through its contents and check if
> the file contains a character from the first array. If I find a
> character, I check its index and use that index to retrieve the code
> from the second array.
>
> My problem is with the index. It seems the index simply doesn't get
> found. I assume this is because I'm not setting the encoding correctly
> of the string that was found.
>
> This is what currently have:
>
> while (![scanner isAtEnd]) {
> if ([scanner scanUpToCharactersFromSet:charSet intoString:NULL]) {
> if ([scanner scanLocation] < (unsigned)length) {
> NSString *foundChar = [NSString stringWithFormat:@"%C", [txt
> characterAtIndex:[scanner scanLocation]]];
> int codeIndex = [charsList indexOfObject:foundChar]; //not set
>
> NSLog(@"Character found: %@ @ %d", foundChar, [scanner
> scanLocation]);
>
> [txt replaceCharactersInRange:NSMakeRange([scanner scanLocation], 1)
> withString:[codesList objectAtIndex:codeIndex]];
>
> [scanner setScanLocation:[scanner scanLocation]+1]; //continue
> searching
> }
> }
>
> [statusIndicator incrementBy:[scanner scanLocation]];
> }
>
>
> Thanks in advance,
>
> Jesus
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden