Mercurial > projects > dstep
comparison dstep/foundation/NSSortDescriptor.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSSortDescriptor; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.objc.bridge.Bridge; | |
11 import dstep.objc.objc : id; | |
12 | |
13 class NSSortDescriptor : NSObject, INSCoding, INSCopying | |
14 { | |
15 mixin ObjcWrap; | |
16 | |
17 Object initWithKey (NSString key, bool ascending) | |
18 { | |
19 return invokeObjcSelf!(Object, "initWithKey:ascending:", NSString, bool)(key, ascending); | |
20 } | |
21 | |
22 this (NSString key, bool ascending) | |
23 { | |
24 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
25 id result = Bridge.invokeObjcMethod!(id, "initWithKey:ascending:", NSString, bool)(objcObject, key, ascending); | |
26 | |
27 if (result) | |
28 objcObject = ret; | |
29 | |
30 dObject = this; | |
31 } | |
32 | |
33 Object initWithKey (NSString key, bool ascending, SEL selector) | |
34 { | |
35 return invokeObjcSelf!(Object, "initWithKey:ascending:selector:", NSString, bool, SEL)(key, ascending, selector); | |
36 } | |
37 | |
38 this (NSString key, bool ascending, SEL selector) | |
39 { | |
40 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
41 id result = Bridge.invokeObjcMethod!(id, "initWithKey:ascending:selector:", NSString, bool, SEL)(objcObject, key, ascending, selector); | |
42 | |
43 if (result) | |
44 objcObject = ret; | |
45 | |
46 dObject = this; | |
47 } | |
48 | |
49 NSString key () | |
50 { | |
51 return invokeObjcSelf!(NSString, "key"); | |
52 } | |
53 | |
54 bool ascending () | |
55 { | |
56 return invokeObjcSelf!(bool, "ascending"); | |
57 } | |
58 | |
59 SEL selector () | |
60 { | |
61 return invokeObjcSelf!(SEL, "selector"); | |
62 } | |
63 | |
64 int compareObject (Object object1, Object object2) | |
65 { | |
66 return invokeObjcSelf!(int, "compareObject:toObject:", Object, Object)(object1, object2); | |
67 } | |
68 | |
69 Object reversedSortDescriptor () | |
70 { | |
71 return invokeObjcSelf!(Object, "reversedSortDescriptor"); | |
72 } | |
73 | |
74 void encodeWithCoder (NSCoder aCoder) | |
75 { | |
76 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
77 } | |
78 | |
79 Object initWithCoder (NSCoder aDecoder) | |
80 { | |
81 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
82 } | |
83 | |
84 this (NSCoder aDecoder) | |
85 { | |
86 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
87 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
88 | |
89 if (result) | |
90 objcObject = ret; | |
91 | |
92 dObject = this; | |
93 } | |
94 | |
95 Object copyWithZone (NSZone* zone) | |
96 { | |
97 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
98 } | |
99 } | |
100 | |
101 template TNSSortDescriptorSorting () | |
102 { | |
103 NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors) | |
104 { | |
105 return invokeObjcSelf!(NSArray, "sortedArrayUsingDescriptors:", NSArray)(sortDescriptors); | |
106 } | |
107 } | |
108 |