Migration¶
ReplaceWithBoxedExpression¶
Since: 0.7
可以迁移到object-c的新的表达方式
定义类: oclint-rules/rules/migration/ObjCBoxedExpressionsRule.cpp
Example:
void aMethod()
{
NSNumber *fortyTwo = [NSNumber numberWithInt:(43 - 1)];
// NSNumber *fortyTwo = @(43 - 1);
NSString *env = [NSString stringWithUTF8String:getenv("PATH")];
// NSString *env = @(getenv("PATH"));
}
ReplaceWithContainerLiteral¶
Since: 0.7
可以迁移到object-c的新的表达方式.
定义类: oclint-rules/rules/migration/ObjCContainerLiteralsRule.cpp
Example:
void aMethod()
{
NSArray *a = [NSArray arrayWithObjects:@1, @2, @3, nil];
// NSArray *a = @[ @1, @2, @3 ];
NSDictionary *d = [NSDictionary dictionaryWithObjects:@[@2,@4] forKeys:@[@1,@3]];
// NSDictionary *d = @{ @1 : @2, @3 : @4 };
}
ReplaceWithNumberLiteral¶
Since: 0.7
可以迁移到object-c的新的表达方式.
定义类: oclint-rules/rules/migration/ObjCNSNumberLiteralsRule.cpp
Example:
void aMethod()
{
NSNumber *fortyTwo = [NSNumber numberWithInt:42];
// NSNumber *fortyTwo = @42;
NSNumber *yesBool = [NSNumber numberWithBool:YES];
// NSNumber *yesBool = @YES;
}
ReplaceWithObjectSubscripting¶
Since: 0.7
可以迁移到object-c的新的表达方式.
定义类: 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];
}