偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

在Objective-c中如何使用協(xié)議

移動開發(fā) iOS
本文介紹的是在Objective-c中如何使用協(xié)議,主要介紹的是協(xié)議的一些概念和操作,先來看內(nèi)容。

Objective-c中如何使用協(xié)議是本文要介紹的內(nèi)容,主要介紹的是協(xié)議的一些概念和操作,通過本文介紹,讓我們?nèi)チ私鈪f(xié)議,先來看內(nèi)容詳解。

一、協(xié)議的定義

  1. @protocol test  
  2.  
  3. -(void) testpocol:(int)t;  
  4. @end 

二、協(xié)議的繼承

h頭文件

  1. #import “test.h”    導(dǎo)入?yún)f(xié)議  
  2. @interface testViewController:UIViewController <test>{  
  3. //id<test> testp;  

m實(shí)現(xiàn)文件

  1. @implementation testViewController  
  2.  
  3. -(void)viewDidLoad{  
  4. [super viewDidLoad];  
  5. //調(diào)用實(shí)現(xiàn)方法的類  
  6. testdiaoyong  *td=[[testdiaoyong alloc] init]; 

td.testd=self;   把當(dāng)前實(shí)現(xiàn)協(xié)議的類對象賦給需要使用的地方

  1. //也可以使用下面的方法傳遞協(xié)議  
  2. [td  setpoco:self]  
  3. }  
  4.  
  5. -(void) testpocol:(int)s{  
  6. NSLog(@"testpocol....................%d",s);  
  7. }  
  8. @end  
  9.  
  10. 三,調(diào)用協(xié)議  
  11.  
  12. @interface testdiaoyong  : NSObject{  
  13. id<test> testp;  
  14. }  
  15.  
  16. -(void)setpoco:t;  
  17.  
  18. -(void)setlen;  
  19. @end  
  20.  
  21. @implementation testdiaoyong  
  22. @synthesize testp;  
  23.  
  24. //協(xié)議t可以不負(fù)類型  
  25.  
  26. -(void)setpoco:t{  
  27. self.testp=t;  
  28. }  
  29.  
  30. -(void)start{  
  31. [testp testpocol:99];  
  32. }  
  33. @end 

小結(jié):在Objective-c中如何使用協(xié)議的內(nèi)容介紹完了,希望本文對你有所幫助。

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-15 17:47:13

Objective-CisMemberOfC

2011-08-03 15:51:48

Objective-C 協(xié)議 委托

2013-04-11 13:41:30

Objective-CiOS編程

2011-08-15 14:32:42

Objective-C委托協(xié)議

2015-11-18 10:16:38

OC代碼

2011-08-04 17:13:48

Objective-C 字符串

2011-08-22 15:31:35

Objective-C協(xié)議

2011-08-02 15:55:31

Objective-C NSAutorele

2011-07-19 17:18:35

Objective-C Property

2011-08-04 15:52:48

Objective-C HTML

2011-08-04 10:04:17

Objective-C 分類 協(xié)議

2012-06-25 10:14:33

WindowsGNUstepObjective-C

2011-08-10 18:07:29

Objective-C反射

2013-06-20 10:40:32

Objective-C實(shí)現(xiàn)截圖

2013-03-27 12:54:00

iOS開發(fā)Objective-C

2011-05-11 15:58:34

Objective-C

2011-05-11 11:20:26

Objective-C

2011-07-25 10:30:41

Objective-C Xcode 重構(gòu)

2011-07-25 11:02:29

Objective-C Xcode 標(biāo)簽

2011-08-17 11:05:22

Objective-C方法
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號