@interface Demo : NSObject
{
NSString *retainString;
NSString *copyString;
}
@property (nonatomic, retain)NSString *retainString;
@property (nonatomic, copy)NSString *copyString;
@end
@implementation Demo
@synthesize retainString;
@synthesize copyString;
-(void)dealloc
{
[retainString release];
[copyString release];
[super dealloc];
}
@end
Demo *o = [[Demo alloc] init];
NSMutableString *s1 = [[NSMutableString alloc] initWithCapacity:100];
[s1 setString:@"fuckyou"];
o.retainString = s1;
o.copyString = s1;
NSLog(@"retain string is %@", o.retainString);
NSLog(@"copy string is %@", o.copyString);
[s1 setString:@"fuckme"];
NSLog(@"retain string is %@", o.retainString);
NSLog(@"copy string is %@", o.copyString);
|