let contactDict: NSDictionary = ["identifier":singleContact.identifier,"firstName":singleContact.firstName, "lastName":singleContact.lastName,"email":singleContact.email,"phone":singleContact.phone,"contactImage":singleContact.contactImage]
我的表达式是模糊的,没有更多的上下文错误。我尝试通过以下表达式解析它
let contactDict: NSDictionary: [NSObject: AnyObject]
但是仍然显示连续语句必须用;
分隔的错误请帮我纠正此错误。
答案 0 :(得分:0)
由于有两个冒号,你得到连续的陈述错误......
let contactDict: NSDictionary: [NSObject: AnyObject]
应该像......
let contacts: [NSObject: AnyObject] = ...
...或
let contacts: Dictionary<NSObject, AnyObject> = ...
请注意,当您使用单词Dictionary
或NSDictionary
时,格式不会使用括号:Dictionary<key, value>
。如果您仍然出现模糊错误,请尝试使用空字典文字创建它,然后附加:
var contacts: Dictionary<NSObject, AnyObject> = [:]
contacts[key] = value
...或
var contacts: Dictionary<NSObject, AnyObject> = [:]
contacts += [...]