#import <Foundation/Foundation.h>
@interface UserInfo :NSObject
@property(nonatomic,strong)NSString *string1;
@property(nonatomic,weak)NSString *string2;
@end
#import "UserInfo.h"
@implementation UserInfo
@synthesize string1;
@synthesize string2;
@end
UserInfo *info=[[UserInfoalloc] init];
info.string1=[[NSStringalloc] initWithUTF8String:"String1"];
//由于self.string1与self.string2指向同一地址,且string2没有retain内存地址,而self.string1=nil释放了内存,所以string1为nil。声明为weak的指 //针,指针指向的地址一旦被释放,这些指针都将被赋值为nil
info.string2=info.string1;
info.string1=nil;
NSLog(@"string2=%@",info.string2);