XCode Documentation


XCode内部でtypeまたはfunctionにマウスを置いてOption-Clickingを行うと、以下に示すように、作成した関数を直接コメントで記録できます.
/// Gives the amount of change due for a given purchase.
///
/// - Parameters:
///   - amountGiven: The amount of money given
///   - purchasePrice: The price of the item being purchased
/// - Returns: An array of currency denominations that should be given as change. An empty array is returned in case of error.
/// - Note: The amount given should not be less than the purchase price. The maximum purchase price is $500
/// (larger amounts have to be handled via card or check) and the minimum purchase price is $0.01.
public func change(for amountGiven: Double, purchasePrice: Double) -> [Denomination] {
    if purchasePrice > 500 || purchasePrice < 0.01 {
        print("Purchase price must be between $0.01 and $500.")
        return []
    }
    ...