Declaration of ownership without an explicit hierarchy

When using properties in Objective-C 2.0, I can declare an instance variable and property as follows:

@interface MyObject : NSObject {
    NSString *_myString;
  }
@property (retain) NSString *myString; 
@end

In the implementation file:

@synthesize myString = _myString;

will tell the compiler that _myString is the name of the actual ivar, right?


Now that you plan to use 64-bit systems, it is possible to declare a property without declaring the corresponding ivar. For instance:

@interface MyObject : NSObject {
  }
@property (retain) NSString *myString; 
@end

In the implementation file:

@synthesize myString = _myString;

My question is , if the command is used @synthesizeas described above, the compiler still points to the automatically generated ivar _myString, which allows me to write _myStringwhen I refer to ivar and write myStringwhen I refer to the property (by calling the getter method)?

0
source share

All Articles