What do you find confusing about the C part of Objective-C?
As I'm preparing for the class I'm teaching with Daniel, I keep thinking about all the C stuff that I see people struggling with. I'd love to be able to do a mind meld and transfer a grok of C, but unfortunately it doesn't work that way.
And besides you don't really have to know C to be a competent iOS/Mac developer. For the most part you work in objects from UIKit, AppKit and Foundation. Only every once in a while do the quirks of C come up.
For example, you have to pass an NSError ** to methods that return an error. You don't really have to understand that C is "pass by copy" to use the pattern:
NSError *err = nil; NSString *stuff = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
You must pass the address of err to change the value of err in the current scope. You can build and deliver apps not understanding why. You just do what works and go on with solving real problems. After all we have to stay calm and ship apps.
But if you are like me, you can only do that for so long before it starts to make you nuts that you don't really understand it!
In the current edition of our book Chris does a great job of going over the stuff you need to know about C to become a proficient iOS developer. But iOS proficiency is the goal. We did not have the space to dig into the details of how pointers work or what "pass by copy" really means.
Which brings me to the point of this post. What do you find confusing or not understand with the C part of Objective-C?
Here is a list of topics I know I want to address:
- function call semantics
- extended types, struct, typedef, enum and #define
- ObjC Strings with @"" vs C Strings with ""
- dynamic memory & malloc/free
- Core Foundation
Some of those items are abstractions of real world problems I've seen people struggle with, but I'm sure there are lots of others. Please send me an email with what you've struggled with and I'll do my best to address that as well.