博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Objectice-C之方法、消息和选择器
阅读量:7282 次
发布时间:2019-06-30

本文共 888 字,大约阅读时间需要 2 分钟。

  在第一篇Car的方法中加入一个类方法:

+ (NSString *) motto {
return(@"Ford Prefects are Mostly Harmless"); }

 

#import 
#import "Car.h" //统一定义颜色和button风格 #define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f] #define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease] //定义TestBedViewController控制器 @interface TestBedViewController : UIViewController @end //实现控制器 @implementation TestBedViewController //定义函数 - (void) action: (id) sender {
// Calling a class method NSLog(@"%@", [Car motto]);//调用类函数 } - (void) viewDidLoad {
self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR; self.navigationItem.rightBarButtonItem = BARBUTTON(@"Action", @selector(action:));//设定右边导航栏的按钮的标题和事件 //此处@selector表示选择器 } @end

转载地址:http://rdkjm.baihongyu.com/

你可能感兴趣的文章
苹果信息推送服务(Apple Push Notification Service)使用总结
查看>>
CSS优先级特性之权重叠加
查看>>
组件、组件化 与 模块化
查看>>
取物料特性
查看>>
sqlserver 如何备份或恢复一个表_MS SQL Server
查看>>
[LeetCode]19. Remove Nth Node From End of List删除链表的倒数第N个节点
查看>>
谷歌浏览器保存网页为pdf和.mhtml文件
查看>>
UITextField,UITextView字数限制
查看>>
[MongoDB]Profiling性能分析
查看>>
设计模式(工厂方法)
查看>>
典型的文件上传漏洞
查看>>
用wix制作属于自己的Flash网站
查看>>
git使用记录
查看>>
[Noi2014]购票 BZOJ3672 点分治+斜率优化+CDQ分治
查看>>
lambda 与内置函数,以及一些补充
查看>>
SqlServer中使用row_number() over实现通用的分页存储过程
查看>>
无线网路
查看>>
通用单例的写法
查看>>
跨域请求被拒绝的问题
查看>>
Swing---WindowConstants
查看>>