I've read many things about the @synthesize call. About its use, ...
So I have made a test, and its result gives me a strange feeling. Let me explain...Lets write in an object .h
@interface AnObject : NSObject {
NSString* aaTest;
}
@property(nonatomic, retain) NSString* bbTest;
-(void)log;
Then in its .m
@synthesize bbTest = aaTest;
-(void)log {
NSLog(@"Inside var : %@"开发者_如何学编程, aaTest);
NSLog(@"Inside property : %@", self.bbTest);
}
In another .m, let's write :
#import "AnObject.h"
then into one method :
AnObject* testCtrl = [[AnObject alloc] init];
testCtrl.bbTest = @"Some string";
NSLog(@"Outside property : %@", testCtrl.bbTest);
[testCtrl log];
We are ok that here, including only the .h, the synthesize call is not known from the other object. Looking at the Log, it gives :
Outside property : Some string
Inside var : Some string
Inside property : Some string
So... Isn't that strange ?
In your synthesize call, you assign bbtest to aaTest (note the capital T). That's not the same as aatest
精彩评论