Use class macro (#605)

This commit is contained in:
Josh Groves 2018-07-19 10:02:33 -06:00 committed by Francesca Frangipane
parent 0cb5450999
commit 7ee46d80e6
8 changed files with 30 additions and 37 deletions

View file

@ -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))
}
}