获取iPhone外壳颜色

2018-08-02  本文已影响0人  大海啊都是水

UIDevice *device = [UIDevice currentDevice];

    SEL selector = NSSelectorFromString(@"deviceInfoForKey:");

    if(![devicerespondsToSelector:selector]) {

        selector =NSSelectorFromString(@"_deviceInfoForKey:");

    }

    if([devicerespondsToSelector:selector]) {

        //消除警告"performSelector may cause a Leak because its selector is unknown"

        IMPimp = [devicemethodForSelector: selector] ;

        NSString* (*func)(id,SEL,NSString*) = (void*)imp;

        NSString*deviceColor = func(device, selector,@"DeviceColor");

        NSString*deviceEnclosureColor = func(device, selector,@"DeviceEnclosureColor");

        NSLog(@"deviceColor --> %@ \n @\"deviceEnclosureColor -->%@",deviceColor, deviceEnclosureColor);

    }

上一篇下一篇

猜你喜欢

热点阅读