Created
September 19, 2015 22:23
-
-
Save blmacbeth/139f3d88ef76dc9d7a22 to your computer and use it in GitHub Desktop.
device_info.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| __doc__ = \ | |
| '''Provides an easy way of determining if you are on an iPad or an iPhone''' | |
| from objc_util import * | |
| from ui import get_screen_size | |
| UIDevice = ObjCClass('UIDevice') | |
| def _get_device_model(): | |
| current_device = UIDevice.currentDevice() | |
| model = current_device.model() | |
| return model | |
| class Device: | |
| @staticmethod | |
| def is_iPad(): return _get_device_model() == ns('iPad') | |
| @staticmethod | |
| def is_iPhone(): return _get_device_model() == ns('iPhone') | |
| @staticmethod | |
| def is_watch(): return UIDevice._isWatch() == ns(1) | |
| if __name__ == '__main__': | |
| print dir(UIDevice) | |
| print Device.is_iPad() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment