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

清风清晨

暂无认证

  • 1浏览

    0关注

    71博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【@property参数strong与weak Objective-C语言】

清风清晨 发布时间:2022-08-22 22:28:26 ,浏览量:1

前言

例如,有一个Car类: #import

@interface Car : NSObject @property(nonatomic,assign)int speed;

  • (void)run; @end

#import “Car.h”

@implementation Car – (void)dealloc { NSLog(@“车废了。。。”); } – (void)run { NSLog(@“时速为%d的车,在行驶。。。”,_speed); } @end

还有一个Person类: #import #import “Car.h” @interface Person : NSObject @property(nonatomic,retain)Car *car; @end

#import “Person.h”

@implementation Person

@end

一、第一个问题,能用retain吗

1)@property(nonatomic,retain)Car *car; 这句话,能用retain吗? 2)retain参数,能不能在ARC机制下面去使用呢。。。不能, 为什么: @property(nonat

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

微信扫码登录

0.0376s