objc2_foundation/
attributed_string.rs1use core::panic::{RefUnwindSafe, UnwindSafe};
2
3use objc2::rc::Retained;
4use objc2::AnyThread;
5
6use crate::*;
7
8impl UnwindSafe for NSAttributedString {}
10impl RefUnwindSafe for NSAttributedString {}
11
12impl NSAttributedString {
13 #[doc(alias = "initWithString:")]
22 #[cfg(feature = "NSDictionary")]
23 #[cfg(feature = "NSString")]
24 pub unsafe fn new_with_attributes(
25 string: &NSString,
26 attributes: &NSDictionary<NSAttributedStringKey, objc2::runtime::AnyObject>,
27 ) -> Retained<Self> {
28 unsafe { Self::initWithString_attributes(Self::alloc(), string, Some(attributes)) }
29 }
30
31 #[doc(alias = "initWithString:")]
33 #[cfg(feature = "NSString")]
34 pub fn from_nsstring(string: &NSString) -> Retained<Self> {
35 Self::initWithString(Self::alloc(), string)
36 }
37}
38
39impl NSMutableAttributedString {
40 #[doc(alias = "initWithString:")]
43 #[cfg(feature = "NSString")]
44 pub fn from_nsstring(string: &NSString) -> Retained<Self> {
45 Self::initWithString(Self::alloc(), string)
46 }
47
48 #[doc(alias = "initWithAttributedString:")]
49 pub fn from_attributed_nsstring(attributed_string: &NSAttributedString) -> Retained<Self> {
50 Self::initWithAttributedString(Self::alloc(), attributed_string)
51 }
52}