Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 4, 2011, 04:29 PM   #1
Blakeasd
macrumors 6502a
 
Join Date: Dec 2009
Add Text To End of NSString

How to I add text to the end of an NSString?
Thanks
Blakeasd is offline   0 Reply With Quote
Old May 4, 2011, 04:49 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
Quote:
Originally Posted by Blakeasd View Post
How to I add text to the end of an NSString?
Thanks
You don't, NSString is immutable.

there is stringByAppendingString: which will return a new, autoreleased NSString with the current value plus the NSString passed in, but if you need to be altering a string "in place" you need NSMutableString. It has an appendString: method.

-Lee
lee1210 is offline   0 Reply With Quote
Old May 4, 2011, 04:53 PM   #3
GFLPraxis
macrumors 604
 
GFLPraxis's Avatar
 
Join Date: Mar 2004
Quote:
Originally Posted by Blakeasd View Post
How to I add text to the end of an NSString?
Thanks
Create a new NSString with the new one added (either through stringByAppendingString or @"%@ blah blah",oldstring).

Or use NSMutableStrings.
GFLPraxis is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: How do I add a linear gradient on a text? h4mza Jailbreaks and iOS Hacks 0 Apr 25, 2013 11:13 AM
begin until end of selected text size nxcoder iPhone/iPad Programming 2 Dec 30, 2012 06:16 AM
Best way to add text labels to my view? jeanlain Mac Programming 2 Dec 16, 2012 03:00 AM
Need to add text to pics,but need it to..... studmule iPhone and iPod touch Apps 2 Dec 12, 2012 12:16 PM
Receiving long text messages end up out of order. gs7x iOS 6 0 Oct 30, 2012 07:15 PM

Forum Jump

All times are GMT -5. The time now is 04:55 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC