Hi everyone, I am pretty new to objective-c, and I've been going over some stuff in a book I bought, and there is just something that is really bothering me. I can't really ask the author a question about his paragraph, so I thought I'd write here instead.
So--- This has to do with arrays, dictionaries and strings. What I don't get is... why is there NSMutableString and NSString? #1. It seems weird to me that a string object can't be modified once it's created. Why is this? #2. It seems weird that there is an alternative "mutable" object that can be modified. If this is the more convenient way to go, why would anyone use a regular NSString? Why not always just use mutable? In that case, why does the language even have a plain old NSString? Isn't it kind of redundant to have the same sort of thing but less-functional? #3. For mutable objects, there is "WithCapacity".. this is where the author completely lost me. So he's saying that these mutable things like NSMutableArray for example can be set to have a capacity by using [NSMutableArray arrayWithCapacity: x] ... Ok.. so, if the whole point of having a mutable object is that it has the ability to be changed-- Why would you want to specify a capacity? If you know the capacity why would you be using NSMutableArray? Why wouldn't you just use NSArray? Ontop of all this, the author says that the capacity isn't a "limit", it's ok if you go over it--- That really made me lose it. So--- Why in the world would you bother setting a capacity for a container object that MIGHT have more objects than the number you specify??? It just seems like this stuff is so weird and unnecessary and illogical... So, I would love it if someone can please explain this to me. I come from scripting languages where it's very easy to just define stuff and use it, add to it, remove from it, etc.. So it's really a struggle for me to see something that seems so fundamental to be so challenging to accomplish. Thank you! Patrick J. Collins http://collinatorstudios.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com