Hi.

I'm a bit curious about the Objective-C 2.0 property/synthesize
mechanism. In all examples I've seen, an instance variable is declared
for each property. But if I leave out the instance variable like in
the following example, everything works fine, too.

----------------------------------------------------------------------
#import <Foundation/Foundation.h>
#import <stdio.h>

@interface MyClass : NSObject
@property NSInteger number;
@end

@implementation MyClass : NSObject
@synthesize number;
@end

int main() {
  MyClass *obj = [[MyClass alloc] init];

  [obj setNumber: 77];
  printf("%d\n", (int)[obj number]);

  [obj release];
  return 0;
}
----------------------------------------------------------------------

So my question: What are the (possible) problems/implications if I
leave out the declarations of instance variable of properties? What
are the recommendations? More specific: Does the above also work/run
on iOS?

-- 
Until the next mail...,
Stefan.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to