Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
The MIT License (MIT)

Copyright (c) 2013 ZY <zzymoon@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a
copy
of this software and associated documentation files (the "Software"), to
deal
in the Software without restriction, including without limitation the
rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN
THE SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
###### Add string name for hardware.
###### Add cocoapods support.

---
zzymoon@gmail.com

---

Determines exact hardware of current iOS device.

mail@boxedfolder.com
Expand Down
9 changes: 7 additions & 2 deletions UIDevice+HardwareModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <UIKit/UIKit.h>

enum UIHardwareModel
typedef enum __UIHardwareModel
{
UIHardwareModelSimulator = 1,

Expand Down Expand Up @@ -51,10 +51,15 @@ enum UIHardwareModel
UIHardwareModeliPhone5s = 30,
UIHardwareModeliPhone5sGlobal = 31

}; typedef NSUInteger UIHardwareModel;
} UIHardwareModel;

@interface UIDevice (HardwareModel)

/**
* Returns hardware name of device instance
*/
- (NSString *)hardwareName;

/**
* Returns hardware id of device instance
*/
Expand Down
106 changes: 106 additions & 0 deletions UIDevice+HardwareModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,112 @@

@implementation UIDevice (HardwareModel)

- (NSString *)hardwareName
{
NSString *name = @"Unknown";

switch ([self hardwareModel]) {
case UIHardwareModeliPad:
name = @"iPad 1G";
break;
case UIHardwareModeliPad2CDMA:
name = @"iPad 2 CDMA";
break;
case UIHardwareModeliPad2GSM:
name = @"iPad 2 GSM";
break;
case UIHardwareModeliPad2Wifi:
name = @"iPad 2 Wifi";
break;
case UIHardwareModeliPad3CDMA:
name = @"iPad 3 CDMA";
break;
case UIHardwareModeliPad3GSM:
name = @"iPad 3 GSM";
break;
case UIHardwareModeliPad3Wifi:
name = @"iPad 3 Wifi";
break;
case UIHardwareModeliPad4CDMA:
name = @"iPad 4 CDMA";
break;
case UIHardwareModeliPad4GSM:
name = @"iPad 4 GSM";
break;
case UIHardwareModeliPad4Wifi:
name = @"iPad 4 Wifi";
break;
case UIHardwareModeliPadMiniCDMA:
name = @"iPad mini CDMA";
break;
case UIHardwareModeliPadMiniGSM:
name = @"iPad mini GSM";
break;
case UIHardwareModeliPadMiniWifi:
name = @"iPad mini Wifi";
break;
case UIHardwareModeliPhone1G:
name = @"iPhone 1G";
break;
case UIHardwareModeliPhone3G:
name = @"iPhone 3G";
break;
case UIHardwareModeliPhone3GS:
name = @"iPhone 3Gs";
break;
case UIHardwareModeliPhone4:
name = @"iPhone 4";
break;
case UIHardwareModeliPhone4S:
name = @"iPhone 4s";
break;
case UIHardwareModeliPhone4Verizon:
name = @"iPhone 4 Verizon";
break;
case UIHardwareModeliPhone5:
name = @"iPhone 5";
break;
case UIHardwareModeliPhone5c:
name = @"iPhone 5c";
break;
case UIHardwareModeliPhone5cGlobal:
name = @"iPhone 5c Global";
break;
case UIHardwareModeliPhone5Global:
name = @"iPhone 5 Global";
break;
case UIHardwareModeliPhone5s:
name = @"iPhone 5s";
break;
case UIHardwareModeliPhone5sGlobal:
name = @"iPhone 5s Global";
break;
case UIHardwareModeliPodTouch1G:
name = @"iPod 1G";
break;
case UIHardwareModeliPodTouch2G:
name = @"iPod 2G";
break;
case UIHardwareModeliPodTouch3G:
name = @"iPod 3G";
break;
case UIHardwareModeliPodTouch4G:
name = @"iPod 4G";
break;
case UIHardwareModeliPodTouch5G:
name = @"iPod 5G";
break;
case UIHardwareModelSimulator:
name = @"Simulator";
break;
default:
name = @"Unknown";
break;
}

return name;
}

-(UIHardwareModel)hardwareModel
{
static UIHardwareModel _hardwareModel;
Expand Down
13 changes: 13 additions & 0 deletions UIDevice+HardwareModel.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|

s.name = "UIDevice+HardwareModel"
s.version = "1.2"
s.summary = "Check iOS hardware model"
s.homepage = "https://github.com/tecentmoon/UIDevice-HardwareModel.git"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "ZY" => "zzymoon@gmail.com" , "bfolder" => "mail@boxedfolder.com"}
s.platform = :ios
s.source = { :git => "https://github.com/tecentmoon/UIDevice-HardwareModel.git", :tag => "1.2" }
s.source_files = '*.{h,m}'

end