import <Foundation/Foundation.h>
@class Jie;
@interface Zhao : NSObject
{
Jie *_jie;
}
@property(nonatomic,retain)Jie *jie;
@end
import "Zhao.h"
import "Jie.h"
@implementation Zhao
-(void)dealloc
{
[super dealloc];
[_jie release];
NSLog(@"Zhao dealloc");
}
@end
import <Foundation/Foundation.h>
@class Zhao;
@interface Jie : NSObject
{
Zhao *_zhao;
}
@property(nonatomic,assign)Zhao *zhao;
@end
import "Jie.h"
@implementation Jie
-(void)dealloc
{
[super dealloc];
// [_zhao release];
NSLog(@"Jie dealloc");
}
@end
import <Foundation/Foundation.h>
import "Jie.h"
import "Zhao.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
Zhao *zhao =[[Zhao alloc ] init];
Jie *jie = [[Jie alloc] init];
NSLog(@"zhao %ld jie %ld",zhao.retainCount,jie.retainCount);
[zhao setJie:jie];
[jie setZhao:zhao];
NSLog(@"zhao %ld jie %ld",zhao.retainCount,jie.retainCount);
[zhao release];
[jie release];
}
return 0;
}
网友评论