OC 对象作为方法的参数连续传递
发布日期:2021-06-30 22:37:04
浏览次数:3
分类:技术文章
本文共 853 字,大约阅读时间需要 2 分钟。
实现1:
#import@interface Gun:NSObject{ @public NSString *_type; int _bllutCount;}-(void)shot;@end@implementation Gun-(void)shot{ if(_bllutCount >0){ _bllutCount--; } NSLog(@"%@ is shoting ..., the bllut is leave :%d",_type,_bllutCount);}@end@interface Person : NSObject{ @public NSString *_name; int _life; int _level;}-(void)fire:(Gun *) gun;@end@implementation Person-(void)fire:(Gun *) gun{ [gun shot];}@endint main(int argc, const char * argv[]){ @autoreleasepool { // Person *p = [Person new]; p->_name = @"tom"; p->_life = 100; p->_level = 10; Gun *gun = [Gun new]; gun ->_type = @"china"; gun ->_bllutCount = 6; [p fire:gun]; [p fire:gun]; [p fire:gun]; NSLog(@"Hello, World!"); } return 0;}
实现2:
转载地址:https://lovoo.blog.csdn.net/article/details/51457198 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年04月30日 11时39分40秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
反向传播&梯度下降 的直观理解程序(numpy)
2019-04-30
CodeForces - 931B World Cup (思维 模拟)
2019-04-30
ACM 2017 北京区域赛 J-Pangu and Stones(区间dp)
2019-04-30
java常用类 String面试题
2019-04-30
Windows10下的powershell美化教程
2019-04-30
利用ffmpeg合并音频和视频
2019-04-30
solr修改schema文件(solr修改配置文件)
2019-04-30
select下拉框分组展示插件的使用--(select-mania插件的使用)
2019-04-30
Java Lambda表达式的应用--Stream API操作集合框架
2019-04-30
solr的使用详解
2019-04-30
Myslq连接(JDBC)url属性的参数的设置
2019-04-30
关于Spring MVC与前端的交互
2019-04-30
大厂经典面试题:Redis为什么这么快?
2019-04-30
Android之Retrofit基本用法篇
2019-04-30
Netty与网络协议资料整理
2019-04-30
Golang 逃逸分析
2019-04-30
golang实现大数据量文件的排序
2019-04-30