-
?查看全部
-
數據庫系統,分布式系統?查看全部
-
父類方法沒有聲明(.h),只有實現(.m),則子類無法繼承 同父類的私有變量,在父類方法里可以看見,但是子類無法直接調用查看全部
-
父類方法沒有聲明(.h),只有實現(.m),則子類無法繼承查看全部
-
//父類的私有變量無法繼承使用 //如果父類的方法中使用了私有變量,子類繼承了父類的方法, //那么私有變量在該方法的操作以及打印我們是可以看到的, //但是我們不可以在子類中直接調用私有變量查看全部
-
/* @public公有 @protected 默認受保護,類外不可使用并且可以被繼承 @private 私有,類外不可使用,不可以繼承 @package 框架權限-框架內相當于受保護,框架外相當于私有 */ @public int _classNo; @protected int _classStr; // .m c1->_classNo=1; } @property(nonatomic,strong)NSString *classname; //方法沒有訪問修飾符,同C語言一樣 //不想被外部調用時,在h文件里不聲明,只在m文件里實現; - (void)report;查看全部
-
{ //成員變量修飾符 /* @public公有 @protected 默認受保護,類外不可使用并且可以被繼承 @private 私有,類外不可使用,不可以繼承 @package 框架權限-框架內相當于受保護,框架外相當于私有 */ //@public //@protected //@private //@package }查看全部
-
重寫初始化方法查看全部
-
/* -,+方法的類型(- 對象方法 用對象名調用 + 類方法 用類名調用) 加號方法和減號方法可以互相調用,當然需要類名和實例化變量,加號方法不能調用成員變量,只能調用靜態變量 2.- (int) int代表返回值類型; 3.(int)x - :代表參數,(int)參數類型,a參數名 4.函數名(方法名)去掉函數(方法)類型,去掉參數類型,去掉參數名 剩下的就是函數名(方法名) 1:- (int)showWithA:(int)a andB:(int)b 函數名 showWithA: andB: 2:- (int):(int)a :(int)b; 函數名 : : */ - (void)report; + (void)report1; - (int)showWithA:(int)a; - (int)showWithA:(int)a andB:(int)b; - (int):(int)a :(int)b;查看全部
-
/* -,+方法的類型(- 對象方法 用對象名調用 + 類方法 用類名調用) 加號方法和減號方法可以互相調用,當然需要類名和實例化變量,加號方法不能調用成員變量,只能調用靜態變量 2.- (int) int代表返回值類型; 3.(int)x - :代表參數,(int)參數類型,a參數名 4.函數名(方法名)去掉函數(方法)類型,去掉參數類型,去掉參數名 剩下的就是函數名(方法名) 1:- (int)showWithA:(int)a andB:(int)b 函數名 showWithA: andB: 2:- (int):(int)a :(int)b; 函數名 : : */ - (void)report; + (void)report1; - (int)showWithA:(int)a; - (int)showWithA:(int)a andB:(int)b; - (int):(int)a :(int)b;查看全部
-
/* -,+方法的類型(- 對象方法 用對象名調用 + 類方法 用類名調用) 加號方法和減號方法可以互相調用,當然需要類名和實例化變量,加號方法不能調用成員變量,只能調用靜態變量 */ - (void)report; + (void)report1; People.m static NSString *_peopleName1; -(void)report { NSLog(@"1111"); [People report1]; } +(void)report1 { NSLog(@"+report1"); [[People alloc] report]; _peopleName1 =@"112"; }查看全部
-
屬性(外部使用)是成員變量(內部使用)的外部接口查看全部
-
#import <Foundation/Foundation.h> @interface People : NSObject { //成員變量 只能在類內使用 (@public ->可用,但不推薦) NSString *_peopleName; int _peopleAge; int _peopleGender; } //property屬性(nonatomic ['n?n?'t?m?k]無原子的) @property(nonatomic,strong)NSString *peopleName; @end查看全部
-
People *p1 = [[People alloc] init]; People *p2 = [[People alloc] init]; People *p3 = [People new]; NSLog(@"p1=%p",p1); NSLog(@"p2=%p",p2); NSLog(@"p3=%p",p3); console: 2016-04-13 15:20:33.406 les3[2141:72950] p1=0x1005000a0 2016-04-13 15:20:33.407 les3[2141:72950] p2=0x1005000b0 2016-04-13 15:20:33.407 les3[2141:72950] p3=0x100500230 Program ended with exit code: 0查看全部
-
//[類名 方法名] *代表指針 //[對象名 方法名] // alloc 為對象分配內存空間 // init 初始化操作 People *p1 = [[People alloc] init]查看全部
舉報
0/150
提交
取消