[英]Type 'AnyObject' does not conform to protocol 'BooleanType'
this is my code in objective c 这是我在目标c中的代码
id locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];
if (locationValue)
{
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
[self startLocationUpdates];
}
i define locationValue as AnyObjectType and the error mentioned as the title hits at the line 我将locationValue定义为AnyObjectType,并在标题符合该行时提到错误
if(locationValue)
I am converting this to swift .. so please help.. 我将其转换为快速..所以请帮助..
The value of any condition in an if statement must have a type that conforms to the BooleanType protocol, which means that the condition must be a boolean expression. if语句中任何条件的值都必须具有符合BooleanType协议的类型,这意味着条件必须是布尔表达式。
locationValue
is not a boolean expression, you want if(locationValue != nil)
. locationValue
不是布尔表达式,你想要if(locationValue != nil)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.