• 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/NSMutable String Concatenation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString/NSMutable String Concatenation


  • Subject: Re: NSString/NSMutable String Concatenation
  • From: Jason Coco <email@hidden>
  • Date: Wed, 3 Sep 2008 22:53:50 -0400


On Sep 3, 2008, at 17:57 , Michael Stearne wrote:

Hi.

I'm new to OS X development and Objective C. I have a NSString (or
NSMutableString if that is wiser) and I would like to add text on to the end
of it.


In PHP it would be something like:
$myString=$myString." more stuff";

I have looked around for docs on this but they are confusing (based on my
newbie status and background).


If there a simple equivalent of the code above for Objective C?

You can use the -(NSString *)stringByAppendingString: (NSString*)theString method:


NSString myNewString = [myOldString stringByAppendingString:@" more stuff"];

Don't forget to retain myNewString if you want it to stick around for a while. You could also do:

myString = [myString stringByAppendingString:@" more stuff"];

but if myString wasn't created by a string constant @"..." you will obviously be leaking (unless the original myString was
also autoreleased already).

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

_______________________________________________

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: 
 >NSString/NSMutable String Concatenation (From: "Michael Stearne" <email@hidden>)

  • Prev by Date: Re: Font Color In CTLineDraw?
  • Next by Date: Re: process monitoring panic
  • Previous by thread: Re: NSString/NSMutable String Concatenation
  • Next by thread: NSMatrix mouse puzzle
  • Index(es):
    • Date
    • Thread