小编Var*_*tla的帖子

ARC不允许将'BOOL'(又名'bool')隐式转换为'id'

我试图将Pending/Completed的值转换为布尔值True/False值

这是代码:

RKValueTransformer *transformer = [RKBlockValueTransformer valueTransformerWithValidationBlock:^BOOL(__unsafe_unretained Class sourceClass, __unsafe_unretained Class destinationClass) {
        return ([sourceClass isSubclassOfClass:[NSNumber class]]);
    } transformationBlock:^BOOL(NSNumber *inputValue, __autoreleasing id *outputValue, __unsafe_unretained Class outputClass, NSError *__autoreleasing *error) {
        // validate the input
        RKValueTransformerTestInputValueIsKindOfClass(inputValue, [NSNumber class], error);
        if([inputValue isEqualToNumber:@(Completed)]) {
            *outputValue = YES;
        } else if([inputValue isEqualToNumber:@(Pending)]){
            *outputValue = FALSE;
        }
        return YES;
    }];
Run Code Online (Sandbox Code Playgroud)

但是,我收到错误: Implicit Conversion of 'BOOL'(aka 'bool') to 'id' is disallowed by ARC

当我尝试将outputValue设置为YES时...

这里发生了什么?

它应匹配此输出:

{ 
   “IsCompleted”: true (nullable),
   “Desc”: null (“new description” on edit) …
Run Code Online (Sandbox Code Playgroud)

objective-c ios restkit

8
推荐指数
1
解决办法
1万
查看次数

在Objective-C中,%@和%ld是什么意思?

NSString *expectedURL = [NSString stringWithFormat:@"https://%@:%ld/%@"];

什么做%@%ld什么意思呢?

string cocoa cocoa-touch objective-c nsstring

-1
推荐指数
2
解决办法
5738
查看次数

标签 统计

objective-c ×2

cocoa ×1

cocoa-touch ×1

ios ×1

nsstring ×1

restkit ×1

string ×1