I'm in the midst of trying (again) to learn Cocoa and Objective-C on the Mac. I've hired a programmer to write my first iPhone app, mainly because I want to get it out into the wild before my idea's time has come and gone. I don't have a lifetime to learn to program it myself. One of the side benefits, of course, is that when it's all said and done, I'll have all of the source code for a commercially-viable iPhone app at my disposal to dissect and study.
Until then, though, I'm doing it the hard (and much cheaper) way: I'm re-reading all of my Cocoa and Objective-C reference books. It has become apparent to me as I go through all of this stuff again that what I find difficult is the system CocObjC uses to declare variables. I understand the model-view-controller paradigm, the messaging paradigm, object-oriented programming concepts, etc. But I cannot for the life of me follow something like
NSColor *color = graphic.color;
CGFloat xLoc = graphic.xLoc;
BOOL hidden = graphic.hidden;
int textCharacterLength = graphic.text.length;
(For what it's worth, these statements were copied verbatim from page 20 of Apple's The Objective-C 2.0 Programming Language.) I'm not worried about the stuff on the right side of the statement; I'm concerned with what's on the left side. And I sort of understand some of what's on the left: I savvy that hidden is the name of a variable that holds a boolean (yes/no or on/off or 0/1) value whose type is BOOL. I savvy that textCharacterLength is the name of a variable that holds a numerical value of type INT.
I do NOT savvy what xLoc is. I suspect that it is the name of a variable that holds a floating-point value, but I don't know why it's of type CGFloat.
I particularly do NOT savvy what *color is. Why the asterisk? What's special about it? Why do some variables have asterisks and some do not? How do you know when to use it? Apple just assumes the reader knows the difference; I suspect that somewhere, buried in Apple's developer documentation library, there's an explanation for this, but I haven't stumbled across it yet.
Until then, though, I'm doing it the hard (and much cheaper) way: I'm re-reading all of my Cocoa and Objective-C reference books. It has become apparent to me as I go through all of this stuff again that what I find difficult is the system CocObjC uses to declare variables. I understand the model-view-controller paradigm, the messaging paradigm, object-oriented programming concepts, etc. But I cannot for the life of me follow something like
NSColor *color = graphic.color;
CGFloat xLoc = graphic.xLoc;
BOOL hidden = graphic.hidden;
int textCharacterLength = graphic.text.length;
(For what it's worth, these statements were copied verbatim from page 20 of Apple's The Objective-C 2.0 Programming Language.) I'm not worried about the stuff on the right side of the statement; I'm concerned with what's on the left side. And I sort of understand some of what's on the left: I savvy that hidden is the name of a variable that holds a boolean (yes/no or on/off or 0/1) value whose type is BOOL. I savvy that textCharacterLength is the name of a variable that holds a numerical value of type INT.
I do NOT savvy what xLoc is. I suspect that it is the name of a variable that holds a floating-point value, but I don't know why it's of type CGFloat.
I particularly do NOT savvy what *color is. Why the asterisk? What's special about it? Why do some variables have asterisks and some do not? How do you know when to use it? Apple just assumes the reader knows the difference; I suspect that somewhere, buried in Apple's developer documentation library, there's an explanation for this, but I haven't stumbled across it yet.