Skip to content

Commit

Permalink
Release 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebyddd committed Aug 26, 2015
1 parent 50d00f3 commit 55b7539
Show file tree
Hide file tree
Showing 20 changed files with 187 additions and 185 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SDVersion supports both iOS and Mac OS. Browse through the implementation of eac
NSLog(@"You own an iPad Air 2 🌀!");

// Check for device screen size
if ([SDVersion deviceSize] == iPhone4inch)
if ([SDVersion deviceSize] == Screen4inch)
NSLog(@"Your screen is 4 inches");

// Get device name
Expand Down Expand Up @@ -96,13 +96,20 @@ CocoaPods is a dependency manager for Objective-C, which automates and simplifie
iPadAir2
iPadMini3

iPodTouch1Gen
iPodTouch2Gen
iPodTouch3Gen
iPodTouch4Gen
iPodTouch5Gen
iPodTouch6Gen

Simulator

### Targetable screen sizes
iPhone3Dot5inch
iPhone4inch
iPhone4Dot7inch
iPhone5Dot5inch
Screen3Dot5inch
Screen4inch
Screen4Dot7inch
Screen5Dot5inch

### Available iOS Version Finder methods
iOSVersionEqualTo(@"v") //E.g: iOSVersionEqualTo(@"8.4.1")
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions SDVersion-Demo/SDVersion/SDVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define SDVersion_h

#if (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
#import "SDiPhoneVersion.h"
#define SDVersion SDiPhoneVersion
#import "SDiOSVersion.h"
#define SDVersion SDiOSVersion
#else
#import "SDMacVersion.h"
#define SDVersion SDMacVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// SDiPhoneVersion.h
// SDiOSVersion.h
// SDVersion
//
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
Expand All @@ -10,10 +10,10 @@
#import <UIKit/UIKit.h>
#import <sys/utsname.h>

#define stringFromDeviceVersion(v) [@{@(3):@"iPhone 4", @(4):@"iPhone 4S", @(5):@"iPhone 5", @(6):@"iPhone 5C", @(7):@"iPhone 5S", @(8):@"iPhone 6", @(9): @"iPhone 6 Plus", @(10):@"iPad 1", @(11):@"iPad 2", @(12):@"iPad Mini", @(13):@"iPad 3", @(14):@"iPad 4", @(15):@"iPad Air", @(16):@"iPad Mini 2", @(17):@"iPad Air 2", @(18):@"iPad Mini 3", @(0):@"Simulator"} objectForKey:[NSNumber numberWithInteger:v]]
#define stringFromDeviceVersion(v) [@{@(3):@"iPhone 4", @(4):@"iPhone 4S", @(5):@"iPhone 5", @(6):@"iPhone 5C", @(7):@"iPhone 5S", @(8):@"iPhone 6", @(9): @"iPhone 6 Plus", @(10):@"iPad 1", @(11):@"iPad 2", @(12):@"iPad Mini", @(13):@"iPad 3", @(14):@"iPad 4", @(15):@"iPad Air", @(16):@"iPad Mini 2", @(17):@"iPad Air 2", @(18):@"iPad Mini 3", @(19):@"iPod Touch 1st Gen", @(20):@"iPod Touch 2nd Gen", @(21):@"iPod Touch 3rd Gen", @(22):@"iPod Touch 4th Gen", @(23):@"iPod Touch 5th Gen", @(24):@"iPod Touch 6th Gen", @(0):@"Simulator"} objectForKey:[NSNumber numberWithInteger:v]]
#define stringFromDeviceSize(v) [@{@(0):@"Unknown Size", @(1):@"3.5 inch", @(2):@"4 inch", @(3):@"4.7 inch", @(4):@"5.5 inch"} objectForKey:[NSNumber numberWithInteger:v]]

@interface SDiPhoneVersion : NSObject
@interface SDiOSVersion : NSObject

#define iOSVersionEqualTo(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define iOSVersionGreaterThan(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
Expand All @@ -22,32 +22,40 @@
#define iOSVersionLessThanOrEqualTo(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

typedef NS_ENUM(NSInteger, DeviceVersion){
iPhone4 = 3,
iPhone4S = 4,
iPhone5 = 5,
iPhone5C = 6,
iPhone5S = 7,
iPhone6 = 8,
iPhone6Plus = 9,

iPad1 = 10,
iPad2 = 11,
iPadMini = 12,
iPad3 = 13,
iPad4 = 14,
iPadAir = 15,
iPadMini2 = 16,
iPadAir2 = 17,
iPadMini3 = 18,
Simulator = 0
iPhone4 = 3,
iPhone4S = 4,
iPhone5 = 5,
iPhone5C = 6,
iPhone5S = 7,
iPhone6 = 8,
iPhone6Plus = 9,

iPad1 = 10,
iPad2 = 11,
iPadMini = 12,
iPad3 = 13,
iPad4 = 14,
iPadAir = 15,
iPadMini2 = 16,
iPadAir2 = 17,
iPadMini3 = 18,

iPodTouch1Gen = 19,
iPodTouch2Gen = 20,
iPodTouch3Gen = 21,
iPodTouch4Gen = 22,
iPodTouch5Gen = 23,
iPodTouch6Gen = 24,

Simulator = 0
};

typedef NS_ENUM(NSInteger, DeviceSize){
UnknownSize = 0,
iPhone3Dot5inch = 1,
iPhone4inch = 2,
iPhone4Dot7inch = 3,
iPhone5Dot5inch = 4
UnknownSize = 0,
Screen3Dot5inch = 1,
Screen4inch = 2,
Screen4Dot7inch = 3,
Screen5Dot5inch = 4
};

+(DeviceVersion)deviceVersion;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// SDiPhoneVersion.m
// SDiOSVersion.m
// SDVersion
//
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import "SDiPhoneVersion.h"
#import "SDiOSVersion.h"

@implementation SDiPhoneVersion
@implementation SDiOSVersion

+(NSDictionary*)deviceNamesByCode {

Expand Down Expand Up @@ -61,7 +61,14 @@ +(NSDictionary*)deviceNamesByCode {
@"iPad5,3" :[NSNumber numberWithInteger:iPadAir2],
@"iPad5,4" :[NSNumber numberWithInteger:iPadAir2],


//iPods
@"iPod1,1" :[NSNumber numberWithInteger:iPodTouch1Gen],
@"iPod2,1" :[NSNumber numberWithInteger:iPodTouch2Gen],
@"iPod3,1" :[NSNumber numberWithInteger:iPodTouch3Gen],
@"iPod4,1" :[NSNumber numberWithInteger:iPodTouch4Gen],
@"iPod5,1" :[NSNumber numberWithInteger:iPodTouch5Gen],
@"iPod7,1" :[NSNumber numberWithInteger:iPodTouch6Gen]

};
});

Expand All @@ -82,7 +89,7 @@ +(DeviceVersion)deviceVersion {
+(DeviceSize)deviceSize {

CGFloat screenHeight = 0;

if (iOSVersionGreaterThan(@"8")) {

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
Expand All @@ -95,14 +102,14 @@ +(DeviceSize)deviceSize {
screenHeight = [[UIScreen mainScreen] bounds].size.height;

if (screenHeight == 480)
return iPhone3Dot5inch;
return Screen3Dot5inch;
else if(screenHeight == 568)
return iPhone4inch;
return Screen4inch;
else if(screenHeight == 667){
if ([UIScreen mainScreen].scale > 2.9) return iPhone5Dot5inch;
return iPhone4Dot7inch;
if ([UIScreen mainScreen].scale > 2.9) return Screen5Dot5inch;
return Screen4Dot7inch;
}else if(screenHeight == 736)
return iPhone5Dot5inch;
return Screen5Dot5inch;
else
return UnknownSize;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// AppDelegate.h
// SDiPhoneVersion
// SDiOSVersion
//
// Created by Sebastian Dobrincu on 10/09/14.
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// AppDelegate.m
// SDiPhoneVersion
// SDiOSVersion
//
// Created by Sebastian Dobrincu on 10/09/14.
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import "AppDelegate.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// ViewController.h
// SDiPhoneVersion
// SDiOSVersion
//
// Created by Sebastian Dobrincu on 10/09/14.
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// ViewController.m
// SDiPhoneVersion
// SDiOSVersion
//
// Created by Sebastian Dobrincu on 10/09/14.
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import "ViewController.h"
Expand All @@ -15,25 +14,27 @@ - (void)viewDidLoad {
[super viewDidLoad];

// Get device name as NSString
self.iphoneVersionLabel.text = [self.iphoneVersionLabel.text stringByAppendingString:stringFromDeviceVersion([SDVersion deviceVersion])];
self.iphoneVersionLabel.text = [self.iphoneVersionLabel.text stringByAppendingString:stringFromDeviceVersion([SDiOSVersion deviceVersion])];

// Get device size using string conversion
self.iphoneSizeLabel.text = [self.iphoneSizeLabel.text stringByAppendingString:[NSString stringWithFormat:@"%@", stringFromDeviceSize([SDVersion deviceSize])]];
self.iphoneSizeLabel.text = [self.iphoneSizeLabel.text stringByAppendingString:[NSString stringWithFormat:@"%@", stringFromDeviceSize([SDiOSVersion deviceSize])]];

// Check for device model
if ([SDVersion deviceVersion] == iPhone6)
if ([SDiOSVersion deviceVersion] == iPhone6)
NSLog(@"You got the iPhone 6. Nice!");
else if ([SDVersion deviceVersion] == iPhone5S)
else if ([SDiOSVersion deviceVersion] == iPhone5S)
NSLog(@"You got the iPhone 5S. Good device!");
else if ([SDiOSVersion deviceVersion] == iPodTouch6Gen)
NSLog(@"The latest iPod Touch. Cool! ❄️")

// Check for device screen size
if ([SDVersion deviceSize] == iPhone3Dot5inch)
if ([SDiOSVersion deviceSize] == Screen3Dot5inch)
NSLog(@"Your screen is 3.5 inches");
else if ([SDVersion deviceSize] == iPhone4inch)
else if ([SDiOSVersion deviceSize] == Screen4inch)
NSLog(@"Your screen size is 4 inches");
else if([SDVersion deviceSize] == iPhone4Dot7inch)
else if([SDiOSVersion deviceSize] == Screen4Dot7inch)
NSLog(@"Your screen size is 4.7 inches");
else if([SDVersion deviceSize] == iPhone5Dot5inch)
else if([SDiOSVersion deviceSize] == Screen5Dot5inch)
NSLog(@"Your screen size is 5.5 inches");

//Check for iOS Version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// main.m
// SDiPhoneVersion
// SDiOSVersion
//
// Created by Sebastian Dobrincu on 10/09/14.
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
//
// SDiPhoneVersionTests.m
// SDiPhoneVersionTests
// SDiOSVersionTests.m
// SDiOSVersionTests
//
// Created by Sebastian Dobrincu on 10/09/14.
// Copyright (c) 2014 Sebastian Dobrincu. All rights reserved.
// Copyright (c) 2015 Sebastian Dobrincu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>

@interface SDiPhoneVersionTests : XCTestCase
@interface SDiOSVersionTests : XCTestCase

@end

@implementation SDiPhoneVersionTests
@implementation SDiOSVersionTests

- (void)setUp {
[super setUp];
Expand Down
4 changes: 2 additions & 2 deletions SDVersion.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |s|
#

s.name = "SDVersion"
s.version = "2.1.4"
s.version = "2.2"
s.summary = "Objective-C library for detecting running device model and screen size."
s.homepage = "https://github.com/sebyddd/SDVersion"
s.screenshots = "https://dl.dropboxusercontent.com/s/5ddx58dsex25x57/sdversion-logo.png?dl=0"
Expand All @@ -28,7 +28,7 @@ Pod::Spec.new do |s|
s.platform = :osx
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.ios.source_files = "SDVersion/SDiPhoneVersion/*.{h,m}"
s.ios.source_files = "SDVersion/SDiOSVersion/*.{h,m}"
s.osx.source_files = "SDVersion/SDMacVersion/*.{h,m}"
s.source = { :git => 'https://github.com/sebyddd/SDVersion.git', :tag => "#{s.version}" }
s.source_files = "SDVersion/*.{h,m}"
Expand Down

0 comments on commit 55b7539

Please sign in to comment.