您当前的位置: 首页 >  objective-c

清风清晨

暂无认证

  • 2浏览

    0关注

    71博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【循环retain Objective-C语言】

清风清晨 发布时间:2022-08-18 10:55:44 ,浏览量:2

前言

例如,有一个Person类: #import #import “Book.h” @interface Person : NSObject @property(nonatomic,retain)NSString *name; @property(nonatomic,retain)Book *book; – (void)read; @end

#import “Person.h” @implementation Person – (void)dealloc { NSLog(@“人挂了。。。”): [_name release]; [_book release]; [super dealloc]; – (void)read { [_book castZhiShi]; NSLog(@“啊,书真好。。。”); } @end

还有一个Book类: #import @class Person; @interface Book : NSObject @property(nonatomic,retain)NSString *name; ///书的拥有者 @property(nonatomic,retain)Person *owner; ///传播知识的方法 – (void)castZhiShi; @end

#import “Book.h” #import “Person.h” @implem

关注
打赏
1663943137
查看更多评论
立即登录/注册

微信扫码登录

0.0363s