forked from overtake/telegram
-
Notifications
You must be signed in to change notification settings - Fork 6
/
POPGeometry.mm
executable file
·67 lines (53 loc) · 1.45 KB
/
POPGeometry.mm
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/
#import "POPGeometry.h"
#if !TARGET_OS_IPHONE
@implementation NSValue (POP)
+ (NSValue *)valueWithCGPoint:(CGPoint)point {
return [NSValue valueWithBytes:&point objCType:@encode(CGPoint)];
}
+ (NSValue *)valueWithCGSize:(CGSize)size {
return [NSValue valueWithBytes:&size objCType:@encode(CGSize)];
}
+ (NSValue *)valueWithCGRect:(CGRect)rect {
return [NSValue valueWithBytes:&rect objCType:@encode(CGRect)];
}
+ (NSValue *)valueWithCFRange:(CFRange)range {
return [NSValue valueWithBytes:&range objCType:@encode(CFRange)];
}
+ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform
{
return [NSValue valueWithBytes:&transform objCType:@encode(CGAffineTransform)];
}
- (CGPoint)CGPointValue {
CGPoint result;
[self getValue:&result];
return result;
}
- (CGSize)CGSizeValue {
CGSize result;
[self getValue:&result];
return result;
}
- (CGRect)CGRectValue {
CGRect result;
[self getValue:&result];
return result;
}
- (CFRange)CFRangeValue {
CFRange result;
[self getValue:&result];
return result;
}
- (CGAffineTransform)CGAffineTransformValue {
CGAffineTransform result;
[self getValue:&result];
return result;
}
@end
#endif