6

iTunes can detect if my iPhone is black or white, so how can I do this in code?

I'm thinking it would be a UIDevice thing but I'm not too sure.

Victor Ronin
  • 22,758
  • 18
  • 92
  • 184
Sam Jarman
  • 7,277
  • 15
  • 55
  • 100
  • possible duplicate of [Detecting Color of iPhone/iPad/iPod touch?](http://stackoverflow.com/questions/8463212/detecting-color-of-iphone-ipad-ipod-touch) – Ortwin Gentz Oct 16 '13 at 10:35

2 Answers2

10

You can obtain color from model part number, for example:

MD381 - black iPhone 4S

MC920 - white iPhone 4S

...

To obtain model number use uidevice-extension

Addition: Alternative solution. Link your project with libLockdown.dylib.

extern id lockdown_connect();
extern id lockdown_copy_value(id, id, id);
extern void lockdown_disconnect();
extern NSString *kLockdownDeviceColorKey;
NSString* CopyDeviceColor() {
    id connection = lockdown_connect();
    NSString *color = lockdown_copy_value(connection, nil, kLockdownDeviceColorKey);
    NSLog(@"color = %@", color);
    lockdown_disconnect(connection);
    return color;
}
Community
  • 1
  • 1
Oleg Trakhman
  • 2,082
  • 1
  • 17
  • 35
  • Hi dont seem to be able to get that code to run. I did add liblockdown.dylib to Xcode project. But I cant figure out how to #import it in .m file therefore each time I run it, it crushes. Im sure I am missing something obvious. Suggestion would be much appreciated. – stringCode Sep 17 '13 at 20:48
  • 1
    @stringCode https://github.com/kennytm/iphone-private-frameworks/blob/master/liblockdown.h try this – Oleg Trakhman Sep 18 '13 at 14:53
2

iTunes detects the color of the device from the serial number I believe.

There is no way to determine the color of the device or developers.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186