1:unnecessary default statement in covered switch statement
如果switch覆蓋了全部就不用添加default如果不是還是需要添加default倔约。
2:(使用對象下標)
UseObjectSubscripting?
Since: 0.7
Name: use object subscripting
This rule locates the places that can be migrated to the new Objective-C literals with object subscripting.
This rule is defined by the following class: oclint-rules/rules/migration/ObjCObjectSubscriptingRule.cpp
Example:
void aMethod(NSArray *a, NSDictionary *d)
{
id item = [a objectAtIndex:0];
// id item = a[0];
id item = [d objectForKey:@1];
// id item = d[@1];
}
參見:https://oclint-docs.readthedocs.io/en/stable/rules/migration.html#useobjectsubscripting
為什么要這樣呢豪诲?
使用的是下標方法mutableDic[key] = nil
不會出錯因為,而根據apple的可變字典文檔的說明询枚,傳入nil
會移除對應key
的value
鸳惯。
為什么會支持下標的使用呢?
下標的使用是iOS6以后支持的膜廊,取值和設值的原理是編譯器調用了一套非正式的協(xié)議informal-protocol
苇本,這套協(xié)議的文檔將下標分為兩類,字典樣式dictionary-style
和數組樣式array-style
摧冀,分別要求實現對應協(xié)議的方法倍踪,從而支持下標的使用
參見:https://blog.csdn.net/xxq_2011/article/details/76147488
為了方便直接復制過來謝謝作者分享霉涨。
下標subscripting是OC開發(fā)中常用的字典和數組的取值和設值方式,其中不可變字典和數組可以取值惭适,可變字典和數組通過繼承可以取值,同時還支持設值
// 字典樣式
// 字典樣式
- (nullable ObjectType)objectForKeyedSubscript:(KeyType)key; // 取值
- (void)setObject:(nullable ObjectType)obj forKeyedSubscript:(KeyType <NSCopying>)key; // 設值
*// 數組樣式*
- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx ; *// 取值*
- (void)setObject:(ObjectType)obj atIndexedSubscript:(NSUInteger)idx ; *//*設置
3:If you override isEqual you must override hash too.
https://blog.csdn.net/Nathan1987_/article/details/79413299
model missing hash method
else 中代碼為空
if (calendarType == DeliveryCalendarBigType) {
selectCalendarType = 1;
} else {
if (self.smallCalendatType != 0) {
selectCalendarType = self.smallCalendatType;
}
}
替換成
if (calendarType !=DeliveryCalendarBigType && **self**.smallCalendatType != 0) {
? selectCalendarType = **self**.smallCalendatType;
? }else{
? selectCalendarType = 1;
? }
4:high ncss method (行數過多)
ivar assignment outside accessors or init (變量必須初始化)
prefer early exits and continue