I hope someone can help me deal with snafu, which I have with the application I'm trying to write (or learn to write) in Swift 2.0. This previously worked in Swift 1.2, but after the necessary transformations, I constantly encounter an error;
Cannot call initializer of type "NSData" with argument list type (contenOfURL: NSURL, options: NSDataReadingOptions, error: no)
Here is my slightly truncated code that I use;
... class func fetchMinionData() -> [Minion] { let myURL = "https://myurl/test.json" let dataURL = NSURL(string: myURL) let data = NSData(contentsOfURL: dataURL!, options: NSDataReadingOptions.DataReadingMappedIfSafe, error: nil) //THIS IS THE LINE THAT THROWS THE ERROR let minionJSON = JSON(data) var minions = [Minion]() for (_ , minionDictionary) in minionJSON { minions.append(Minion(minionDetails: minionDictionary)) } return minions } ...
Please note that I plan to use SwiftyJSON to further analyze the data after loading it. I search endlessly online, but I just can't figure it out! Thanks!
source share