码迷,mamicode.com
首页 > 其他好文 > 详细

延展性,实现方法的私有化

时间:2015-11-10 19:28:16      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

//Study.m文件声明

1 #import <Foundation/Foundation.h>
2 
3 @interface Study : NSObject
4 
5 -(void)study; 
6 
7 @end

//Study.h文件实现

 1 #import "Study.h"
 2 
 3 @interface Study ()//偷偷声明
 4 
 5 -(void)playLOL;
 6 
 7 -(void)playCF;
 8 
 9 @end
10 
11 @implementation Study
12 
13 -(void)study
14 
15 {
16     NSLog(@"我正在学习");
17 
18     [self playCF];
19 
20     [self playLOL];
21 
22 }
23 
24 -(void)playLOL//延展1
25 
26 {
27     NSLog(@"我同样在玩LOL");
28 }
29 
30 -(void)playCF//延展2
31 
32 {
33     NSLog(@"我还在玩CF");
34 }
35 
36 @end

 //main.m文件中

Study *xiaoming=[[Study alloc]init];

[xiaoming study];

//

2015-11-10 18:53:47.972 test[7322:112328] 我正在学习
2015-11-10 18:53:47.972 test[7322:112328] 我在玩CF
2015-11-10 18:53:47.972 test[7322:112328] 我在玩LOL

  

  

延展性,实现方法的私有化

标签:

原文地址:http://www.cnblogs.com/liuyingjie/p/4953978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!