2015-10-28 16:31:40.478 attendance[10644:128666] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionaryI 0x7fe0e047d340> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key pstype.'
錯(cuò)誤如上,意思是該字典沒有這個(gè)鍵,異常拋出是在這馋吗,
[socket.writeData setValue:@(20152)
forKey:@"pstype"];
socket.writeData是可變的字典炭分,添加新的鍵值時(shí)需要進(jìn)行內(nèi)存分配查坪,最終如下解決
socket.writeData=[NSMutableDictionary dictionaryWithCapacity:10];
[socket.writeData setValue:@(20152)
forKey:@"pstype"];