GithubHelp home page GithubHelp logo

ghvillasboas / uidevicehardware Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 128 KB

A helper class to extract more precisely the current hardware platform being used.

License: MIT License

Objective-C 100.00%

uidevicehardware's Introduction

UIDeviceHardware

A simple and easy to use helper class to extract more precisely the current hardware platform being used by the user.

It outputs three formats:

  1. Platform format: The raw platform given by the system:

     // Outputs something like: iPhone3,1, iPod2,1, iPad3,6
     [UIDeviceHardware platform]
    
  2. PlarformString format: A friendly and more readable format:

     // Outputs something like: iPhone 4, iPod Touch 2G, iPad 4 (GSM+CDMA)
     [UIDeviceHardware platformString]
    
  3. GenericDeviceType format: A smart output based on the device type and screen size

     // Outputs something like: UIDeviceHardwareGenericTypePhone35, UIDeviceHardwareGenericTypePod40
     [UIDeviceHardware genericDeviceType]
    

General considerations

  • Uses a more low level system information extractor for better performance
  • This will be a constantly revised source for new devices released by Apple (last update: 12/30/2013)
  • Supports even the simulator if needed (x86_64/Simulator/UIDeviceHardwareGenericTypeUnknown)

Live examples

if ([UIDeviceHardware genericDeviceType] == UIDeviceHardwareGenericTypePhone35 ||
	 [UIDeviceHardware genericDeviceType] == UIDeviceHardwareGenericTypePod35){
	// do some stuff targeted to 3,5" iPhone or iPod Touch screens
}
else if ([UIDeviceHardware genericDeviceType] == UIDeviceHardwareGenericTypePhone40 ||
	 [UIDeviceHardware genericDeviceType] == UIDeviceHardwareGenericTypePod40){
	// do some stuff targeted to 4.0" iPhone or iPod Touch screens
}
else if ([UIDeviceHardware genericDeviceType] == UIDeviceHardwareGenericTypePad97){
	// do some stuff targeted to the bigger 9,7" iPads
}
else if ([UIDeviceHardware genericDeviceType] == UIDeviceHardwareGenericTypePad79){
	// do some stuff targeted to the iPad Minis
}
else{
	// unknown hardware type.
	// Possibly the simulator. Should throw an exception
}

uidevicehardware's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.