i have variable named downloadedphotourls of type [nsurl]?.
i'm trying assign results of function returns type [nsurl] (non optional).
i unwrap variable downloadedphotourls! when assigning.
i error:
cannot assign value of type '[nsurl]' value of type '[nsurl]'
i don't see how fix this.
i'm using xcode 7 beta (only because have able run on device have free account)
do { downloadedphotourls! = try nsfilemanager.defaultmanager().contentsofdirectoryaturl(directoryurl, includingpropertiesforkeys: nil, options: nil) collectionview!.reloaddata() } catch _ { downloadedphotourls = nil }
two problems there ...
force unwrapping downloadedphotourls!
you can't assign in way. if variable type optional, you're assigning in common way, if isn't optional, ...
downloadedphotourls = ... unwrapping (!, ...) used when want read / access value. not when want assign new value. did correctly on line:
downloadedphotourls = nil optionsettype in swift 2.0
you can't pass nil in options: argument. signature of methos is:
func contentsofdirectoryaturl(url: nsurl, includingpropertiesforkeys keys: [string]?, options mask: nsdirectoryenumerationoptions) throws -> [nsurl] and nsdirectoryenumerationoptions is:
struct nsdirectoryenumerationoptions : optionsettype { init(rawvalue: uint) static var skipssubdirectorydescendants: nsdirectoryenumerationoptions { } static var skipspackagedescendants: nsdirectoryenumerationoptions { } static var skipshiddenfiles: nsdirectoryenumerationoptions { } } so should like:
downloadedphotourls = try nsfilemanager.defaultmanager().contentsofdirectoryaturl(nsurl(string: "")!, includingpropertiesforkeys: nil, options:nsdirectoryenumerationoptions(rawvalue: 0)) more info optionsettype (introduced swift 2.0).
Comments
Post a Comment