2016-02-24 00:50:26.931 TravelAssistant[1900:792534] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionary0 0x7fc430404810> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key userName2.'
Try using setObject(forKey:) rather than setValue(forUndefinedKey:).
David
···
On Feb 24, 2016, at 1:12 AM, 张辉 via swift-dev <swift-dev@swift.org> wrote:
HI everybody:
I have a question about NSDictionary.
I defined a instance of NSDictionary, when I set value to this instance , it throw a exception.
code:
let userDict = NSDictionary()
userDict.setValue(self.userName.text!, forUndefinedKey: "userName2")
exception:
2016-02-24 00:50:26.931 TravelAssistant[1900:792534] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionary0 0x7fc430404810> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key userName2.'
At 2016-02-24 17:58:20, "David Smith" <david_smith@apple.com> wrote:
Hi,
Try using setObject(forKey:) rather than setValue(forUndefinedKey:).
David
On Feb 24, 2016, at 1:12 AM, 张辉 via swift-dev <swift-dev@swift.org> wrote:
HI everybody:
I have a question about NSDictionary.
I defined a instance of NSDictionary, when I set value to this instance , it throw a exception.
code:
let userDict = NSDictionary()
userDict.setValue(self.userName.text!, forUndefinedKey: "userName2")
exception:
2016-02-24 00:50:26.931 TravelAssistant[1900:792534] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionary0 0x7fc430404810> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key userName2.'
At 2016-02-24 18:06:56, "张辉" <tianya_z@163.com> wrote:
No such method
I use swift2.1
At 2016-02-24 17:58:20, "David Smith" <david_smith@apple.com> wrote:
Hi,
Try using setObject(forKey:) rather than setValue(forUndefinedKey:).
David
On Feb 24, 2016, at 1:12 AM, 张辉 via swift-dev <swift-dev@swift.org> wrote:
HI everybody:
I have a question about NSDictionary.
I defined a instance of NSDictionary, when I set value to this instance , it throw a exception.
code:
let userDict = NSDictionary()
userDict.setValue(self.userName.text!, forUndefinedKey: "userName2")
exception:
2016-02-24 00:50:26.931 TravelAssistant[1900:792534] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionary0 0x7fc430404810> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key userName2.'
At 2016-02-24 18:06:56, "张辉" <tianya_z@163.com> wrote:
No such method
I use swift2.1
At 2016-02-24 17:58:20, "David Smith" <david_smith@apple.com> wrote:
Hi,
Try using setObject(forKey:) rather than setValue(forUndefinedKey:).
David
On Feb 24, 2016, at 1:12 AM, 张辉 via swift-dev <swift-dev@swift.org> wrote:
HI everybody:
I have a question about NSDictionary.
I defined a instance of NSDictionary, when I set value to this instance , it throw a exception.
code:
let userDict = NSDictionary()
userDict.setValue(self.userName.text!, forUndefinedKey: "userName2")
exception:
2016-02-24 00:50:26.931 TravelAssistant[1900:792534] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionary0 0x7fc430404810> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key userName2.'