4 ms·
I downmodded you because your response is snarky in addition to not being applicable. If you're new to Objective C and are used to a language like Ruby, where a
by nonrecursive 18y ago
I downmodded you because your response is snarky in addition to not being applicable. If you're new to Objective C and are used to a language like Ruby, where all strings are mutable, you wouldn't even realize it was necessary to use a class other than NSString to modify your strings.
- jemmons 18y agoIf you're expecting a different language, framework, and platform to behave like a ruby, I would argue no amount of eschewing documentation and getting down to coding will help you. In fact, I suggest documentation to be even more vital to you in this instance. As to my snark, I'm only faithfully transcribing how I figured out I was supposed to use an NSMutableString instead of an NSString. I was reading the documentation for NSString (and this was back in the NeXTStep days, so it was crap. Thanks Scott for making it a joy!) but I came across a line very similar to what's there now: "The mutable subclass of NSString is NSMutableString." "What on earth to they mean by mutable?" I thought. So I looked it up. And that's when it all made sense. Note that it is highly unlikely I would have figured this out by coding alone. Sifting object dumps of NSString or whatever would not have helped (unless I noticed -mutableCopy and was able to suss out what the NSMutableCopying protocol was all about) -- esp. coming from C where the expectation is there are no string conveniences and you have to roll it all yourself. Point being, its idiotic to say "Forget theory; ... Just set yourself a project and start working." Cocoa and, perhaps to an even greater extent, Cocoa Touch are hyper-complex frameworks that are made simple and understandable through the theory behind them. If you never learn the method to the madness -- all the patterns and best-practices behind Cocoa and why they're there -- all you will see is madness. You have very little hope of grokking iPhone development by "just doing it".
- wallflower 18y ago> If you're expecting a different language, framework, and platform to behave like a ruby, I would argue no amount of eschewing documentation and getting down to coding will help you. I actually learned this lesson the hard way in the past week and basically consult the iPhone SDK and Objective-C documentation constantly. Thanks. For example, looking at NSViewController's documentation for loadView, pointed out the fact that you should override this method if you want to do any intialization (like initialize instances of custom classes you need to handle controller interaction). And yes - I did spend some time looking without results at NSString object dumps before stumbling on the NSMutableString tip via google (and it would have been much faster to have read the NSString documentation)