標籤:nat get 取出 ble ios開發 spec 資料 郵件 方法
#pragma mark -- nullable
nullable:可以為空白,只能修飾對象,不能修飾基礎資料型別 (Elementary Data Type)
// 方式一:
@property (nonatomic, copy, nullable) NSString *name;
// 方式二:
@property (nonatomic, copy) NSString *_Nullable name;
// 方式三:
@property (nonatomic, copy) NSString *__nullable name;
// 方法中
- (nullable NSString *)test:(nullable NSString *)str;
- (NSString * _Nullable)test1:(NSString * _Nullable)str;
#pragma mark -- nonnull
nonnull: 不可為空,只能修飾對象,不能修飾基礎資料型別 (Elementary Data Type)
// 方式一:
@property (nonatomic, copy, nonnull) NSString *name;
// 方式二:
@property (nonatomic, copy) NSString * _Nonnull name;
// 方式三:
@property (nonatomic, copy) NSString * __nonnull name;
// 方法中
- (nonnull NSString *)test:(nonnull NSString *)str;
- (NSString * _Nonnull)test1:(NSString * _Nonnull)str;
#pragma mark -- null_resettable
null_resettable: get:不能返回為空白, set可以為空白
@property (nonatomic, copy, null_resettable) NSString *name;
// 注意;如果使用null_resettable,必須 重寫get方法或者set方法,處理傳遞的值為空白的情況
#pragma mark -- _Null_unspecified
_Null_unspecified:不確定是否為空白
方式一
@property (nonatomic, copy) NSString *_Null_unspecified name;
方式二
@property (nonatomic, copy) NSString *__null_unspecified name;
#pragma mark -- 泛型
@property (nonatomic, strong) NSMutableArray<NSString *> *arrayM;
// 表明arrayM數組中存放的對象只能是NSString類型的對象
// 開發規範、從數組中取出來對象,直接當做泛型對象使用,可以直接使用點文法,提高開發效率
#pragma mark -- __kindof
// __kindof Person *:表示傳回值可以是Person類或者它的子類,外面使用的時候可以很清楚的知道傳回值的類型
+ (__kindof Person *)person;
有任何關於iOS開發的問題!歡迎下方留言!!!或者郵件[email protected] 雖然我不一定能夠解答出來,但是我會請教iOS開發高手!!!解答您的問題!!!
iOS9新特性之常見關鍵字、泛型