Why are Objective-C instance variables declared in an interface?

Posted by Chase on Stack Overflow See other posts from Stack Overflow or by Chase
Published on 2010-06-14T20:50:24Z Indexed on 2010/06/14 20:52 UTC
Read the original article Hit count: 147

Filed under:

I'm just getting into Objective-C (Java is my primary OO language).

Defining an object's instance variables in the interface instead of the class seems strange. I'm used to an interface being a public API definition with nothing besides method signatures (not counting constants here).

Is there some reason that state is defined in an interface (even if it is private) and behaviour is defined in a class. It just seems odd that since objects are state+behavior that the definition would be split into two separate places.

Is it a design benefit is some way? A pain in the rear issue that you are just forced to deal with in Objective-C? A non-issue, just different? Any background on why it's done this way?

Or can you put object state in a class and I just haven't hit that part in my book yet?

© Stack Overflow or respective owner

Related posts about objective-c