Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
and this is how I have implemented it in my file, note I have changed item to Item because i named by subclass stuff with a small i.
I think you're early enough on in this process to scrap your poorly-named class and create a new one that follows the naming-convention you desire.

Code:
- (void)addItem:sender {
    if (ItemInputController == nil) {
        itemInputController *ItemInputController = [[itemInputController alloc] init];
    }
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:ItemInputController];
    [[self navigationController] presentModalViewController:navigationController animated:YES];
    [navigationController release];
}

So I think thats pretty close, I think Im on the right track but I have 1 error and 1 warning still. on this line I have an error "ItemInputController undecleared" could you please help me understand how i am meant to declare it.
If you declare your ItemInputController inside the if, what scope do you think it will have outside the if?
 
I think you're early enough on in this process to scrap your poorly-named class and create a new one that follows the naming-convention you desire.

Too true... I gotta stop having these lazy lapses...

If you declare your ItemInputController inside the if, what scope do you think it will have outside the if?


if there was a head in hands smile I would use it right now... its just I feel abit overwhelmed and overlook these things cause I give up too early, thank you for pointing that out for me.. will have ago at it now.
 
So I think thats pretty close, I think Im on the right track but I have 1 error and 1 warning still. on this line I have an error "ItemInputController undecleared" could you please help me understand how i am meant to declare it.
Code:
 if ([COLOR="Blue"]ItemInputController == nil[/COLOR]) {

and then I have a warning on this line of code saying "unused variable ItemInputController"
Code:
itemInputController *ItemInputController = [[itemInputController alloc] init];

Pay closer attention to the case of names: ItemInputController and itemInputController have different case, so are different things.

If you get confused by case, then pick more notable variable names, as distinct from the class name. Then be very sure which one you intend to use. For example, if ItemInputController is the name of a class, what does the blue-hilited expression mean? If you don't know, or you intended to refer to the variable rather than the class, then I've made my point: you will benefit from having a naming convention that doesn't confuse you.

You could easily have a naming convention where every variable and class name was just a change in the case of the different letters in the word "variable". They would all be different: Variable, VAriable, VariablE, VArIable, etc. No sane person would do this intentionally. So do something that you will notice, and stop doing things that confuse you.
 
So I took
Code:
ItemInputController *itemInputController = [[ItemInputController alloc] init];

out of the if statement, I understand why I had to do it as you outlined, and it worked.. a new window pops up from the bottom of the screen.. nothing is in it yet, I guess I will populate it with a NSMutableArray of stuff that I can choose from. but for now, I was wondering if you could tell me what
Code:
if (ItemInputController == nil) {
was ment to do?
Is it just asking if there is a object of ItemInputController instantiated? or something else.

Here is my new addItem method.
Code:
- (void)addItem:sender {
	ItemInputController *itemInputController = [[ItemInputController alloc] init];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:itemInputController];
    [[self navigationController] presentModalViewController:navigationController animated:YES];
    [navigationController release];
}
 
@Clown33

Yep I understand what your saying. However do you think in this situation when your creating an instance of a Class its acceptable? I only ask this as it seems to be the norm in alot of the books I have been reading and is even done on the apple developer guides, where objects tend to user the object type before the name for instance textName, lableName and buttonName and when working with classes they just choose to change the case.
 
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.
 
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.


okay before I finish reading the rest of your post, I swear on my fathers grave I thought I saw your name as Clown... It might be the fact that where my mac is I'm dealing from a great deal of reflection on the screen in the morning!!

God, when I read this I gasped! Honestly.. It was not something I did on purpose.. now back to reading. :eek:
 
okay before I finish reading the rest of your post, I swear on my fathers grave I thought I saw your name as Clown... It might be the fact that where my mac is I'm dealing from a great deal of reflection on the screen in the morning!!
That sounds bad. Not just in a theoretical sense, but in a down-to-earth practical sense. If you can't see your screen accurately, that's at least as big a problem as anything having to do with naming conventions or what books to read.

God, when I read this I gasped! Honestly.. It was not something I did on purpose.. now back to reading. :eek:

Relax! Now you're making me laugh. It looked like an honest mistake, and now it's getting to be hilarious. Overreaction to minor foibles is one of the classic sources of comedy!
 
:) sorry.. again. To be honest forums in general can be tough places to get into and be taken seriously. especially when your new to programming or just beginning a new language, me being part of the later group.

I just want to make sure people know I'm not taking the piss and that I am really wanting to learn to better myself, and hopefully one day get to the point where I can just sit down and make usable apps that I and other people will hopefully enjoy.

I don't generally say this to people I don't know but I have a semi learning disability in the fact that my memory has been effected by a brain tumor that I had to have operated on about 4 years ago. Since then I went to uni and graduated in Computer Science and am now just looking to develop my current skill base. I wouldn't say programming comes naturally to me, everything I have to do I have to work at to understand... but thats okay because I don't mind hard work.

I'll take your comments on board and figure out a better way of understanding things I don't.. I already have one idea that I have to implement and thats just getting a book I can write in. I tend to have to write things down while I read them for information to get far enough into my memory to stick :p for some reason (possibly the brain tumor) I have trouble only reading things to remember.. I find it really hard and will often find myself going over the same line of code five or six times till the point where I loose myself.. I have noticed writing things down while I read helps.. so I will do that.

Again thanks for taking the time to off your opinions and help its honestly greatly appreciated.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.