• 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: Question about an NSScanner loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about an NSScanner loop


  • Subject: Re: Question about an NSScanner loop
  • From: j o a r <email@hidden>
  • Date: Wed, 12 Jan 2005 23:16:25 +0100


On 2005-01-12, at 22.48, Matt Crocker wrote:

NSScanner *cellScanner = [NSScanner scannerWithString:[inputString substringWithRange:NSMakeRange(inputIndex, [inputString length]-inputIndex)]];

cellScanner is an autoreleased object...

[cellScanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@",\n"] intoString:&cellString];

Should you not check the return value? Add a check to see that this returns YES!


[cellScanner release];

...you release the autorelease object. This is a memory management error, and would have crashed, had you not been in your never ending loop...


After you've found something by using "scanUpToString...", you need to scan *past* that point in the string by using "scanString...", or else you'll get "stuck". This is probably the reason why the loop never ends.

Let's start with these things - return to the list if you don't find the problem with why the loop never ends.

j o a r

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >Question about an NSScanner loop (From: Matt Crocker <email@hidden>)

  • Prev by Date: Re: Cocoa/Objective-C's Relative Performance
  • Next by Date: IB, multiple table views, and view resizing
  • Previous by thread: Question about an NSScanner loop
  • Next by thread: NSTask
  • Index(es):
    • Date
    • Thread