but for now, I was wondering if you could tell me what
Code:
if (ItemInputController == nil) {
was ment to do?
The original example code didn't have ItemInputController. It had itemInputController.
The convention for class names is They Always Start With Upper Case. The convention for variable names is they
never start with upper case.
So assuming this convention is being used by the example, what does this imply about the names? Two things:
1. ItemInputController is a class name.
2. itemInputController is a variable name.
So based solely on this information, what does it mean to compare a variable against nil in the conditional part of an
if statement? It means you're checking whether you already have an object assigned to that variable, and only executing the body of the
if when no object is assigned.
The body of the
if statement then goes on to do what? It allocs and inits an instance of the class (note case of name), and assigns it to the variable.
And what does this accomplish? If the variable doesn't hold an object it assigns a new object, and if it does hold an object it uses the one it has.
It should also be clear you will get a completely different meaning if you use the class name instead of a variable name in the conditional.
This should all be plain simply be reading the original code and mentally walking through it one line at a time. It shouldn't be difficult to perform this analysis, nor should it be difficult to infer which names are variables and which are classes. If either of those
are difficult, then you need to study the fundamentals again.
Cocoa Naming Conventions:
http://developer.apple.com/library/...eptual/CodingGuidelines/CodingGuidelines.html
You also need to work on basic accuracy in typing, or you need to use copy and paste more often. I've been called a clown before, but never on this forum. I took no offense; in fact, it made me grin.
As to what's acceptable, I think that depends on you. If you're confused by it, then you need to analyze and understand the code as given, then annotate it or revise it so it's not confusing to you. Since I'm not in your head, reading your thoughts, I can't tell you what's acceptable. You have to work that out yourself. I can assure you of this: you should learn what the conventions are, so you can read what others write. You should also understand what you read, even if you have to annotate it so you can understand it. If that means printing it on paper and marking it up with a red pen, then do that until you become proficient at reading code that follows the conventions. Simply copying and pasting code without understanding it gets you nowhere. You won't even be able to make it work without understanding what it's telling you.