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


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

The example variable of the object in the interface instead of the defined class looks strange. I am used as a public API definition for an interface, which is nothing other than the method signature (here the constraint is not counted).

Is there any reason that the state is defined in the interface (even if it is private) and behavior is defined in a class. It just sounds weird because things are state + the definition of behavior will be divided into two different places.

Is there any kind of design benefit? Is there a pain in the rear issue that you are forced to deal with only objective-C? A non-issue, just different?

Can you put something in a square and I have not yet killed that part in my book?

UPDATE

implement the answer given below In the example variable was declared written before the language attribute was declared. The basis of the question is no longer valid as it is said, nothing should be done in @interface that you do not want to be public.


It is a hangover with the fact that a very thin layer of C-made on the top of C is produced as a purpose-C, an interface is made in a module (a Java < Do not confuse with Code> Interface ) Define in a header file and to be really included in each compilation unit. It's like copy-pasting announcements automatically at the top of every compiled file. If it seems primitive, that's because it is, but C is a 40-year old language.

You have to define private characters in the interface - for example - Object-Objects are implemented as C Structures which are themselves blocks memory and offset within those blocks are named . The structure that displays an object of each class is to include a location for a super-class instance variable, so the subclass should have at least the size of the straight representation of the superclass and the public and protected example variable offset address . Unfortunately, this means that all the example variables should also highlight the private people as part of the external interface. The other oo version of C ++ suffers from the same problem for the same reason.

It is a pain of writing two signatures in two ways, but you use it.

* With 64 bit runtime, you no longer need to declare Ivor for synthesized accessories; Despite the public in all ways, it still does not have to be The world is meant to highlight the internal condition, but it reduces the problem.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -