我正在嘗試將檔案添加到我在 Xcode 中的代碼中。我關注了幾篇文章,這些文章建議我的標記應該與 Xcode 預覽(
uj5u.com熱心網友回復:
這實際上與串列無關,而是與標題有關。請注意,如果您洗掉 header# Examples:或僅洗掉#字符,則降價將按預期呈現。
出于某種原因,Xcode 在檔案注釋中遇到任何型別的標題后都會忽略所有文本。

(嘗試洗掉標題,看看會發生什么!)
不過,引數和回傳似乎很好。
另一方面,如果我使用jazzy鏈接答案所建議的檔案生成器,則標題和所有其他文本都會正確呈現:

沒有 Swift 徽標,因為我沒有將其下載到我的本地機器上 :) 您的formattedString函式檔案也由 正確生成jazzy,無需更改任何內容。
作為另一種選擇,AppCode 也會為您的formattedString函式和上述示例正確生成檔案。
所以我認為這只是 Xcode 中的一個怪癖/錯誤。檔案生成器仍然可以從這些注釋中正確生成檔案。
uj5u.com熱心網友回復:
這里是固定部分(去掉#,并且包裝注釋只有/** */,你不需要在每一行都用*來表示注釋本身,但它是串列項的標記)
/**
Formats date components into a sensible representation given the other date components included.
Examples:
* If two dates are in the same year, the common year will be returned.
* If two dates are in the same month and year, the common months and year will be returned.
* If two dates don't share any commonality, nil is returned.
*/
func formattedString(for components: [DateComponents]) -> String? {
getFormattedDateRange(for: components)
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/455670.html
