我想在iOS 9中使用新的LocationManager属性,我会这样写:
if ([_manager respondsToSelector:@selector(allowsBackgroundLocationUpdates)]){
_manager.allowsBackgroundLocationUpdates = YES;
}
但是如何在这里使用performSelector,以便在XCode 6和7中都进行编译,因为上面没有
allowsBackgroundLocationUpdates
,因此上面的代码会在XCode 6上产生编译错误,一种选择是使用默认的对象设置方法。[_manager performSelector:@selector(setAllowsBackgroundLocationUpdates) withObject:@{1}];
但我在intellisense中看不到选择器:
setAllowsBackgroundLocationUpdates
那么如何使用performSelector编写这样的语句?
最佳答案
也许您缺少“:”
[_manager performSelector:@selector(setAllowsBackgroundLocationUpdates:) withObject:@{1}];
关于ios - 如何使用performSelector进行对象值分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33564095/