Does Objective-C @package correspond to Java packages?

Discussion in 'iOS Programming' started by rhimbo, Jul 11, 2011.

  1. rhimbo macrumors member


    Jun 21, 2009
    Hello folks,

    My goal is to organize the source files that comprise my project into "packages" in the sense of Java packages. The Objective-C manual (page 41) indicates that the language supports a @package compiler directive. But the manual doesn't explain packages beyond that!

    So, my questions are:

    1) What is an Objective-C package?

    2) Should I organize the source files in my project by package, assuming Objective-C packages are similar to Java in regards to visibility.

    Thanks in advance.
  2. jiminaus macrumors 65816


    Dec 16, 2010
    You can't. See Luke Redpath's stack overflow link above. It describes the common technique of using "namespace" prefixes on class.

    @package is used in Objective-C in the same way as @private and @public is used, which are used in the same way a Java's private and public, but for instance variables only, not for methods.

    However, @package bears no relation to Java's package in this context. The Objective-C Runtime Release Notes for Mac OS X v10.5 describes what @package means.

Share This Page