【发布时间】:2014-10-20 07:31:26
【问题描述】:
我正在为 iOS 8 实现新的核心位置权限,但我想使用 Xcode 5.1.1 和 iOS 7.1 SDK 进行编译和发布。
具体来说,我想在 CLLocationManager 上调用“requestWhenInUseAuthorization”方法,该方法仅在 iOS 8 中可用。
这样做有什么风险?这是一个好习惯吗?我可以忽略“未声明的选择器”警告吗?
// Warning: Undeclared Selector
SEL requestWhenInUse = @selector(requestWhenInUseAuthorization);
if( [self.sharedLocationManager respondsToSelector:requestWhenInUse] )
{
// Warning: May cause leak because selector is unknown
[self.sharedLocationManager performSelector:requestWhenInUse];
}
[self.sharedLocationManager startUpdatingLocation];
【问题讨论】:
标签: ios core-location ios8 performselector