Skip to content

Commit 15f9ebe

Browse files
committed
Use the new class! macro added to objc
1 parent 7700563 commit 15f9ebe

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ exclude = [".gitignore"]
1313

1414
[dependencies]
1515
block = "0.1"
16-
objc = "0.2"
16+
objc = "0.2.2"
1717
objc_id = "0.1"

src/array.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ object_impl!(NSArray<T, O>);
167167

168168
impl<T, O> INSObject for NSArray<T, O> where T: INSObject, O: Ownership {
169169
fn class() -> &'static Class {
170-
Class::get("NSArray").unwrap()
170+
class!(NSArray)
171171
}
172172
}
173173

@@ -282,7 +282,7 @@ object_impl!(NSMutableArray<T, O>);
282282

283283
impl<T, O> INSObject for NSMutableArray<T, O> where T: INSObject, O: Ownership {
284284
fn class() -> &'static Class {
285-
Class::get("NSMutableArray").unwrap()
285+
class!(NSMutableArray)
286286
}
287287
}
288288

src/dictionary.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ object_impl!(NSDictionary<K, V>);
122122

123123
impl<K, V> INSObject for NSDictionary<K, V> where K: INSObject, V: INSObject {
124124
fn class() -> &'static Class {
125-
Class::get("NSDictionary").unwrap()
125+
class!(NSDictionary)
126126
}
127127
}
128128

src/macros.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ macro_rules! object_struct {
99

1010
impl $crate::INSObject for $name {
1111
fn class() -> &'static ::objc::runtime::Class {
12-
let name = stringify!($name);
13-
match ::objc::runtime::Class::get(name) {
14-
Some(cls) => cls,
15-
None => panic!("Class {} not found", name),
16-
}
12+
class!($name)
1713
}
1814
}
1915

src/value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object_impl!(NSValue<T>);
5656

5757
impl<T> INSObject for NSValue<T> where T: Any {
5858
fn class() -> &'static Class {
59-
Class::get("NSValue").unwrap()
59+
class!(NSValue)
6060
}
6161
}
6262

0 commit comments

Comments
 (0)