On Nov 25, 2011, at 9:38 PM, Koen van der Drift wrote:
> Here is what I am doing, I read an NSString from the raw data, an xml file
> using NSXMLParser. This works ok. Then I convert that to an NSData object,
> and perform base64 decoding
No, you're not ;-) You read a string that is presumably already Base64 encoded,
then you stuff it into an NSData, then you Base64 encode that, then you decode
it, leaving you with the original Base64 encoding intact...
Instead of:
> NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding];
> NSString *base64String = [data base64EncodedString];
> NSData * base64DecodedData = [NSData dataFromBase64String:base64String];
I think you just need:
NSData * base64DecodedData = [NSData dataFromBase64String:string];
The actual byte-swapping code looks OK:
> for (n = 0 ; n < (2 * count) ; n++)
> {
> ((u_int32_t *) result)[n] = ntohl((u_int32_t) ((u_int32_t
> *) dataToConvert)[n]);
> }
Although there's a superfluous cast there that might be a clue that you're just
slinging code in without understanding it...
There's also probably not much point to using subdataWithRange instead of
bytes...
--
Scott Ribe
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]