views:

27

answers:

1

Hi there

Is it possible to put in my NSDictionary into a NSInputStream? This would be my 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];

I tried something like this but it didn't worked...

NSInputStream *inputStream = [[NSInputStream alloc] init];
[inputStream setValue:@"123" forKey:@"identifier"];

Thx a lot

A: 

Sure. The way you can do it is serialize your dictionary into an NSData object using NSPropertyListSerialization, and then write your data object out to your NSInputStream.

The downside is that this requires that your dictionary only hold plist objects (numbers, strings, dates, data, arrays, and dictionaries).

Dave DeLong