• 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: Adding spaces to an NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding spaces to an NSString


  • Subject: Re: Adding spaces to an NSString
  • From: Matt Long <email@hidden>
  • Date: Tue, 18 Mar 2008 20:28:29 -0600

You could get a char array from your initial NSString and then use stringByAppendingFormat:@"%c " on an NSString in a loop. Notice the space after the %c.

-Matt



J. Todd Slack wrote:
Hi John,

Yes, I have, Are you thinking insertString:atIndex:?

So at a basic level, can I get the string length, for loop through each
character and after each use insertString to add a space?


I am just looking for the most efficient way, sometimes I suffer from doing
things multiple ways, trying to find the most succinct and efficient versus
just making it work and optimizing later..


Jason


On 3/18/08 5:46 PM, "John Stiles" <email@hidden> wrote:


Have you looked at NSMutableString? The APIs are pretty basic here.
I'd recommend working from right-to-left; you'll find it probably makes
the logic simpler.


J. Todd Slack wrote:

Hello All,

I am a little stumped today, not sure why, but how would I add a space after
every character in an NSString and produce a new NSString from it.


So I have something like: (ignore the quotes, I just did it for containment
sake..)


³/Users/slack/Music²

And I want it to be:

³/ U s e r s / s l a c k / M u s i c ³

Would anyone have any thoughts?

Thanks!
-Jason

_______________________________________________

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: 
 >Re: Adding spaces to an NSString (From: "J. Todd Slack" <email@hidden>)
 >Re: Adding spaces to an NSString (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Confused about CFRunLoop
  • Next by Date: Re: [Solved]NSAppleScript returning wrong error info
  • Previous by thread: Re: Adding spaces to an NSString
  • Next by thread: Re: Adding spaces to an NSString
  • Index(es):
    • Date
    • Thread