#import <UIKit/UIKit.h> #import "AppDelegate.h" @interface B : NSObject @end @implementation B - (void)dealloc { NSLog(@"in dealloc"); } @end @interface A : NSObject @property(nonatomic, weak)id referObj; - (void)foo; @end @implementation A - (void)foo { B*b = [B new]; self.referObj = b; NSLog(@"%@",b); } @end int main(int argc, char * argv[]) { @autoreleasepool { A*a = [A new]; [a foo]; return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }
时间: 2024-10-15 00:44:53