Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
738 views
in Technique[技术] by (71.8m points)

ios - [__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance

I am trying to add "dateTime" to My dictionary as defined follows:

Symptom Ranking: {
    5111ef19253b4a9150000000 = 1;
    5111f029253b4add4e000000 = 1;
    5111f036253b4a123d000001 = 1;
    5111f045253b4a404f000000 = 1;
}

NSLog(@"date selected: %@", [[self.datePicker date] description])

[self.results setObject:[[self.datePicker date] description] forKey:@"dateTime"];

App crashes and I get this:

Symptom Tracker[43134:c07] -[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x7603990
2013-02-06 08:15:58.741 Symptom Tracker[43134:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x7603990'
*** First throw call stack:
(0x171b012 0x1428e7e 0x17a64bd 0x170abbc 0x170a94e 0x521e 0x143c705 0x373920 0x3738b8 0x434671 0x434bcf 0x433d38 0x3a333f 0x3a3552 0x3813aa 0x372cf8 0x2652df9 0x2652ad0 0x1690bf5 0x1690962 0x16c1bb6 0x16c0f44 0x16c0e1b 0x26517e3 0x2651668 0x37065c 0x25dd 0x2505)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your dictionary is immutable - it's an NSDictionary and not an NSMutableDictionary. Fix that, and it'll work fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...