forked from mruegenberg/objc-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.m
More file actions
45 lines (39 loc) · 1.12 KB
/
Util.m
File metadata and controls
45 lines (39 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Util.m
// Classes
//
// Created by Marcel Ruegenberg on 13.06.11.
// Copyright 2011 Dustlab. All rights reserved.
//
#import "Util.h"
#import <UIKit/UIKit.h>
id fromNil(id origValue, id alternativeValue) {
if(origValue == nil || origValue == [NSNull null]) {
return alternativeValue;
}
return origValue;
}
NSString *fromEmptyStr(NSString *origValue, NSString *alternativeValue) {
if(origValue == nil || [origValue isEqualToString:@""]) {
return alternativeValue;
}
return origValue;
}
NSInteger majorOSVersion() {
static NSInteger osVersion = -1;
if(osVersion < 0) {
NSString *v = [[UIDevice currentDevice] systemVersion];
NSArray *c = [v componentsSeparatedByString:@"."];
if([c count] > 0) osVersion = [[c objectAtIndex:0] integerValue];
}
return osVersion;
}
NSInteger minorOSVersion() {
static NSInteger osVersion = -1;
if(osVersion < 0) {
NSString *v = [[UIDevice currentDevice] systemVersion];
NSArray *c = [v componentsSeparatedByString:@"."];
if([c count] > 1) osVersion = [[c objectAtIndex:1] integerValue];
}
return osVersion;
}