PDA

View Full Version : Does Objective-C @package correspond to Java packages?




rhimbo
Jul 11, 2011, 03:31 PM
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.



Luke Redpath
Jul 11, 2011, 04:10 PM
http://www.google.co.uk/#sclient=psy&hl=en&safe=off&source=hp&q=objective-c+%40package&aq=f&aqi=g1&aql=&oq=&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=ce07ae90aca13e82&biw=1255&bih=777

First result.

And an even better result a few results down:

http://stackoverflow.com/questions/1000707/objective-c-equivalent-of-java-packages

Did you even bother Googling for it?

jiminaus
Jul 11, 2011, 05:33 PM
My goal is to organize the source files that comprise my project into "packages" in the sense of Java packages.

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

The Objective-C manual (page 41) indicates that the language supports a @package compiler directive. But the manual doesn't explain packages beyond that!

@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 (http://developer.apple.com/library/mac/releasenotes/Cocoa/RN-ObjectiveC/_index.html#//apple_ref/doc/uid/TP40004309-CH1-DontLinkElementID_7) describes what @package means.