---
title: WebHistory
framework: webkit
role: symbol
role_heading: Class
path: webkit/webhistory
---

# WebHistory

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 orderedItemsLastVisited(onDay:) method. WebHistory objects can be loaded and saved by specifying a file URL (see load(from:)).

## Declaration

```swift
class WebHistory
```

## Topics

### Accessing Shared History Objects

- [optionalShared()](webkit/webhistory/optionalshared().md)
- [setOptionalShared(_:)](webkit/webhistory/setoptionalshared(_:).md)

### Adding and Removing History Items

- [addItems(_:)](webkit/webhistory/additems(_:).md)
- [removeItems(_:)](webkit/webhistory/removeitems(_:).md)
- [removeAllItems()](webkit/webhistory/removeallitems().md)

### Getting Web History Items

- [orderedItemsLastVisited(onDay:)](webkit/webhistory/ordereditemslastvisited(onday:).md)
- [orderedLastVisitedDays](webkit/webhistory/orderedlastvisiteddays.md)
- [item(for:)](webkit/webhistory/item(for:).md)

### Loading and Saving History Information

- [load(from:)](webkit/webhistory/load(from:).md)
- [save(to:)](webkit/webhistory/save(to:).md)

### Getting and Setting Attributes

- [historyAgeInDaysLimit](webkit/webhistory/historyageindayslimit.md)
- [historyItemLimit](webkit/webhistory/historyitemlimit.md)

### Constants

- [Web History Dictionary Keys](webkit/web-history-dictionary-keys.md)

### Notifications

- [WebHistoryAllItemsRemoved](foundation/nsnotification/name-swift.struct/webhistoryallitemsremoved.md)
- [WebHistoryItemChanged](foundation/nsnotification/name-swift.struct/webhistoryitemchanged.md)
- [WebHistoryItemsAdded](foundation/nsnotification/name-swift.struct/webhistoryitemsadded.md)
- [WebHistoryItemsRemoved](foundation/nsnotification/name-swift.struct/webhistoryitemsremoved.md)
- [WebHistoryLoaded](foundation/nsnotification/name-swift.struct/webhistoryloaded.md)
- [WebHistorySaved](foundation/nsnotification/name-swift.struct/webhistorysaved.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Accessing Previous Webpages (Legacy)

- [WebBackForwardList](webkit/webbackforwardlist.md)
- [WebHistoryItem](webkit/webhistoryitem.md)
