• 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: NSString searching for zero
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString searching for zero


  • Subject: Re: NSString searching for zero
  • From: Claudius Sailer <email@hidden>
  • Date: Sun, 22 Sep 2002 15:52:49 +0200

Am Sonntag, 22.09.02 um 15:19 Uhr schrieb Andreas Mayer:

and this seems a little bit stupid:

if (([text characterAtIndex:0] == 0) && ([text characterAtIndex:1] == 0) && ([text characterAtIndex:2] == 0) && ([text characterAtIndex:3] == 0))

What about

[text isEqualToString:@"\0\0\0\0"]; // see 'man printf' for more escape codes

This doesn't work


This will most likely not work for values > 127 though, since those could be encoded using more than one byte (unicode).

If you are handling non-character data, it may be better to use NSData instead of NSString.
Or you could use regular C strings and functions for processing arbitrary data and move to Cocoa classes only when actually working with text (not byte streams).

but you gave me the hint

([text cStringLength] == 0)

works :-))

Thanks


Claudius
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSString searching for zero (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: NSString searching for zero
  • Next by Date: Re: sheet comes unglued from its window
  • Previous by thread: Re: NSString searching for zero
  • Next by thread: Re: NSString searching for zero
  • Index(es):
    • Date
    • Thread