#[repr(C)]pub struct NSCalendar { /* private fields */ }
NSCalendar
only.Expand description
Implementations§
Source§impl NSCalendar
impl NSCalendar
pub unsafe fn currentCalendar() -> Retained<NSCalendar>
pub unsafe fn autoupdatingCurrentCalendar() -> Retained<NSCalendar>
pub unsafe fn calendarWithIdentifier( calendar_identifier_constant: &NSCalendarIdentifier, ) -> Option<Retained<NSCalendar>>
NSString
only.pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn initWithCalendarIdentifier( this: Allocated<Self>, ident: &NSCalendarIdentifier, ) -> Option<Retained<Self>>
NSString
only.pub unsafe fn calendarIdentifier(&self) -> Retained<NSCalendarIdentifier>
NSString
only.pub unsafe fn locale(&self) -> Option<Retained<NSLocale>>
NSLocale
only.Sourcepub unsafe fn setLocale(&self, locale: Option<&NSLocale>)
Available on crate feature NSLocale
only.
pub unsafe fn setLocale(&self, locale: Option<&NSLocale>)
NSLocale
only.Setter for locale
.
pub unsafe fn timeZone(&self) -> Retained<NSTimeZone>
NSTimeZone
only.Sourcepub unsafe fn setTimeZone(&self, time_zone: &NSTimeZone)
Available on crate feature NSTimeZone
only.
pub unsafe fn setTimeZone(&self, time_zone: &NSTimeZone)
NSTimeZone
only.Setter for timeZone
.
pub unsafe fn firstWeekday(&self) -> NSUInteger
Sourcepub unsafe fn setFirstWeekday(&self, first_weekday: NSUInteger)
pub unsafe fn setFirstWeekday(&self, first_weekday: NSUInteger)
Setter for firstWeekday
.
pub unsafe fn minimumDaysInFirstWeek(&self) -> NSUInteger
Sourcepub unsafe fn setMinimumDaysInFirstWeek(
&self,
minimum_days_in_first_week: NSUInteger,
)
pub unsafe fn setMinimumDaysInFirstWeek( &self, minimum_days_in_first_week: NSUInteger, )
Setter for minimumDaysInFirstWeek
.
pub unsafe fn eraSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn longEraSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn monthSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn shortMonthSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn veryShortMonthSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn standaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn shortStandaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn veryShortStandaloneMonthSymbols( &self, ) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn weekdaySymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn shortWeekdaySymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn veryShortWeekdaySymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn standaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn shortStandaloneWeekdaySymbols( &self, ) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn veryShortStandaloneWeekdaySymbols( &self, ) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn quarterSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn shortQuarterSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn standaloneQuarterSymbols(&self) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn shortStandaloneQuarterSymbols( &self, ) -> Retained<NSArray<NSString>>
NSArray
and NSString
only.pub unsafe fn AMSymbol(&self) -> Retained<NSString>
NSString
only.pub unsafe fn PMSymbol(&self) -> Retained<NSString>
NSString
only.pub unsafe fn minimumRangeOfUnit(&self, unit: NSCalendarUnit) -> NSRange
NSRange
only.pub unsafe fn maximumRangeOfUnit(&self, unit: NSCalendarUnit) -> NSRange
NSRange
only.pub unsafe fn rangeOfUnit_inUnit_forDate( &self, smaller: NSCalendarUnit, larger: NSCalendarUnit, date: &NSDate, ) -> NSRange
NSDate
and NSRange
only.pub unsafe fn ordinalityOfUnit_inUnit_forDate( &self, smaller: NSCalendarUnit, larger: NSCalendarUnit, date: &NSDate, ) -> NSUInteger
NSDate
only.pub unsafe fn rangeOfUnit_startDate_interval_forDate( &self, unit: NSCalendarUnit, datep: Option<&mut Option<Retained<NSDate>>>, tip: *mut NSTimeInterval, date: &NSDate, ) -> bool
NSDate
only.pub unsafe fn dateFromComponents( &self, comps: &NSDateComponents, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn components_fromDate( &self, unit_flags: NSCalendarUnit, date: &NSDate, ) -> Retained<NSDateComponents>
NSDate
only.pub unsafe fn dateByAddingComponents_toDate_options( &self, comps: &NSDateComponents, date: &NSDate, opts: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn components_fromDate_toDate_options( &self, unit_flags: NSCalendarUnit, starting_date: &NSDate, result_date: &NSDate, opts: NSCalendarOptions, ) -> Retained<NSDateComponents>
NSDate
only.pub unsafe fn getEra_year_month_day_fromDate( &self, era_value_pointer: *mut NSInteger, year_value_pointer: *mut NSInteger, month_value_pointer: *mut NSInteger, day_value_pointer: *mut NSInteger, date: &NSDate, )
NSDate
only.pub unsafe fn getEra_yearForWeekOfYear_weekOfYear_weekday_fromDate( &self, era_value_pointer: *mut NSInteger, year_value_pointer: *mut NSInteger, week_value_pointer: *mut NSInteger, weekday_value_pointer: *mut NSInteger, date: &NSDate, )
NSDate
only.pub unsafe fn getHour_minute_second_nanosecond_fromDate( &self, hour_value_pointer: *mut NSInteger, minute_value_pointer: *mut NSInteger, second_value_pointer: *mut NSInteger, nanosecond_value_pointer: *mut NSInteger, date: &NSDate, )
NSDate
only.pub unsafe fn component_fromDate( &self, unit: NSCalendarUnit, date: &NSDate, ) -> NSInteger
NSDate
only.pub unsafe fn dateWithEra_year_month_day_hour_minute_second_nanosecond( &self, era_value: NSInteger, year_value: NSInteger, month_value: NSInteger, day_value: NSInteger, hour_value: NSInteger, minute_value: NSInteger, second_value: NSInteger, nanosecond_value: NSInteger, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn dateWithEra_yearForWeekOfYear_weekOfYear_weekday_hour_minute_second_nanosecond( &self, era_value: NSInteger, year_value: NSInteger, week_value: NSInteger, weekday_value: NSInteger, hour_value: NSInteger, minute_value: NSInteger, second_value: NSInteger, nanosecond_value: NSInteger, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn startOfDayForDate(&self, date: &NSDate) -> Retained<NSDate>
NSDate
only.pub unsafe fn componentsInTimeZone_fromDate( &self, timezone: &NSTimeZone, date: &NSDate, ) -> Retained<NSDateComponents>
NSDate
and NSTimeZone
only.pub unsafe fn compareDate_toDate_toUnitGranularity( &self, date1: &NSDate, date2: &NSDate, unit: NSCalendarUnit, ) -> NSComparisonResult
NSDate
and NSObjCRuntime
only.pub unsafe fn isDate_equalToDate_toUnitGranularity( &self, date1: &NSDate, date2: &NSDate, unit: NSCalendarUnit, ) -> bool
NSDate
only.pub unsafe fn isDate_inSameDayAsDate( &self, date1: &NSDate, date2: &NSDate, ) -> bool
NSDate
only.pub unsafe fn isDateInToday(&self, date: &NSDate) -> bool
NSDate
only.pub unsafe fn isDateInYesterday(&self, date: &NSDate) -> bool
NSDate
only.pub unsafe fn isDateInTomorrow(&self, date: &NSDate) -> bool
NSDate
only.pub unsafe fn isDateInWeekend(&self, date: &NSDate) -> bool
NSDate
only.pub unsafe fn rangeOfWeekendStartDate_interval_containingDate( &self, datep: Option<&mut Option<Retained<NSDate>>>, tip: *mut NSTimeInterval, date: &NSDate, ) -> bool
NSDate
only.pub unsafe fn nextWeekendStartDate_interval_options_afterDate( &self, datep: Option<&mut Option<Retained<NSDate>>>, tip: *mut NSTimeInterval, options: NSCalendarOptions, date: &NSDate, ) -> bool
NSDate
only.pub unsafe fn components_fromDateComponents_toDateComponents_options( &self, unit_flags: NSCalendarUnit, starting_date_comp: &NSDateComponents, result_date_comp: &NSDateComponents, options: NSCalendarOptions, ) -> Retained<NSDateComponents>
pub unsafe fn dateByAddingUnit_value_toDate_options( &self, unit: NSCalendarUnit, value: NSInteger, date: &NSDate, options: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn enumerateDatesStartingAfterDate_matchingComponents_options_usingBlock( &self, start: &NSDate, comps: &NSDateComponents, opts: NSCalendarOptions, block: &DynBlock<dyn Fn(*mut NSDate, Bool, NonNull<Bool>) + '_>, )
NSDate
and block2
only.pub unsafe fn nextDateAfterDate_matchingComponents_options( &self, date: &NSDate, comps: &NSDateComponents, options: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn nextDateAfterDate_matchingUnit_value_options( &self, date: &NSDate, unit: NSCalendarUnit, value: NSInteger, options: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn nextDateAfterDate_matchingHour_minute_second_options( &self, date: &NSDate, hour_value: NSInteger, minute_value: NSInteger, second_value: NSInteger, options: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn dateBySettingUnit_value_ofDate_options( &self, unit: NSCalendarUnit, v: NSInteger, date: &NSDate, opts: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn dateBySettingHour_minute_second_ofDate_options( &self, h: NSInteger, m: NSInteger, s: NSInteger, date: &NSDate, opts: NSCalendarOptions, ) -> Option<Retained<NSDate>>
NSDate
only.pub unsafe fn date_matchesComponents( &self, date: &NSDate, components: &NSDateComponents, ) -> bool
NSDate
only.Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for NSCalendar
impl AsRef<AnyObject> for NSCalendar
Source§impl AsRef<NSCalendar> for NSCalendar
impl AsRef<NSCalendar> for NSCalendar
Source§impl AsRef<NSObject> for NSCalendar
impl AsRef<NSObject> for NSCalendar
Source§impl Borrow<AnyObject> for NSCalendar
impl Borrow<AnyObject> for NSCalendar
Source§impl Borrow<NSObject> for NSCalendar
impl Borrow<NSObject> for NSCalendar
Source§impl ClassType for NSCalendar
impl ClassType for NSCalendar
Source§const NAME: &'static str = "NSCalendar"
const NAME: &'static str = "NSCalendar"
Source§type ThreadKind = <<NSCalendar as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSCalendar as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for NSCalendar
Available on crate feature NSObject
only.
impl CopyingHelper for NSCalendar
NSObject
only.Source§type Result = NSCalendar
type Result = NSCalendar
Self
if the type has no
immutable counterpart. Read moreSource§impl Debug for NSCalendar
impl Debug for NSCalendar
Source§impl Deref for NSCalendar
impl Deref for NSCalendar
Source§impl Hash for NSCalendar
impl Hash for NSCalendar
Source§impl Message for NSCalendar
impl Message for NSCalendar
Source§impl NSCoding for NSCalendar
impl NSCoding for NSCalendar
Source§unsafe fn encodeWithCoder(&self, coder: &NSCoder)
unsafe fn encodeWithCoder(&self, coder: &NSCoder)
NSObject
and NSCoder
only.Source§impl NSCopying for NSCalendar
impl NSCopying for NSCalendar
Source§impl NSObjectProtocol for NSCalendar
impl NSObjectProtocol for NSCalendar
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref