Use class macro (#605)
This commit is contained in:
parent
0cb5450999
commit
7ee46d80e6
8 changed files with 30 additions and 37 deletions
|
|
@ -4,7 +4,7 @@ use std::ffi::CString;
|
|||
use std::mem;
|
||||
use std::os::raw::*;
|
||||
|
||||
use objc::runtime::{Class, Object};
|
||||
use objc::runtime::Object;
|
||||
|
||||
pub type id = *mut Object;
|
||||
pub const nil: id = 0 as id;
|
||||
|
|
@ -78,7 +78,7 @@ extern {
|
|||
|
||||
pub trait NSString: Sized {
|
||||
unsafe fn alloc(_: Self) -> id {
|
||||
msg_send![class("NSString"), alloc]
|
||||
msg_send![class!(NSString), alloc]
|
||||
}
|
||||
|
||||
unsafe fn initWithUTF8String_(self, c_string: *const c_char) -> id;
|
||||
|
|
@ -105,10 +105,3 @@ impl NSString for id {
|
|||
msg_send![self, UTF8String]
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn class(name: &str) -> *mut Class {
|
||||
unsafe {
|
||||
mem::transmute(Class::get(name))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue