0
我應該使用常量類型屬性而不是私有常量嗎?Swift:私有常量與常量類型屬性
在我ChatViewController.swift
文件的頂部,外類定義的,我有一個私人常數:
private let messageFontSize: CGFloat = 17
但由於此常數僅用於的ChatViewController
情況下,我應該將它的內部類定義並使其成爲一個常量類型屬性?
class ChatViewController: UIViewController {
static let messageFontSize: CGFloat = 17
// . . .
}
但後來,我不得不相當冗長訪問:
ChatViewController.messageFontSize