Mac Developer Library

Developer

WebKit Framework Reference WebHistory Class Reference

Options
Deployment Target:

On This Page
Language:

WebHistory

Inheritance


Conforms To


Import Statement


Swift

import WebKit

Objective-C

@import WebKit;

Availability


Available in OS X v10.2 with Safari 1.0 and later.
Available in OS X v10.2.7 and later.

WebHistory objects are used to maintain the pages visited by users. Visited pages are represented by WebHistoryItem objects. You add and remove history items using the addItems: and removeItems: methods. These methods post appropriate notifications when items are added or removed so you can update the display. WebHistory organizes the WebHistoryItem objects by the day they were visited, ordered from most recent to oldest. You can request all the days that contain history items using the orderedLastVisitedDays method or request the items visited on a particular day using the orderedItemsLastVisitedOnDay: method. WebHistory objects can be loaded and saved by specifying a file URL (see loadFromURL:error:).

  • Returns a shared web history object, if one exists.

    Declaration

    Swift

    class func optionalSharedHistory() -> WebHistory!

    Objective-C

    + (WebHistory *)optionalSharedHistory

    Return Value

    A shared web history object initialized with the default web history file, or nil if one was not previously specified using the setOptionalSharedHistory: method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets the web history object to share.

    Declaration

    Swift

    class func setOptionalSharedHistory(_ history: WebHistory!)

    Objective-C

    + (void)setOptionalSharedHistory:(WebHistory *)history

    Parameters

    history

    The web history object to share.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Inserts or updates the specified items in the web history.

    Declaration

    Swift

    func addItems(_ newItems: [AnyObject]!)

    Objective-C

    - (void)addItems:(NSArray *)newItems

    Parameters

    newItems

    An array of web history items to add. If an item in the array already exists in the web history this method replaces the existing item, so that the last-visited date for the item is updated.

    Discussion

    When successful, this method posts a notification (WebHistoryItemsAddedNotification).

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Removes the specified items from the web history.

    Declaration

    Swift

    func removeItems(_ items: [AnyObject]!)

    Objective-C

    - (void)removeItems:(NSArray *)items

    Parameters

    items

    An array of web history items to remove.

    Discussion

    When successful, this method posts a notification (WebHistoryItemsRemovedNotification).

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Removes all items from the web history.

    Declaration

    Swift

    func removeAllItems()

    Objective-C

    - (void)removeAllItems

    Discussion

    When successful, this method posts a notification (WebHistoryAllItemsRemovedNotification).

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns web history items that were last visited on the specified date.

    Declaration

    Swift

    func orderedItemsLastVisitedOnDay(_ calendarDate: NSCalendarDate!) -> [AnyObject]!

    Objective-C

    - (NSArray *)orderedItemsLastVisitedOnDay:(NSCalendarDate *)calendarDate

    Parameters

    calendarDate

    The date on which the web history items were last visited.

    Return Value

    An array of web history items that were last visited on the specified date.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns all calendar days represented in the web history.

    Declaration

    Swift

    var orderedLastVisitedDays: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSArray *orderedLastVisitedDays

    Return Value

    An array of calendar days, in order from most recent to oldest. Each calendar day is associated with at least one web history item.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the web history item that corresponds to the specified web location.

    Declaration

    Swift

    func itemForURL(_ URL: NSURL!) -> WebHistoryItem!

    Objective-C

    - (WebHistoryItem *)itemForURL:(NSURL *)URL

    Parameters

    URL

    The location, as a URL, of the webpage that was visited.

    Return Value

    The web history item that represents visits to the specified URL, or nil if none was found.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Loads the contents of the specified web history file.

    Declaration

    Swift

    func loadFromURL(_ URL: NSURL!, error error: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)loadFromURL:(NSURL *)URL error:(NSError **)error

    Parameters

    URL

    The URL of the file to load. The file should have been created previously by a web history object. Note that the file’s format is private and should not be edited directly.

    error

    On output, nil if the load was successful; otherwise, error, contains details of the failure.

    Return Value

    YEStrue if successful; otherwise, NOfalse.

    Discussion

    When successful, this method posts a notification (WebHistoryLoadedNotification).

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Saves the web history to the specified file.

    Declaration

    Swift

    func saveToURL(_ URL: NSURL!, error error: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)saveToURL:(NSURL *)URL error:(NSError **)error

    Parameters

    URL

    The URL of the file to contain the web history information. The file must be user-writable, but its format is private and should not be edited directly.

    error

    On output, nil if the load was successful; otherwise, error, which contains details of the failure.

    Return Value

    YEStrue if successful; otherwise, NOfalse

    Discussion

    When successful, this method posts a notification (WebHistorySavedNotification).

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the maximum age of web history items that can be retrieved.

    Declaration

    Swift

    var historyAgeInDaysLimit: Int32

    Objective-C

    @property(nonatomic) int historyAgeInDaysLimit

    Return Value

    The maximum age, in days, of web history items that can be retrieved.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Sets the maximum age of web history items that can be retrieved.

    Declaration

    Swift

    var historyAgeInDaysLimit: Int32

    Objective-C

    @property(nonatomic) int historyAgeInDaysLimit

    Parameters

    limit

    The maximum age, in days, of retrievable web history items.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Returns the maximum number of web history items that can be stored.

    Declaration

    Swift

    var historyItemLimit: Int32

    Objective-C

    @property(nonatomic) int historyItemLimit

    Return Value

    The maximum number of web history items that can be stored.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Sets the maximum number of web history items to store.

    Declaration

    Swift

    var historyItemLimit: Int32

    Objective-C

    @property(nonatomic) int historyItemLimit

    Parameters

    limit

    The maximum number of web history items to store.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • The key for accessing the web history items stored in a notification’s user information dictionary.

    Declaration

    Swift

    let WebHistoryItemsKey: String

    Objective-C

    extern NSString *WebHistoryItemsKey;

    Constants

    • WebHistoryItemsKey

      WebHistoryItemsKey

      The key to access an array containing the added or removed web history items.

      Available in OS X v10.2 and later.

    Discussion

    This string is used as the key in the userInfo dictionary passed as the argument to the WebHistoryAllItemsRemovedNotification, WebHistoryItemsAddedNotification, and WebHistoryItemsRemovedNotification notifications.

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Posted when all history items have been removed from the web history.

    The notification object is the web history from which the history items were removed. The userInfo dictionary contains the following information:

    Key

    Value

    @”WebHistoryItemsKey”

    An NSArray object containing the removed items.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Posted when history items have been added to a web history.

    The notification object is the web history to which the items were added. The userInfo dictionary contains the following information:

    Key

    Value

    @”WebHistoryItemsKey”

    An NSArray object containing the added items.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Posted when items have been removed from the web history.

    The notification object is the web history from which the history items were removed. The userInfo dictionary contains the following information:

    Key

    Value

    @”WebHistoryItemsKey”

    An NSArray object containing the removed items.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Posted when web history items have been loaded from a URL.

    The notification object is the web history that loaded the history items. This notification does not contain a userInfo dictionary.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Posted when web history items have been saved to a URL.

    The notification object is the web history that saved the history items. This notification does not contain a userInfo dictionary.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.