输入' AnyObject'不符合协议' BooleanType'

时间:2016-03-14 10:07:52

标签: ios objective-c swift

这是我在目标c中的代码

 id locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];
if (locationValue)
{
    UIApplication *app  = [UIApplication sharedApplication];
    UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid;
    bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:bgTask];
    }];
    [self startLocationUpdates];
}

我将locationValue定义为AnyObjectType,并在标题点击

时提到错误
if(locationValue)

我正在将此转换为快速..所以请帮助..

1 个答案:

答案 0 :(得分:0)

if语句中任何条件的值必须具有符合BooleanType协议的类型,这意味着条件必须是布尔表达式。

public class ViewModelsManpowerEdit { public PmcManpowerRequestViewModel ModelManpowerRequestEdit { get; set; } public List<ManpowerRequestEdit_Result> ModelManpowerRequestEditResults { get; set; } }不是布尔表达式,您需要locationValue