Reputation: 153
I have migrated swift project from Xcode6.4 to Xcode7 but facing this error continuously and I could not find any solution for this problem.
let nviewsDictionary : NSDictionary = NSDictionary(dictionaryLiteral: dptButton1 , "dptButton1" , txtNotes , "txtNotes")
Error: Cannot invoke initializer for NSDictionary with an argument list of type..
Upvotes: 0
Views: 651
Reputation: 13316
As @Sulthan noted, a regular Swift dictionary may be what you want, but if you need to use an NSDictionary
for some reason you can create one like this:
let nviewsDictionary = NSDictionary(objects: [dptButton1, txtNotes], forKeys: [NSString(string: "dptButton1"), NSString(string: "txtNotes")])
Per Apple's documentation for NSDictionary
, it does not look like the initializer that you were using is available.
Upvotes: 0
Reputation: 130200
I am not sure what was your original code but in Swift you probably don't want to use NSDictionary
at all.
let nviewsDictionary: [String: AnyObject] = ["dptButton1": dptButton1, "txtNotes": txtNotes]
Upvotes: 0