开发者

Get Which iOS Frameworks are Available?

开发者 https://www.devze.com 2023-03-18 05:50 出处:网络
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:

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

精彩评论

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