use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use objc::runtime::Object;
use objc::{class, msg_send, sel, sel_impl};
use objc_id::Id;
use crate::foundation::{id, NSString};
#[derive(Debug)]
pub struct NSMutableDictionary(pub Id<Object>);
impl Default for NSMutableDictionary {
fn default() -> Self {
NSMutableDictionary::new()
}
}
impl NSMutableDictionary {
pub fn new() -> Self {
NSMutableDictionary(unsafe { Id::from_ptr(msg_send![class!(NSMutableDictionary), new]) })
}
pub fn insert(&mut self, key: NSString, object: id) {
unsafe {
let _: () = msg_send![&*self.0, setObject:object forKey:&*key];
}
}
pub fn into_inner(mut self) -> id {
&mut *self.0
}
}
impl Deref for NSMutableDictionary {
type Target = Object;
fn deref(&self) -> &Object {
&*self.0
}
}
impl DerefMut for NSMutableDictionary {
fn deref_mut(&mut self) -> &mut Object {
&mut *self.0
}
}