What is the best way to declare a property?

Posted by Simon on Stack Overflow See other posts from Stack Overflow or by Simon
Published on 2010-12-30T03:45:48Z Indexed on 2011/01/01 4:54 UTC
Read the original article Hit count: 271

Filed under:

Hi. We declare properties using the @property keyword and synthesize it in the implementation file. My question is,

What if I declare a property using the @property keyword and also declare a variable in the interface block with the same name? For example, consider the following code,

Interface:

@interface myClass : NSObject {

    NSString *myClass_name;  // LINE 1
}

@property(nonatomic, retain) NSString *myClass_name;  // LINE 2

@end

Implementation:

@implementation myClass

@synthesize myClass_name  // LINE 3

@end

Declaring myClass_name in LINE 1 will make any problem? Like any reference problem or any unnecessary memory consumption problem?

© Stack Overflow or respective owner

Related posts about iphone