Any use for undeclared @implementations?

Discussion in 'Mac Programming' started by zippyfly, Sep 28, 2010.

  1. macrumors regular

    Mar 22, 2008
    Hi folks.

    So I've come across mention that methods not declared in @interface and written up in @implementation can still be called?

    Of what use is this?

    It seems such methods are not actually @private to the object. I can't see this being a mistake on the part of the designers so I'm wondering why this is allowed?
  2. macrumors 68000


    Aug 17, 2009
    Most often you see this used for overrides (methods prototyped by a superclass, like -init or -mouseDown), for protocol implementation (like NSCoding or datasource, implicitly prototyped via the protocol conformance declaration) and for delegate methods. Occaisionally you might see non-prototyped methods that are only used within the implementation, which the programmer might do in order to hide the methods, but this is a generally discouraged practice.
  3. thread starter macrumors regular

    Mar 22, 2008
    But of course! (Smacks forehead. Mine, not yours. ;-)
  4. macrumors G5


    Nov 25, 2005
    I recommend to set up your projects so that all compiler warnings are treated as errors, then make use of unknown selector a warning. (Especially useful when you write @selector(thismethod) instead of @selector(thismethod: ) )

    I tend to have something like

    @interface myclass (privatebits)

    in my implementation files for internally used methods so that these methods are not even visible in the header file.

Share This Page