Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-01-2010, 06:21 PM   #1 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default base64encoding works in 4.0, but not 3.2

Hey Guys,

I am trying to figure out why this line of code works when i have my active executable set to 4.0, but not 3.2:

Code:
NSString *authString = [[[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
It crashes on 3.2 and the console has this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteMutableData base64Encoding]: unrecognized selector sent to instance 0x4c28d20'
wheli is offline   Reply With Quote
Old 09-01-2010, 08:11 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,049
Default

Quote:
Originally Posted by wheli View Post
Hey Guys,

I am trying to figure out why this line of code works when i have my active executable set to 4.0, but not 3.2:

Code:
NSString *authString = [[[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
It crashes on 3.2 and the console has this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteMutableData base64Encoding]: unrecognized selector sent to instance 0x4c28d20'
There is no such thing as "base64Encoding". Why do you need this anyway - not sure what you are trying to do here? The string creation will work without it.
wuf810 is offline   Reply With Quote
Old 09-01-2010, 08:54 PM   #3 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default

Quote:
Originally Posted by wuf810 View Post
There is no such thing as "base64Encoding". Why do you need this anyway - not sure what you are trying to do here? The string creation will work without it.
Ummm....i may be mistaken, but I saw it somewhere and seems to work perfectly. Here is authString with it: YXBjOmFwYw== and authString without it: <6170633a 617063>

Those are the values printed to the console by NSLog(@"%@",authString)

I am using it within an web service application that i am writing to put base 64 encoded strings into a request.
wheli is offline   Reply With Quote
Old 09-02-2010, 10:58 AM   #4 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default

I think this was the post that I was looking at when I first used the code:
Iphone UIWebView HTTP Basic Authentication | Wetware

I guess its possible that the base64encoding component is part of "NSData+Additions.h", but I still don't understand why it would work in 4.0 and not 3.2. Was there a base64encoding addition to NSData in 4.0?
wheli is offline   Reply With Quote
Old 09-05-2010, 08:06 PM   #5 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default

anyone else have any other ideas on this one? I am kind of stumped at the moment. do you think that it's not worth worrying about since 4.x will be coming out for the iPad soon and I can just say that you need 4.x to run the app?

thanks. (sorry for the bump)
wheli is offline   Reply With Quote
Old 09-09-2010, 10:07 AM   #6 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default

Hey Guys,

Still stuck on this one....
I'd rather not have to add extra classes to my application if I don't have to. Any thoughts/suggestions? I don't know what the best practice would be in this case. Has anyone implemented any base 64 encoding in their applications?

Thanks!
wheli is offline   Reply With Quote
Old 09-09-2010, 11:00 AM   #7 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
Default

Yes I've implemented base64 in my apps, it work even on 4.1

I'm use the base64 implementation by Matt Gallagher Cocoa with Love: Base64 encoding options on the Mac and iPhone
TUX2K is offline   Reply With Quote
Old 09-09-2010, 11:16 AM   #8 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default

Quote:
Originally Posted by TUX2K View Post
Yes I've implemented base64 in my apps, it work even on 4.1

I'm use the base64 implementation by Matt Gallagher Cocoa with Love: Base64 encoding options on the Mac and iPhone
Did it work with 3.x firmware? I'm not having problems with 4.x...
wheli is offline   Reply With Quote
Old 09-09-2010, 07:42 PM   #9 (permalink)
Registered Member
 
wheli's Avatar
 
Join Date: Jan 2010
Posts: 128
Default

I finally figured it out. I was able to find the NSData+Additions.h class. It was deeply buried within the Colloquy source code. It's a pretty handy class....allows for base 64 encoding of your authentication string with two lines:

Code:
NSString *authString = [[[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
authString = [NSString stringWithFormat: @"Basic %@", authString];
Thanks to everyone for the help! If you're curious about the open source Colloquy project, you can check it out here: Development Guide ? Colloquy
wheli is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 259
23 members and 236 guests
ADY, AragornSG, bookesp, chillyh, dacapo, Dani77, Davey555, Desert Diva, Dominus, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, Oral B, prchn4christ, Raggou, Rudy, spiderguy84, themathminister
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:29 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0