Why We Declare Class with Keyword @interface

Discussion in 'iOS Programming' started by teguh123, Mar 26, 2011.

  1. teguh123 macrumors member

    Mar 22, 2011
    Is this because all classes are effectively an interface of NSObject?
  2. KnightWRX macrumors Pentium


    Jan 28, 2009
    Quebec, Canada
    It has nothing to do with inheritance from NSObject. The keyword is @interface because that is what you're declaring, the variables/properties/methods that a developer will use to interface with your class.

    It's just an Objective-C keyword, no need to think about it for too long.
  3. admanimal macrumors 68040

    Apr 22, 2005
    It makes sense when you think about its counterpart, @implementation. You declare the class' interface (i.e. how you can interface with it) in the header file, and then the implementation of the things listed in the interface goes in the .m file.
  4. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    You also need to think about the compiler that is build in, think about how that works.
    U basicly tell the compiler like this, make these these and these methods/variables in this viewController header file & then in the M file, u basicly tell it to get it from the header file, via the implementation.

    This is not the right way to put it, but in big lines it is.
    Think u can get a more nerdy explenation somewhere x)

Share This Page