UITouches의 NSSet, UIEvent 및 NSString과 같은 일부 객체가 포함 된 NSDictionary가 있습니다.UITouchesEvent를 NSData로 인코딩 할 때 오류가 발생했습니다.
사전을 NSData로 인코딩하려고하면 문자열이 제대로 인코딩됩니다. UITouches를 인코딩하는 데 오류가 있었지만 UITouch를 인코딩 할 수 있도록 일부 코드로 클래스를 확장하는 방법을 찾았습니다. 그러나 UIEvent (실제로는 UITouchesEvent)를 인코딩 할 수 없습니다. UIEvent 또는 UIInternalEvent를 NSData로 인코딩 가능하도록 확장하려면 어떻게해야합니까?
방법은 내가 인코딩/디코딩에 사용 :
-(NSString *)stringFromDictionary:(NSDictionary *)dict{
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:dict forKey:@"dictKey"];
[archiver finishEncoding];
return [Base64 encode:data];
}
-(NSDictionary *)dictionaryFromString:(NSString *)string{
NSData *data = [[NSMutableData alloc] initWithData:[Base64 decode:string]];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
NSDictionary *myDictionary = [unarchiver decodeObjectForKey:@"dictKey"];
[unarchiver finishDecoding];
return myDictionary;
}
오류가 나는 얻을 :
-[UITouchesEvent encodeWithCoder:]: unrecognized selector sent to instance
내가 디버깅에 관한 중요한 정보를 누락하는 경우 알려 주시기 바랍니다. 감사!
감사하지만 말했듯이 이미 UITouch 인코딩 작업이 있습니다. UITouchesEvent를 사용하여이 작업을 수행하는 방법을 파악하려고합니다. – rsmoz
제 잘못, 그럼 당연히 당신은'UITouchesEvent' 클래스에 대해 그렇게해야 할 것입니다. 그러나 이것이 쉽지 않을 것이라고 생각합니다. – Pascal