When I create a recursion in a didSet actually I turned out i could just put a return and program exits from didSet . But i did not find anywhere (i was searching for a long time) that i can put a return word to exit from didSet. So, is didSet works like a computed property where we can return value? Please if someone know anything i would very appreciated. Thank you.
class AppDetailController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
var app : App? {
didSet {
if app?.screenshots != nil {
return
}
if let id = app?.id {
let urlString = "https://api.letsbuildthatapp.com/appstore/appdetail?id=\(id)"
URLSession.shared.dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) in
if error != nil {
print(error)
}
do {
let json = try(JSONSerialization.jsonObject(with: data!, options: .mutableContainers ))
let appDetail = App()
appDetail.setValuesForKeys(json as! [String: AnyObject])
self.app = appDetail
} catch let error as NSError {
print(error.localizedDescription)
}
}).resume()
}
}
}