Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MadDoc

macrumors 6502
Original poster
Apr 25, 2005
329
5
UK
I am trying to learn Objective-C and Cocoa. I think I am making slow but steady progress :)

I was just wondering if anyone can explain in simple English the difference between NSMutable strings and NSStrings (i.e. immutable). I just don't understand the difference.

Sorry for such a simple question!

Thanks,

MadDoc,
 

HexMonkey

Administrator emeritus
Feb 5, 2004
2,240
504
New Zealand
Mutable strings can be modified after they've been created, immutable strings cannot. In other words, you can do things like add text to an NSMutableString object, or remove part of it, but you can't do these things to an NSString object without creating a new object.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
And immutable strings are generally more efficient in several ways, lest you be tempted to always use mutable strings. Try to always use NSStrings where you can and go mutable only when you really need to build up strings dynamically (although even here you often don't need to do this thanks to methods like -stringWithFormat:).
 

MadDoc

macrumors 6502
Original poster
Apr 25, 2005
329
5
UK
Thanks guys.

Having come from REALbasic - I am finding ObjC/Cocoa to have a steep learning curve but I think the effort will be worth it.

On the subject, are there any new resources for IB 3 out there yet?

MadDoc,
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.