Mac Developer Library

Developer

WebKit Framework Reference WebBackForwardList Class Reference

Options
Deployment Target:

On This Page
Language:

WebBackForwardList

A WebBackForwardList object maintains a list of visited pages used to go back and forward to the most recent page. A WebBackForwardList object maintains only the list data—it does not perform actual page loads (in other words, it does not make any client requests). If you need to perform a page load, see the loadRequest: method in WebFrame Class Reference to find out how to do this.

Items are typically inserted in a back-forward list in the order they are visited. A WebBackForwardList object also maintains the notion of the current item (which is always at index 0), the preceding item (which is at index -1), and the following item (which is at index 1). The goBack and goForward methods move the current item backward or forward by one. The goToItem: method sets the current item to the specified item. All other methods that return WebHistoryItem objects do not change the value of the current item, they just return the requested item or items. You can also limit the number of history items stored in the back-forward list using capacity.

WebBackForwardList objects also control the number of pages cached. You can turn page caching off by setting the page cache size to 0 using the pageCacheSize method, or limit the number of pages cached by passing a value greater than 0.

  • Inserts an item into the back-forward list, immediately after the current item.

    Declaration

    Swift

    func addItem(_ item: WebHistoryItem!)

    Objective-C

    - (void)addItem:(WebHistoryItem *)item

    Parameters

    item

    A web history item that represents a visited webpage. If item is nil, an NSInvalidArgumentException exception is raised.

    Discussion

    Any items following item in the back-forward list are removed. This method also removes items if the capacity of the receiver is exceeded.

    Availability

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

    Available in OS X v10.2.7 and later.

  • Moves backward one item in the back-forward list.

    Declaration

    Swift

    func goBack()

    Objective-C

    - (void)goBack

    Discussion

    This method works by changing the current item to the item that precedes it. This method raises an NSInternalInconsistencyException exception if no item precedes the current item.

    Availability

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

    Available in OS X v10.2.7 and later.

  • Moves forward one item in the back-forward list.

    Declaration

    Swift

    func goForward()

    Objective-C

    - (void)goForward

    Discussion

    This method works by changing the current item to the item that follows it. This method raises an NSInternalInconsistencyException exception if no item follows the current item.

    Availability

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

    Available in OS X v10.2.7 and later.

  • Makes the specified item in the back-forward list the current item.

    Declaration

    Swift

    func goToItem(_ item: WebHistoryItem!)

    Objective-C

    - (void)goToItem:(WebHistoryItem *)item

    Parameters

    item

    A web history item that represents a visited webpage. If item is not in the back-forward list, an NSInvalidArgumentException exception is raised.

    Availability

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

    Available in OS X v10.2.7 and later.

  • The item that precedes the current item in the back-forward list. (read-only)

    Declaration

    Swift

    var backItem: WebHistoryItem! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebHistoryItem *backItem

    Discussion

    nil if none precedes it.

    Availability

    Available in OS X v10.2 and later.

  • The number of items that precede the current item in the back-forward list. (read-only)

    Declaration

    Swift

    var backListCount: Int32 { get }

    Objective-C

    @property(nonatomic, readonly) int backListCount

    Availability

    Available in OS X v10.2 and later.

    See Also

    forwardListCount

  • Returns the items that precede the current item in the back-forward list, up to the specified number of items.

    Declaration

    Swift

    func backListWithLimit(_ limit: Int32) -> [AnyObject]!

    Objective-C

    - (NSArray *)backListWithLimit:(int)limit

    Parameters

    limit

    The greatest number of items to return.

    Return Value

    An array containing (at most) the specified number of items, or nil if no items precede the current item.

    Availability

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

    Available in OS X v10.2.7 and later.

  • Returns a Boolean value indicating whether the back-forward list contains the specified item.

    Declaration

    Swift

    func containsItem(_ item: WebHistoryItem!) -> Bool

    Objective-C

    - (BOOL)containsItem:(WebHistoryItem *)item

    Parameters

    item

    The item to find in the back-forward list.

    Return Value

    YEStrue if the specified item is in the back-forward list; otherwise, NOfalse.

    Availability

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

    Available in OS X v10.2.7 and later.

  • The current item in the back-forward list. (read-only)

    Declaration

    Swift

    var currentItem: WebHistoryItem! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebHistoryItem *currentItem

    Availability

    Available in OS X v10.2 and later.

  • Returns the item at the specified index in the back-forward list.

    Declaration

    Swift

    func itemAtIndex(_ index: Int32) -> WebHistoryItem!

    Objective-C

    - (WebHistoryItem *)itemAtIndex:(int)index

    Parameters

    index

    The index of the item to return. The position of the current item is index 0, and the position of any other item is expressed as an offset from index 0. For example, the item preceding the current item is at index -1, and the item following the current item is at index 1.

    Return Value

    The item at the specified index, or nil if index exceeds the bounds of the back-forward list (that is, if index is greater than the value returned by forwardListCount, or less than the negative form of the value returned by backListCount).

    Availability

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

    Available in OS X v10.2.7 and later.

  • The item that follows the current item in the back-forward list. (read-only)

    Declaration

    Swift

    var forwardItem: WebHistoryItem! { get }

    Objective-C

    @property(nonatomic, readonly, strong) WebHistoryItem *forwardItem

    Availability

    Available in OS X v10.2 and later.

  • The number of items that follow the current item in the back-forward list. (read-only)

    Declaration

    Swift

    var forwardListCount: Int32 { get }

    Objective-C

    @property(nonatomic, readonly) int forwardListCount

    Availability

    Available in OS X v10.2 and later.

    See Also

    backListCount

  • Returns the items that follow the current item in the back-forward list, up to the specified number of items.

    Declaration

    Swift

    func forwardListWithLimit(_ limit: Int32) -> [AnyObject]!

    Objective-C

    - (NSArray *)forwardListWithLimit:(int)limit

    Parameters

    limit

    The greatest number of items to return.

    Return Value

    An array containing (at most) the specified number of items, or nil if no items follow the current item.

    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 number of pages that the receiver can cache.

    Deprecation Statement

    Use the usesPageCache method in WebPreferences instead.

    Declaration

    Swift

    func pageCacheSize() -> Int

    Objective-C

    - (NSUInteger)pageCacheSize

    Return Value

    The maximum number of pages that can be cached.

    Availability

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

    Available in OS X v10.2.7 and later.

    Deprecated in OS X v10.4.11.

  • Sets the maximum number of pages the receiver can cache.

    Deprecation Statement

    Use the setUsesPageCache: method in WebPreferences instead.

    Declaration

    Swift

    func setPageCacheSize(_ size: Int)

    Objective-C

    - (void)setPageCacheSize:(NSUInteger)size

    Parameters

    size

    The maximum number of pages that can be cached.

    Discussion

    The default page cache size can vary depending on the computer’s configuration. Use pageCacheSize to get the current setting.

    Availability

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

    Available in OS X v10.2.7 and later.

    Deprecated in OS X v10.4.11.

  • The maximum number of items that the back-forward list can contain.

    Declaration

    Swift

    var capacity: Int32

    Objective-C

    @property(nonatomic) int capacity

    Availability

    Available in OS X v10.2 and later.