PTDocumentTabManager


@interface PTDocumentTabManager : NSObject

This class tracks a list of PTDocumentTabItem instances and allows manipulation of the order and selection.

  • A list of the PTDocumentTabItem instances managed by the receiver.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<PTDocumentTabItem *> *_Nonnull items;

    Swift

    var items: [PTDocumentTabItem] { get }
  • The index of the currently selected item in the items list.

    The value of this property is NSNotFound when there are no items.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger selectedIndex;

    Swift

    var selectedIndex: UInt { get set }
  • The currently selected item in the items list.

    The value of this property is nil when there are no items.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) PTDocumentTabItem *selectedItem;

    Swift

    weak var selectedItem: PTDocumentTabItem? { get set }
  • Add a PTDocumentTabItem instance to the list of items. The item is added to the end of the items list, if it is not already in the list.

    Declaration

    Objective-C

    - (void)addItem:(nonnull PTDocumentTabItem *)item;

    Swift

    func addItem(_ item: PTDocumentTabItem)

    Parameters

    item

    The PTDocumentTabItem instance to add to the list of items.

  • Insert a PTDocumentTabItem instance into the list of items at the specified index.

    Declaration

    Objective-C

    - (void)insertItem:(nonnull PTDocumentTabItem *)item atIndex:(NSUInteger)index;

    Swift

    func insertItem(_ item: PTDocumentTabItem, at index: UInt)

    Parameters

    item

    The PTDocumentTabItem instance to insert into the list of items.

    index

    The index in the items list at which to insert the item.

  • Remove the specified PTDocumentTabItem instance from the list of items.

    Declaration

    Objective-C

    - (void)removeItem:(nonnull PTDocumentTabItem *)item;

    Swift

    func removeItem(_ item: PTDocumentTabItem)

    Parameters

    item

    The PTDocumentTabItem instance to remove from the list of items.

  • Remove the PTDocumentTabItem instance from the items list at the specified index.

    Declaration

    Objective-C

    - (void)removeItemAtIndex:(NSUInteger)index;

    Swift

    func removeItem(at index: UInt)

    Parameters

    index

    The index of the item in the items list to remove.

  • Removes all the items from the items list.

    After removing all items, the selected item will be nil.

    Declaration

    Objective-C

    - (void)removeAllItems;

    Swift

    func removeAllItems()
  • Move the item located at index in the items list to newIndex.

    Declaration

    Objective-C

    - (void)moveItemAtIndex:(NSUInteger)index toIndex:(NSUInteger)newIndex;

    Swift

    func moveItem(at index: UInt, to newIndex: UInt)

    Parameters

    index

    The index of the item in the items list to move.

    newIndex

    The new index of the item in the items list.

  • Whether an item is currently being moved from one index to another.

    The value is YES during a call to the -moveItemAtIndex:toIndex: method.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=isMoving) BOOL moving;

    Swift

    var isMoving: Bool { get }
  • The default location at which the list of items is saved.

    Declaration

    Objective-C

    @property (class, nonatomic, strong, readonly) NSURL *_Nonnull savedItemsURL;

    Swift

    class var savedItemsURL: URL { get }
  • Save the current list of items to disk at the location specified by PTDocumentTabManager.savedItemsURL.

    Declaration

    Objective-C

    - (void)saveItems;

    Swift

    func saveItems()
  • Save the current list of items to disk at the specified location.

    Declaration

    Objective-C

    - (void)saveItemsToURL:(nonnull NSURL *)savedItemsURL;

    Swift

    func saveItems(to savedItemsURL: URL)

    Parameters

    savedItemsURL

    The location at which to save the list of items.

  • Save the current list of items to disk at the specified location, calling the optional completion handler when finished.

    Declaration

    Objective-C

    - (void)saveItemsToURL:(nonnull NSURL *)savedItemsURL
        withCompletionHandler:
            (void (^_Nullable)(BOOL, NSError *_Nullable))completion;

    Swift

    func saveItems(to savedItemsURL: URL) async throws -> Bool

    Parameters

    savedItemsURL

    The location at which to save the list of items.

    completion

    The completion handler to call when finished. If saving was successful, the value of the success block parameter will be YES. Otherwise if an error occurred, the value of the success block parameter will be NO and the error block parameter will contain information on why the operation failed.

  • Restore the list of items from disk at the location specified by PTDocumentTabManager.savedItemsURL.

    Declaration

    Objective-C

    - (void)restoreItems;

    Swift

    func restoreItems()
  • Restore the list of items from disk at the specified location.

    Declaration

    Objective-C

    - (void)restoreItemsFromURL:(nonnull NSURL *)savedItemsURL;

    Swift

    func restoreItems(from savedItemsURL: URL)

    Parameters

    savedItemsURL

    The location from which to restore the list of items.