iOS 在不添加库的情况下 通过抽象类来获取自己想要的方法

#define SYSTEM_VERSION_MORE_THAN_BFDATA(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)



+ (NSString *)advertisingID {
    
    NSString *returnValue = nil;
    if (SYSTEM_VERSION_MORE_THAN_BFDATA(@"5.9")) {
//通过抽象类来获取 ASIdentifier 这里面的方法。得到idfa
        Class MyManager = NSClassFromString(@"ASIdentifierManager");
        if (MyManager) {
            id manager = [MyManager performSelector:@selector(sharedManager)];
            if ([manager performSelector:@selector(isAdvertisingTrackingEnabled)]) {
                returnValue = [[manager performSelector:@selector(advertisingIdentifier)]
                               performSelector:@selector(UUIDString)];
            }
        }
    }
    
    return returnValue;
}

 

你可能感兴趣的:(iOS 在不添加库的情况下 通过抽象类来获取自己想要的方法)