I want to generate qrcode for a NSDictionary. Using NSKeyedArchiver converted dictionary to NSData and generated a QRCode. But when the qrcode is scanned the output is of different characters with the dictionary element in somewhere in between the output.
Is there a way to use DataUsingEncoding to convert dictionary to data.
Thanks in advance.
Related
I have multiple large dynamically created NSDictionaries which contain (among other) multiple NSData objects.
I need to "pretty-print" this dictionary. Using -description I get a quite good result except for the NSData stuff which is not completely printed as it is cropped by the method.
Is there a way (except for iterating over the whole dictionary with a nested for-loop) to convert all the NSData objects to a Hex-String representation?
I'm receiving data in XML from a server through a NSData object and I would like to convert this data to a NSMutableArray object.
How do I convert the data from the NSData object (knowing that there should be different objects transferred into the NSMutableArray - UIImages ,CLLocation2D objects, strings,...)
Give you a URL, check it by yourself, it is easy to solve.
Using the json-framework for iPhone (http://code.google.com/p/json-framework/) it's really easy to create json data from a NSDictionary. Like so;
NSString *json_string = [json_parser stringWithObject:dictionary];
This works perfect if I have objects like NSString and so on in my dictionary. But I also need to send integers,bools and floats with json and can not find a way to do this in the same way. Anyone got a solution?
UPDATE:
I found out that I can wrap integers to NSNumber. But how can I use bools?
I believe that json-framework maps from JSON bools and numbers to NSDecimalNumber. In the case of bools, the NSDecimalNumber should be init'd with initWithBool:. Give that a try.
I am unsure of how to separate a NSData object into smaller parts so that I can send it over bluetooth. I believe it is a method similar to this:
- (void)getBytes:(void *)buffer range:(NSRange)range
I do not know what to pass in for the buffer. Do I just pass in a NSMutableData object to hold the bytes that I pull out of the original NSData?
Thanks
You can use the -subdataWithRange: method.
I am pulling down a plist from a URL using an NSURLConnection, which returns an
NSData object. I would like to convert this to an NSArray. Can anyone help me?
I am refactoring a method that currently does a synchronous request to the URL,
using arrayWithContentsOfURL: to get the NSArray.
Thanks!!
Use +[NSPropertyListSerialization dataWithPropertyList:format:options:error:] to convert the data, then check if the result -isKindOfClass:[NSArray class].
Use NSKeyedArchiver for archiving object to data.
NSKeyedUnarchiver for unarchiving object from data:
NSArray *object = [NSKeyedUnarchiver unarchiveObjectWithFile:self.receivedData];