#[repr(C)]pub struct WebHistory { /* private fields */ }
WebHistory
only.Expand description
WebHistory is used to track pages that have been loaded by WebKit.
See also Appleโs documentation
Implementationsยง
Sourceยงimpl WebHistory
impl WebHistory
๐Deprecated
Returns a shared WebHistory instance initialized with the default history file.
Returns: A WebHistory object.
๐Deprecated
Parameter history
: The history to use for the global WebHistory.
Sourcepub unsafe fn addItems(&self, new_items: Option<&NSArray>)
๐Deprecated
pub unsafe fn addItems(&self, new_items: Option<&NSArray>)
Parameter newItems
: An array of WebHistoryItems to add to the WebHistory.
Sourcepub unsafe fn removeItems(&self, items: Option<&NSArray>)
๐Deprecated
pub unsafe fn removeItems(&self, items: Option<&NSArray>)
Parameter items
: An array of WebHistoryItems to remove from the WebHistory.
pub unsafe fn removeAllItems(&self)
Sourcepub unsafe fn orderedLastVisitedDays(&self) -> Retained<NSArray>
๐Deprecated
pub unsafe fn orderedLastVisitedDays(&self) -> Retained<NSArray>
An array of NSCalendarDates for which history items exist in the WebHistory.
An array of NSCalendarDates, each one representing a unique day that contains one or more history items, ordered from most recent to oldest.
pub unsafe fn orderedItemsLastVisitedOnDay( &self, calendar_date: Option<&NSCalendarDate>, ) -> Option<Retained<NSArray>>
Sourcepub unsafe fn itemForURL(
&self,
url: Option<&NSURL>,
) -> Option<Retained<WebHistoryItem>>
๐DeprecatedAvailable on crate feature WebHistoryItem
only.
pub unsafe fn itemForURL( &self, url: Option<&NSURL>, ) -> Option<Retained<WebHistoryItem>>
WebHistoryItem
only.Get an item for a specific URL
Parameter URL
: The URL of the history item to search for
Returns: Returns an item matching the URL
Sourcepub unsafe fn historyItemLimit(&self) -> c_int
๐Deprecated
pub unsafe fn historyItemLimit(&self) -> c_int
The maximum number of items that will be stored by the WebHistory.
Sourcepub unsafe fn setHistoryItemLimit(&self, history_item_limit: c_int)
๐Deprecated
pub unsafe fn setHistoryItemLimit(&self, history_item_limit: c_int)
Setter for historyItemLimit
.
Sourcepub unsafe fn historyAgeInDaysLimit(&self) -> c_int
๐Deprecated
pub unsafe fn historyAgeInDaysLimit(&self) -> c_int
The maximum number of days to be read from stored history.
Sourcepub unsafe fn setHistoryAgeInDaysLimit(&self, history_age_in_days_limit: c_int)
๐Deprecated
pub unsafe fn setHistoryAgeInDaysLimit(&self, history_age_in_days_limit: c_int)
Setter for historyAgeInDaysLimit
.
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.
ยง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 WebHistory
impl AsRef<AnyObject> for WebHistory
Sourceยงimpl AsRef<NSObject> for WebHistory
impl AsRef<NSObject> for WebHistory
Sourceยงimpl AsRef<WebHistory> for WebHistory
impl AsRef<WebHistory> for WebHistory
Sourceยงimpl Borrow<AnyObject> for WebHistory
impl Borrow<AnyObject> for WebHistory
Sourceยงimpl Borrow<NSObject> for WebHistory
impl Borrow<NSObject> for WebHistory
Sourceยงimpl ClassType for WebHistory
impl ClassType for WebHistory
Sourceยงconst NAME: &'static str = "WebHistory"
const NAME: &'static str = "WebHistory"
Sourceยงtype ThreadKind = <<WebHistory as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<WebHistory as ClassType>::Super as ClassType>::ThreadKind
Sourceยงimpl Debug for WebHistory
impl Debug for WebHistory
Sourceยงimpl Deref for WebHistory
impl Deref for WebHistory
Sourceยงimpl Hash for WebHistory
impl Hash for WebHistory
Sourceยงimpl Message for WebHistory
impl Message for WebHistory
Sourceยงimpl NSObjectProtocol for WebHistory
impl NSObjectProtocol for WebHistory
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