一句話筆記,某段時(shí)間內(nèi)遇到或看到的某個(gè)可記錄的點(diǎn)。 2016-9-06
- 一個(gè)關(guān)于app 命名的新規(guī)
- nullable、__nullable、_Nullable 區(qū)別
- 不小心刪除了Xcode中的SDK,怎么辦
- 數(shù)字轉(zhuǎn)金額大寫
- UITableViewCell 中一個(gè)替換
1、蘋果終于開始對App命名做出規(guī)定
不允許超過五十個(gè)字符。之前通過關(guān)鍵字堆砌在應(yīng)用名的ASO做法終于不管用了!
另外,蘋果也宣布在清理app store中不符合新審核標(biāo)準(zhǔn)的“僵尸”app。
2、nullable、__nullable、_Nullable 究竟有什么區(qū)別?
區(qū)別:
__nullable 表示對象可以是 NULL 或 nil,
__nonnull 表示對象不應(yīng)該為空。
三種寫法本質(zhì)上都是互通的,只是放的位置不同。
------
@property (nonatomic, copy, nullable) NSString *aString;
@property (nonatomic, copy) NSString * __nullable aString;
@property (nonatomic, copy) NSString * _Nullable aString;
------
- (nullable NSString *)method;
- (NSString * __nullable)method;
- (NSString * _Nullable)method;
三種寫法的源來:
為了避免與第三方庫潛在的沖突,蘋果把 __nonnull/__nullable 改成 _Nonnull/_Nullable。
再加上蘋果同樣支持了沒有下劃線的寫法 nonnull/nullable,所以就有三種寫法啦
建議:
1. 對于屬性、方法返回值、方法參數(shù)的修飾,使用:nonnull/nullable;
2. 對于 C 函數(shù)的參數(shù)、Block 的參數(shù)、Block 返回值的修飾,使用:_Nonnull/_Nullable
源自:南峰子_老驢 的 Objective-C 中的 nullable、__nullable、_Nullable 究竟有什么區(qū)別呢?
3、不小心刪除了Xcode中的SDK
rm -r ~/Library/Developer/Xcode/DerivedData/ModuleCache
就是刪除當(dāng)前版本下 Xcode 中的這個(gè)緩存文件,這個(gè)緩存文件就是留了一些不合法或者說無效的某些東東,對于當(dāng)前文件。
4、數(shù)字轉(zhuǎn)金額大寫
- (NSString *)digitUppercaseWithMoney:(NSString *)money {
// 判斷長度
NSMutableString *testString = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%.0f",[money doubleValue]]];
if (testString.length > 16) return money; // 這個(gè)數(shù)目已經(jīng)夠大了
// 截取小數(shù)點(diǎn) 前兩位
NSMutableString *moneyString = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%.2f",[money doubleValue]]];
// 設(shè)置單位
NSArray *scaleArray=@[@"分", @"角", @"元", @"拾", @"佰", @"仟", @"萬", @"拾", @"佰", @"仟", @"億", @"拾", @"佰", @"仟", @"兆", @"拾", @"佰", @"仟" ];
NSArray *integerArray = @[@"拾", @"佰", @"仟", @"萬", @"拾萬", @"佰萬", @"仟萬", @"億", @"拾億", @"佰億", @"仟億", @"兆", @"拾兆", @"佰兆", @"仟兆"];
// 數(shù)字大寫
NSArray *baseArray=@[@"零", @"壹", @"貳", @"叁", @"肆", @"伍", @"陸", @"柒", @"捌", @"玖"];
// 開始轉(zhuǎn)換
NSMutableString *resultString = [[NSMutableString alloc] init];
[moneyString deleteCharactersInRange:NSMakeRange([moneyString rangeOfString:@"."].location, 1)];
for(NSInteger i=moneyString.length;i > 0;i--)
{
NSInteger index = [[moneyString substringWithRange:NSMakeRange(moneyString.length-i, 1)] integerValue];
[resultString appendString:baseArray[index]];
//判斷是否是整數(shù)金額
if (i == moneyString.length) {
NSInteger longIndex = [[moneyString substringFromIndex:1] integerValue];
if (index > 0 && longIndex == 0) {
NSString *integerString = @"";
if (moneyString.length > 3) {
integerString = integerArray[moneyString.length-4];
}
[resultString appendString:[NSString stringWithFormat:@"%@%@",integerString,@"元整"]];
break;
}
}
if([[moneyString substringFromIndex:moneyString.length-i+1] integerValue] == 0
&& i != 1
&& i != 2) {
[resultString appendString:@"元整"];
break;
}
[resultString appendString:scaleArray[i-1]];
}
return resultString;
}
從 JAnzTam 瞄過來的,特此筆記下。
5、這個(gè)方法原來已經(jīng)被棄用啦,后期需要換一下。
-initWithFrame:(CGRect)frame reuseIdentifier:(nullable NSString *)reuseIdentifier
**
@interface UITableViewCell (UIDeprecated)
// Frame is ignored. The size will be specified by the table view width and row height.
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(nullable NSString *)reuseIdentifier
在UITableViewCell 中自定義時(shí),常用到的方法,此處已經(jīng)被棄用,可用
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier NS_AVAILABLE_IOS(3_0) NS_DESIGNATED_INITIALIZER;
其實(shí)換了蠻久的,之前一直沒有注意過,直接當(dāng)做代碼塊啦,所以有時(shí)代碼塊也有檢查啊!