commit | author | age
|
3eceb5
|
1 |
// |
W |
2 |
// VKUtil.h |
|
3 |
// |
|
4 |
// Copyright (c) 2014 VK.com |
|
5 |
// |
|
6 |
// Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
7 |
// this software and associated documentation files (the "Software"), to deal in |
|
8 |
// the Software without restriction, including without limitation the rights to |
|
9 |
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
10 |
// the Software, and to permit persons to whom the Software is furnished to do so, |
|
11 |
// subject to the following conditions: |
|
12 |
// |
|
13 |
// The above copyright notice and this permission notice shall be included in all |
|
14 |
// copies or substantial portions of the Software. |
|
15 |
// |
|
16 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
18 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
19 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
20 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
21 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
22 |
|
|
23 |
#define VK_COLOR [UIColor colorWithRed:85.0f / 255 green:133.0f / 255 blue:188.0f / 255 alpha:1.0f] |
|
24 |
#define VK_IS_DEVICE_IPAD (UIUserInterfaceIdiomPad == [[UIDevice currentDevice] userInterfaceIdiom]) |
|
25 |
|
|
26 |
#import <UIKit/UIKit.h> |
|
27 |
|
|
28 |
/** |
|
29 |
Various functions |
|
30 |
*/ |
|
31 |
@interface VKUtil : NSObject |
|
32 |
/** |
|
33 |
Breaks key=value string to dictionary |
|
34 |
@param queryString string with key=value pairs joined by & symbol |
|
35 |
@return Dictionary of parameters |
|
36 |
*/ |
|
37 |
+ (NSDictionary *)explodeQueryString:(NSString *)queryString; |
|
38 |
|
|
39 |
+ (NSString *)generateGUID; |
|
40 |
|
|
41 |
+ (NSNumber *)parseNumberString:(id)number; |
|
42 |
|
|
43 |
+ (UIColor *)colorWithRGB:(NSInteger)rgb; |
|
44 |
|
|
45 |
+ (NSString *)queryStringFromParams:(NSDictionary *)params; |
|
46 |
|
|
47 |
/** |
|
48 |
* Indicates that the current device system version at least conforms the argument version |
|
49 |
*/ |
|
50 |
+ (BOOL) isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion) version; |
|
51 |
|
|
52 |
/** |
|
53 |
* Returns true if the current device uses iOS 7 or greater |
|
54 |
*/ |
|
55 |
+ (BOOL) isOperatingSystemAtLeastIOS7; |
|
56 |
|
|
57 |
/** |
|
58 |
* Returns true if the current device uses iOS 8 or greater |
|
59 |
*/ |
|
60 |
+ (BOOL) isOperatingSystemAtLeastIOS8; |
|
61 |
@end |
|
62 |
|
|
63 |
|
|
64 |
@interface UIImage (RoundedImage) |
|
65 |
- (UIImage *)vks_roundCornersImage:(CGFloat)cornerRadius resultSize:(CGSize)imageSize; |
|
66 |
@end |
|
67 |
|
|
68 |
static inline NSNumber *VK_ENSURE_NUM(id obj) { |
|
69 |
return [obj isKindOfClass:[NSNumber class]] ? obj : nil; |
|
70 |
} |
|
71 |
|
|
72 |
static inline NSDictionary *VK_ENSURE_DICT(id data) { |
6c0388
|
73 |
return [data isKindOfClass:[NSDictionary class]] ? data : nil; |
3eceb5
|
74 |
} |
W |
75 |
|
|
76 |
static inline NSArray *VK_ENSURE_ARRAY(id data) { |
6c0388
|
77 |
return [data isKindOfClass:[NSArray class]] ? data : nil; |
3eceb5
|
78 |
} |
W |
79 |
|
6c0388
|
80 |
static inline id VK_ENSURE(id data, Class objectClass) { |
W |
81 |
return [data isKindOfClass:objectClass] ? data : nil; |
|
82 |
} |