• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Header Differences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Header Differences


  • Subject: Re: Header Differences
  • From: Michael Ash <email@hidden>
  • Date: Mon, 25 May 2009 01:16:39 -0400

On Mon, May 25, 2009 at 12:51 AM, Chunk 1978 <email@hidden> wrote:
> i'm following a tutorial that lists the header file like this:
>
>
> -=-=-=-=-
> @interface PickersAppDelegate : NSObject <UIApplicationDelegate>
>        {
>        IBOutlet UIWindow *window;
>        IBOutlet UITabBarController *rootController;
>        }
>
> @property (nonatomic, retain) UIWindow *window;
> @property (nonatomic, retain) UITabBarController *rootController;
> -=-=-=-=-
>
>
> but IB automatically sets the IBOutlet as part of the @property and
> not in the declaration struct like this:
>
>
> -=-=-=-=-
> @interface PickersAppDelegate : NSObject <UIApplicationDelegate>
>        {
>        UIWindow *window;
>        UITabBarController *rootController;
>        }
>
> @property (nonatomic, retain) IBOutlet UIWindow *window;
> @property (nonatomic, retain) IBOutlet UITabBarController *rootController;
> -=-=-=-=-
>
>
> is there a difference?  which one should be used?

No difference. Use whatever makes you happy. IBOutlet is just a hint
to help Interface Builder parse your header. It literally does nothing
when the code is actually compiled: IBOutlet is #defined to nothing.

>  also, just to clear
> things up for me a bit, is it safe to assume that everything listed in
> the declaration struct should also have getter and setter methods with
> @property/@synthesize?

Not at all. The stuff that's "listed in the declaration struct" (which
it's not, but I get what you mean) are called instance variables, and
even though they appear in the header you should treat them as an
implementation detail of your class. @property, on the other hand, is
part of your class's public interface. A @property may well be
implemented in terms of an instance variable (and that's exactly what
@synthesize accomplishes), but it doesn't have to be. And going the
other way, an instance variable doesn't need to have a @property and
in fact frequently doesn't, as instance variables are often used for
purposes which need no exposure to any code outside that class.

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Header Differences
      • From: Ken Thomases <email@hidden>
References: 
 >Header Differences (From: Chunk 1978 <email@hidden>)

  • Prev by Date: Header Differences
  • Next by Date: Re: Best way to draw text in CAOpenGLLayer
  • Previous by thread: Header Differences
  • Next by thread: Re: Header Differences
  • Index(es):
    • Date
    • Thread