gpt4 book ai didi

Swift 方法文档 - 不显示在自动完成中

转载 作者:搜寻专家 更新时间:2023-10-31 19:37:11 25 4
gpt4 key购买 nike

我正在按如下方式记录我的 Swift 方法:

/// Extracts the server time from the API call response.
/// - parameter response: The HTTPURLResponse from which to extract the date.
/// - returns: The 'Date' header from the response, as a `Date` object.
/// - throws: If the 'Date' header is not found, or cannot be parsed to a `Date` object.
static func extractServerTimeFromResponse(_ response: HTTPURLResponse) throws -> Date {
guard let serverTimeString = response.allHeaderFields["Date"] as? String else {
throw RGOTimeSyncHelperError.invalidServerResponse
}
let formatter = DateFormatter()
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
guard let serverTime = formatter.date(from: serverTimeString) else {
throw RGOTimeSyncHelperError.dateParsingError
}
return serverTime
}

/// Calculates the offset of the local time compared to the server time.
/// - parameter serverTime: The time from the server.
/// - returns: The amount of seconds that need to be added to the client time, to match the server time.
static func calculateOffset(serverTime: Date) -> Int {
let localTime = Date()
let offset = Calendar.current.dateComponents([.second], from: localTime, to: serverTime).second!
return offset
}

/// Add an offset in seconds to a given date.
/// - parameter date: The date to which to offset should be applied.
/// - parameter bySeconds: The offset, in seconds, that will be applied to the given date.
/// - returns: A new `Date` object, comprised of the given date, with the given offset applied.
static func offset(date: Date, bySeconds offset: Int) -> Date {
let offsetDate = Calendar.current.date(byAdding: .second, value: offset, to: date)!
return offsetDate

}

当我在任意位置按住 alt 并单击方法签名时,Xcode 会显示快速帮助面板,其中显示了我已正确输入的信息。

Help Panel

但是,当我开始键入方法签名并弹出自动完成时,它不会像 Apple 的 API 那样在自动完成框的底部显示此信息。

Autocomplete

我的注释语法哪里出错了?

最佳答案

原因是 Xcode 从单独的文档集而不是类文件本身解析弹出窗口中显示的文档。

看看这里:https://stackoverflow.com/a/43982094/1415898以获得更完整的答案。

关于Swift 方法文档 - 不显示在自动完成中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42717510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com