开发者

Get Which iOS Frameworks are Available?

I'm writing a static library for iOS. I want to prog开发者_运维百科rammatically figure out if CoreLocation is added to the project, is there any way to do that?


Probably something like:

if(NSClassFromString(@"CLLocationManager"))
{
    NSLog(@"CoreLocation is available");
}

Would do it. NSClassFromString takes an NSString and checks whether there's a class of that name currently available in the runtime. If so then it returns the Class object, otherwise it returns nil. The if statement there effectively compares to nil.

So, the logic you're applying is "does a class called CLLocationManager currently exist?", which is a proxy for checking that CoreLocation is loaded because it's one of the fundamental classes to that framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜