Problems with retreiving objects from an array
Problems with retreiving objects from an array
- Subject: Problems with retreiving objects from an array
- From: Jesus De Meyer <email@hidden>
- Date: Fri, 19 Nov 2004 10:52:09 +0100
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