Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
RE: [Q] omissible method declaration in interface file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Q] omissible method declaration in interface file



Thank you for your detailed explanation.

Well... isn't it be controlled by @private, @protected, and @public?

No. @private, @protected, and @public apply only to instance variables and not instance methods. As a practical matter, @private, @protected, and @public cannot be enforced even for instance variables at run-time because an instance can always be treated as a C struct via @defs(class_name) and the variables can be accessed using simple C structure dereference.



Hmm.. I am sorry that I was confused it with those for C++. :)
I read Apple's Obj-C reference manual again, and finally "recognized" that they are applied only to variables.
How did I missed it!!!


If things are omitted in interface files and they
are written in their implementation files, it would be easy to lose
track, and although some methods are deleted accidently from the
implementation file, it would be easier to figure out which one is
omitted or not.

By default, an Objective-C compiler will WARN you that a method is declared but not implemented. Implementing a method that is not declared is not even worth a warning. It is normal.



Yes. Why not. However, let's assume that someone give you his code, i.e. a header and its implementation file. Let's also assume that you use C++. He tried cleaning some portion of code before giving it to you.
However, he deleted some 1 or 2 line of functions from his implementation file accidently, but not from his header file which contains a class whose methods are implemented in the implementation file.
With C++, it is possible that the compiler emits error message for you.


However if a method declaration in a header file can be omissible, it may not be able to throw errors, because to the compiler, the method doesn't exist at all.

So, this is the reason behind my question.

Thank you.



=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=++=+=+=+=
JongAm Park                   Home : http://my.dreamwiz.com/jongam
                              Blog : http://jongampark.blogspot.com
Tel)213-251-9592              MSN  : email@hidden
H.P)213-820-8943         AIM/iChat : JongAm
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.