• 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: Cocoa-dev Digest, Vol 1, Issue 303
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Cocoa-dev Digest, Vol 1, Issue 303
      • From: Karin Kosina <email@hidden>
  • Prev by Date: Re: Fastest way to push strings to the screen in an NSView?
  • Next by Date: Sorting Attributed Strings w/Bindings
  • Previous by thread: Re: Potential trick for adding instance variables to classes using poseAs
  • Next by thread: Re: Cocoa-dev Digest, Vol 1, Issue 303
  • Index(es):
    • Date
    • Thread