Skip to content

Instantly share code, notes, and snippets.

@blmacbeth
Created September 19, 2015 22:23
Show Gist options
  • Select an option

  • Save blmacbeth/139f3d88ef76dc9d7a22 to your computer and use it in GitHub Desktop.

Select an option

Save blmacbeth/139f3d88ef76dc9d7a22 to your computer and use it in GitHub Desktop.
device_info.py
# 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