Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Using NSMutableString

Using NSMutableString
Thread Tools
Dedicated MacNNer
Join Date: Jan 2001
Location: Computer Error: Unknown
Status: Offline
Reply With Quote
May 25, 2001, 07:32 PM
 
I can't figure out how to use an NSMutableString. I want it to have a float value and then some text after it in the string. I am declaring it with

NSMutableString totalStr;

but PB just comes up with an error

"totalStr cannot be statically allocated
statically allocated objects are not supported."

After I get it set up, how would I append a float value and then text to it?

Thanks in advance.
"...Because the people who are crazy enough to think they can change the world,
are the ones who do."
-To the Crazy Ones

     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 25, 2001, 10:11 PM
 
Everything in Cocoa is a pointer.

So you'd do something like:

NSMutableString *myStr = [[NSMutableString alloc] init]; (which is the generic format for all objects.)

Then you can use appendFormat: to append stuff in printf-style format:

i.e.

[myStr appendFormat:@"Mooof! %f %@", myFloat, myNSNormalOrMutableString];
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2