• 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: [Newbie] Extracting a specific character number from a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Newbie] Extracting a specific character number from a string


  • Subject: Re: [Newbie] Extracting a specific character number from a string
  • From: "Kyle Sluder" <email@hidden>
  • Date: Wed, 6 Aug 2008 18:33:06 -0400

On Wed, Aug 6, 2008 at 6:23 PM, Phil Faber <email@hidden> wrote:
> NSLog(@"Character %i of %@ is %@",i,pass1,[pass1 substringWithRange:1,2]);

You need to pass an NSRange struct to -[NSString substringWithRange:].
 You can make one using the NSMakeRange() function.  If you didn't
know that function existed, you could always have just created one
manually:

NSRange range;
range.location = 1;
range.length = 1;

Also, be careful with NSString character-related functions, because
you get into very thorny issues with respect to "byte" versus
"character" versus "unichar" versus "Unicode code point".  String
slicing is not for the faint of heart (or for those unfamiliar with
surrogate pairs).

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >[Newbie] Extracting a specific character number from a string (From: Phil Faber <email@hidden>)

  • Prev by Date: Re: [Newbie] Extracting a specific character number from a string
  • Next by Date: Re: Dumb Q
  • Previous by thread: Re: [Newbie] Extracting a specific character number from a string
  • Next by thread: Command Line Argument - Choosing a Style
  • Index(es):
    • Date
    • Thread