• 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: Is this a bug of the Cocoa or the Objective-C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this a bug of the Cocoa or the Objective-C?


  • Subject: Re: Is this a bug of the Cocoa or the Objective-C?
  • From: Nir Soffer <email@hidden>
  • Date: Fri, 26 Jan 2007 17:01:51 +0200


On Jan 26, 2007, at 06:58, JongAm Park wrote:

while( item = [objectsEnumerator nextObject] ) {

   keyString = [item valueForKeyPath:@"CF_EncodingName"];

if (keyString == nil) continue;


theRange = [keyString rangeOfString:searchString options:NSLiteralSearch];


   if( theRange.location != NSNotFound ){
	[filteredObjects addObject:item];
    }
}


Let's assume that theRange has {0, 6} in the previous iteration.
if the keyString is "nil", the rangeOfString.. method returns nil.
However, it can't update the theRange variable, so it thinks that it found
the searchString.


Is this inevitable bug, because the Objective-C is a dynamic language?
Or.. is it just a bug in the Cocoa?

It is a bug in your code :-)

You can (and should) detect the situation when there is no keyString, and not relay on the value returned from calling messages to nil.


Best Regards,

Nir Soffer

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Is this a bug of the Cocoa or the Objective-C? (From: JongAm Park <email@hidden>)

  • Prev by Date: local mail framework?
  • Next by Date: NSComboBoxCell exceptioning, sometimes on reloadData?
  • Previous by thread: Re: Is this a bug of the Cocoa or the Objective-C?
  • Next by thread: Color Table Animation
  • Index(es):
    • Date
    • Thread