输出应该是
strString = değiştim
wkString = NULL
但事实并非如此。为什么?
#import <Foundation/Foundation.h>
@interface learnARC : NSObject {
NSString *strString, __weak *wkString;
}
@property (strong) NSString *strString;
@property (weak) NSString *wkString;
-(void) yaz;
@end
#import "learnARC.h"
@implementation learnARC
@synthesize wkString, strString;
-(void) yaz {
NSString *anaString = @"anaString";
strString = anaString;
wkString = anaString;
NSLog(@"\nstrString = %@\nwkString = %@",strString,wkString);
anaString = @"değiştim";
NSLog(@"\nstrString = %@\nwkString = %@",strString,wkString);
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
learnARC *lrnarc = [[learnARC alloc]init];
[lrnarc yaz];
}
return 0;
}