Sportica   Sportica

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;
}

 

posted @ 2015-08-10 16:51  qingjoin  阅读(779)  评论(0编辑  收藏  举报
  Sportica