XCode Documentation

j00hyun·2022년 3월 4일

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 []
IOS Developer

0개의 댓글