Monitoring notifications
Notificationcenter. default. Addobserver (self, selector: #selector (libraryapi.downloadimage (_:)), Name: nsnotification. Name (rawValue: downloadimagenotification), object: nil)
Network download and main thread Refresh UI
Dispatchqueue. Global(). Async {
Let image = Self . Xiazaitupianwithurl (IMAGEURL)
Dispatchqueue. Main. Async {
Myimageview?. image = Image
Self . Persistencymanager. Baocuntupian (Image, FileName: URL (String:imageurl)!. lastpathcomponent)
}
}
File local Directory
Let path = nshomedirectory () + "/documents/\(filename)"
Enumeration
Enum Poketype {
Case Normal
Case Fire
Case Water
}
KVO
Myimgview. Addobserver (self, Forkeypath: "image", Options: [], Context: nil)
Override func Observevalue (forkeypath keypath: String?, of object: Any) , change: [Nskeyvaluechangekey: C5>any]?, context: unsafemutablerawpointer?) {
if KeyPath = = "image" {
indicator. stopanimating ()
}
}
//
Topviewcontroller
(Controllers[controllers.count-1] as! Uinavigationcontroller). Topviewcontroller as ? detailviewcontroller
Didset
var detailitem: nsdate? {
Didset {
Update the view.
Configureview ()
}
}
Swift Development Note 07