可以将我的NSDictionary放到NSInputStream中吗?这将是我的NSDictionary
NSArray *keys = [NSArray arrayWithObjects:@"name", @"device_token", @"identifier", nil];
NSArray *values = [NSArray arrayWithObjects:@"Test iPhone", initDeviceToken, [UIDevice currentDevice].uniqueIdentifier, nil];
NSDictionary *parameters = [NSDictionary dictionaryWithObjects:values forKeys:keys];我试过这样的方法,但不起作用。
NSInputStream *inputStream = [[NSInputStream alloc] init];
[inputStream setValue:@"123" forKey:@"identifier"];非常感谢
发布于 2010-09-17 03:21:22
好的。方法是使用NSPropertyListSerialization将字典序列化为NSData对象,然后将数据对象写出到NSInputStream中。
缺点是,这要求您的字典只保存plist对象(数字、字符串、日期、数据、数组和字典)。
发布于 2012-09-11 22:41:27
是。
任何符合NSCoding protocol的对象都是可序列化的,因此可写入流。当然,容器对象中的项也必须符合NSCoding协议。
https://stackoverflow.com/questions/3729803
复制相似问题