Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Next Page > Hide TOC

WebHistory Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/WebKit.framework
Availability
Available in Mac OS X v10.2 with Safari 1.0 and later.
Available in Mac OS X v10.2.7 and later.
Companion guide
Declared in
WebHistory.h

Overview

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, so 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:).

Tasks

Getting a Shared Instance

Adding and Removing History Items

Getting History Items

Loading and Saving History

Getting and Setting Attributes

Class Methods

optionalSharedHistory

Returns a shared history object if specified.

+ (WebHistory *)optionalSharedHistory

Discussion

Returns a shared history object, or nil if not previously specified using the setOptionalSharedHistory: method.

Availability
See Also
Declared In
WebHistory.h

setOptionalSharedHistory:

Sets the shared history object.

+ (void)setOptionalSharedHistory:(WebHistory *)history

Availability
See Also
Declared In
WebHistory.h

Instance Methods

addItems:

Inserts or updates multiple WebHistoryItem objects.

- (void)addItems:(NSArray *)newItems

Discussion

This method adds the WebHistoryItem objects specified by newItems to the receiver if they don’t already exist in the receiver. If an item in newItems already exists in the receiver then it will replace the existing item, so that the date the item was last visited is updated. Posts WebHistoryItemsAddedNotification if successful.

Availability
See Also
Declared In
WebHistory.h

historyAgeInDaysLimit

Returns the maximum number of days that history will be stored by the receiver.

- (int)historyAgeInDaysLimit

Availability
See Also
Declared In
WebHistory.h

historyItemLimit

Returns the maximum number of items that will be stored by the receiver.

- (int)historyItemLimit

Availability
See Also
Declared In
WebHistory.h

itemForURL:

Return a history item matching a url.

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

Discussion

This method returns the receiver’s WebHistoryItem object that matches the given URL, or nil if none was found.

Availability
Declared In
WebHistory.h

loadFromURL:error:

Loads contents from a file URL into the receiver.

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

Discussion

The file should have been previously created by a WebHistory object. The format of the file is private and should not be edited directly. The error argument is set to nil if the load was successful, otherwise error contains details of the failure. Returns YES if successful, NO otherwise.

Availability
See Also
Declared In
WebHistory.h

orderedItemsLastVisitedOnDay:

Returns WebHistoryItem objects last visited on a given date.

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

Discussion

The history items are ordered from most recent to oldest.

Availability
See Also
Declared In
WebHistory.h

orderedLastVisitedDays

Returns an ordered list of non-empty calendar days included in the history.

- (NSArray *)orderedLastVisitedDays

Discussion

This method returns an array of NSCalendarDate objects, each one representing a day that contains one or more history items managed by the receiver. Dates are ordered from most recent to oldest.

Availability
See Also
Declared In
WebHistory.h

removeAllItems

Removes all history items from the receiver.

- (void)removeAllItems

Discussion

Posts WebHistoryAllItemsRemovedNotification if successful.

Availability
See Also
Declared In
WebHistory.h

removeItems:

Removes multiple WebHistoryItem objects from the receiver.

- (void)removeItems:(NSArray *)items

Discussion

Posts WebHistoryItemsRemovedNotification if successful.

Availability
See Also
Declared In
WebHistory.h

saveToURL:error:

Saves the receiver to a file specified by URLits URL.

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

Discussion

The file URL specified by URL must reference a file that is writable by the user. The format of the file is private and should not be edited directly. The error argument is set to nil if the save was successful, otherwise error contains details of the failure. Returns YES if successful, NO otherwise.

Availability
See Also
Declared In
WebHistory.h

setHistoryAgeInDaysLimit:

Sets the maximum number of days that the receiver stores history.

- (void)setHistoryAgeInDaysLimit:(int)limit

Availability
See Also
Declared In
WebHistory.h

setHistoryItemLimit:

Sets the maximum number of history items that the receiver stores.

- (void)setHistoryItemLimit:(int)limit

Availability
See Also
Declared In
WebHistory.h

Constants

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

Constant

Description

WebHistoryItemsKey

An array containing the added or removed items depending on the type of notification.

Notifications

WebHistoryAllItemsRemovedNotification

Posted when all history items have been removed from the web history. The notification object is the WebHistory the history items were removed from. The userInfo dictionary contains the following information:

Key

Value

@”WebHistoryItemsKey”

An NSArray containing the removed items.

Availability
See Also
Declared In
WebHistory.h

WebHistoryItemsAddedNotification

Posted when items have been added to a web history. The notification object is the WebHistory that items were added to. The userInfo dictionary contains the following information:

Key

Value

@”WebHistoryItemsKey”

An NSArray containing the added items.

Availability
See Also
Declared In
WebHistory.h

WebHistoryItemsRemovedNotification

Posted when items have been removed from the web history. The notification object is the WebHistory that the history items were removed from. The userInfo dictionary contains the following information:

Key

Value

@”WebHistoryItemsKey”

An NSArray containing the removed items.

Availability
See Also
Declared In
WebHistory.h

WebHistoryLoadedNotification

Posted when web history items have been loaded from a URL. The notification object is the WebHistory that loaded the history items. This notification does not contain a userInfo dictionary.

Availability
See Also
Declared In
WebHistory.h

WebHistorySavedNotification

Posted when web history items have been saved to a URL. The notification object is the WebHistory that saved the history items. This notification does not contain a userInfo dictionary.

Availability
See Also
Declared In
WebHistory.h

Next Page > Hide TOC


Last updated: 2006-05-23




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice