views:

40

answers:

1

I would like to know from people with experience where the best place to declare, initialize and release objects is.

Should all objects including NSStrings always be declared in the header file?

Are variables like an int declared in the header file?

If I declare an object or use an object in a method, should it be released in that method or in the dealloc method?

If an object is only needed in the method, should it just be declared and released within the method?

This is simple, but the header and implementation file style is new to me.

Regards

+2  A: 

It depends entirely on what you are trying to do. The documentation does a good job of covering much of what you are asking.

I would suggest reading the Objective-C conceptual guide and then rephrasing your questions to something more specific.

bbum
I have read it, I would like to hear different peoples opinions etc. a general question.
alJaree
I see nothing in your questions above that is subject to opinions. bbum is correct: you're just going to have to learn how it's done (and everything you asked is detailed in the conceptual materials).
Joshua Nozzi
And please don't take offense at my answer. I read and re-read that particular conceptual guide about a dozen times over the first 10 years I did Objective-C, learning something new each time. As well, the example code like Sketch and TextEdit are tremendously educational to consume, too.
bbum
No none taken :)stackoverflow is a great site. Much friendlier users than e.g. Java forums at oracle. :PI will read it again then. thank you.
alJaree