Class
CategorizeTransactionViewController
public final class CategorizeTransactionViewController: UINavigationController
A view controller for categorizing a transaction.
Required scopes: categories:read
, transactions:read
, and transactions:categorize
A CategorizeTransactionViewController
displays an interface for picking a category to recategorize a transaction as.
After picking a category it can also display similar transactions which the user can select to also recategorize.
Overview
Provide the id of the transaction you want to categorize and which category types you want the user to choose categories from. For example, if the transaction has a negative amount you might only want to allow the transaction to be recategorized as an expense or transfer category.
let categorizeTransactionViewController = CategorizeTransactionViewController(
tink: <#Tink#>,
transactionID: <#Transaction.ID#>,
categoryTypes: [<#Category.Kind#>]
)
Dismissing the Categorization Interface
This view controller is designed to be presented modally. To handle what should happen after the transaction has been categorized or if the user taps Cancel, you need to implement the CategorizeTransactionViewControllerDelegate
. By default the view controller will dismiss itself when the user taps Cancel but you might also want to customize what should happen when the transaction was categorized or if an error occured.
categorizeTransactionViewController.delegate = <#delegateInstance#>
present(categorizeTransactionViewController, animated: true)
extension <#Class#>: CategorizeTransactionViewControllerDelegate {
func categorizeTransactionViewController(_ controller: CategorizeTransactionViewController, didCategorize transactions: [Transaction.ID], category: Category) {
dismiss(animated: true)
}
func categorizeTransactionViewController(_ controller: CategorizeTransactionViewController, didFailWithError error: Error) {
<#Error handling#>
}
func categorizeTransactionViewControllerDidCancel(_ controller: CategorizeTransactionViewController) {
dismiss(animated: true)
}
}
Relationships
Conforms To
UINavigationController
Initializers
init(tink:transactionID:categoryTypes:categoryID:showSimilarTransactions:)
public convenience init(tink: Tink = .shared, transactionID: Transaction.ID, categoryTypes: [TinkCore.Category.Kind], categoryID: TinkCore.Category.ID? = nil, showSimilarTransactions: Bool = true)
Initializes a new view controller.
Parameters
Name | Type | Description |
---|---|---|
tink | Tink |
A configured |
transactionID | Transaction.ID |
The id of the transaction to recategorize. |
categoryTypes | [TinkCore.Category.Kind] |
The available category types to choose from. Must not be empty. |
categoryID | TinkCore.Category.ID? |
The current category id of the transaction. If |
showSimilarTransactions | Bool |
The value of this determines wether to show similar transactions or not when categorizing. Detaults to |
init(tink:transactionId:categoryTypes:categoryId:showSimilarTransactions:)
@available(*, deprecated, renamed: "init(tink:transactionID:categoryTypes:categoryID:showSimilarTransactions:)") public convenience init(tink: Tink = .shared, transactionId: Transaction.ID, categoryTypes: [TinkCore.Category.Kind], categoryId: TinkCore.Category.ID? = nil, showSimilarTransactions: Bool = true)
Properties
categorizeTransactionDelegate
var categorizeTransactionDelegate: CategorizeTransactionViewControllerDelegate?
An object that conforms to the CategorizeTransactionViewControllerDelegate
protocol.
Methods
viewDidLoad()
override public func viewDidLoad()
viewWillAppear(_:)
override public func viewWillAppear(_ animated: Bool)
viewDidAppear(_:)
override public func viewDidAppear(_ animated: Bool)