Objective-C - 循环引用问题
来源:互联网 发布:山东自动化控制软件 编辑:程序博客网 时间:2024/05/17 22:35
循环引用问题
/* 1.@class的作用:仅仅告诉编译器,某个名称是一个类 @class Person; // 仅仅告诉编译器,Person是一个类 2.开发中引用一个类的规范 1> 在.h文件中用@class来声明类 2> 在.m文件中用#import来包含类的所有东西 3.两端循环引用解决方案 1> 一端用retain 2> 一端用assign */#import <Foundation/Foundation.h>#import "Card.h"#import "Person.h"int main(){ // p - 1 Person *p = [[Person alloc] init]; // c - 1 Card *c = [[Card alloc] init]; // c - 2 p.card = c; // p - 1 c.person = p; // c - 1 [c release]; // p - 0 c - 0 [p release]; return 0;}
#import "Card.h"// @class仅仅是告诉编译器,Card是一个类//@class Card;@interface Person : NSObject@property (nonatomic, retain) Card *card;@end
#import "Card.h"@implementation Person- (void)dealloc{ NSLog(@"Person被销毁了"); [_card release]; [super dealloc];}@end
@class Person;@interface Card : NSObject@property (nonatomic, assign) Person *person;@end
@implementation Card- (void)dealloc{ NSLog(@"Car被销毁了"); // [_person release]; [super dealloc];}@end
0 1
- Objective-C - 循环引用问题
- Objective-c 循环引用
- Objective-C 循环引用
- Objective-c中block使用时的循环引用问题
- Objective-C 循环引用的处理
- objective-c基础语法学习之--(6)内存管理经典问题:循环引用
- Objective-C中循环引用的问题 深入剖析实用版
- objective-c 交叉引用问题的解决方案
- Objective-C 【protocol 的引用问题】
- Objective - C基础: 第五天 - 6.循环引用
- Objective - C基础: 第六天 - 3.ARC循环引用
- Objective-C内存管理第四弹:循环引用
- Objective-c - ARC机制下的循环引用
- object c 循环引用计数问题,非常重要。
- Effective Objective-C(第29-36条)内存管理篇,ARC、循环引用、引用计数
- objective-c 引用计数
- Objective-C关联引用
- Objective-C关联引用
- New files creation and Makefile
- Scala编程指南(2) 更少的字更多的事
- C++友元
- presentViewController弹出界面的大小设置
- 设计模式 笔记 享元模式 Flyweight
- Objective-C - 循环引用问题
- MHA 自动故障转移步骤及过程剖析
- source Insight 3.5.72
- Web服务器之Nginx详解(理论部分)
- tomcat管理用户配置
- PyQt5学习笔记08----标准输入框QInputDialog
- 验证码校验
- Python操作redis
- 第一篇