自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

關于Objective-C構造函數(shù)舉例

移動開發(fā) iOS
Objective-C構造函數(shù)舉例是本文要介紹的內(nèi)容,主要是來學習Objective-C中的構造函數(shù),本文呢內(nèi)容不多,駐澳是基于代碼實現(xiàn),來看詳細內(nèi)容。

Objective-C構造函數(shù)舉例是本文要介紹的內(nèi)容,主要是來學習Objective-C中的構造函數(shù),本文呢內(nèi)容不多,駐澳是基于代碼實現(xiàn),來看詳細內(nèi)容。

  1. #include  <Foundation/Foundation.h> 
  2. #include  <stdio.h> 
  3.  
  4. @interface  Container:NSObject  
  5. {  
  6.  int number;  
  7. }  
  8. -(void) setNumber:(int) n;  
  9. -(int) intValue;  
  10. -(Container*) init:(int)n;  
  11. @end;  
  12.  
  13. @implementation Container  
  14. -(void) setNumber:(int) n  
  15. {  
  16.  nnumber=n;  
  17. }  
  18. -(int) intValue  
  19. {  
  20.  return number;  
  21. }  
  22.  
  23. //構造函數(shù)  
  24. -(Container*)init:(int) n  
  25. {  
  26.  self=[super  init];  
  27.  if (self){  
  28.  [self setNumber:n];  
  29. }  
  30.  
  31. return self;  
  32. }  
  33. @end  
  34. int main(void)  
  35. {  
  36.  Container  *object=[[Container new]   init : 3];  
  37.  printf( "The number is %i\n",  [object intValue]);  
  38.  return 0;  

輸出結(jié)果:

  1. The number is 3 

小結(jié):關于Objective-C構造函數(shù)舉例的內(nèi)容介紹完了,希望通過本文的學習能對你有所幫助!

責任編輯:zhaolei 來源: 博客園
相關推薦

2011-08-17 10:58:59

Objective-C構造函數(shù)

2011-08-04 11:15:46

Objective-C 構造函數(shù) 構造方法

2011-08-17 15:37:23

Objective-C垃圾收集

2011-07-20 13:34:37

Objective-C self.

2011-08-15 14:02:36

Objective-C

2011-08-01 17:11:43

Objective-C 函數(shù)

2011-08-04 15:14:39

Objective-C 數(shù)據(jù)類型

2013-03-27 12:54:00

iOS開發(fā)Objective-C

2013-06-20 10:40:32

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

2011-05-11 11:20:26

Objective-C

2011-05-11 15:58:34

Objective-C

2011-08-10 18:07:29

Objective-C反射

2011-08-04 16:46:03

Objective-C 聲明

2011-07-08 13:49:46

Objective-C UUID

2011-07-29 16:16:30

Objective-c block

2011-08-03 16:55:05

Objective-C 代理

2014-04-30 10:16:04

Objective-CiOS語法

2011-08-04 09:35:09

Objective-C 編碼規(guī)范

2012-03-07 13:43:59

Objective-C

2014-06-25 14:02:59

Objective-CKVO
點贊
收藏

51CTO技術棧公眾號