我在試圖限制泛型類型的要求,只是引用類型的問題。下面是一些示例代碼: class WeakHolder<Element: AnyObject> {
weak var element: Element?
init(element: Element) {
self.element = element
}
}
protocol Animal: class
fatal error: unexpectedly found nil while unwrapping an Optional value 有了下面的代碼: weak var previewBlurView : UIVisualEffectView?
func blurPreviewWindow() {
if (self.previewBlurView == nil) {
我有這些類: class Song {
var title : String = ""
weak var album : Album?
init() {
self.album = Album()
}
}
和 class Album {
var title : String = ""
var Songs : Array