我将一个对象(NSObject)打包到(NSData),然后使用(NSASCIIStringEncoding)对其进行编码,以便使用以下代码将其发送到SQLite数据库:
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:canvasView.trazoYorch];
//convert NSData object to plain text for sending it to DB
NSData *data2 = [[NSString stringWithFormat:@"%@",data] dataUsingEncoding:NSASCIIStringEncoding];
NSString *dataStr = [[NSString alloc] initWithData:data2 encoding:NSASCIIStringEncoding];
一切正常,但是当我想对NSData进行反向过程NSString时,我得到了不同的结果,这是我的逆过程代码
NSString *FirmaString = [self traerFirmadeBD]; //returns the string content of DB
NSData *data2 = [FirmaString dataUsingEncoding:NSASCIIStringEncoding];
FirmaYorch *firmaCompleta = [NSKeyedUnarchiver unarchiveObjectWithData:data2];
任何解决这个问题的帮助我都会感激