开发者

Basic HTTP Authentication using Obj C and Xcode

I am hoping someone ca开发者_StackOverflown help me with a question i have relating to Basic HTTP Authentication in an Xcode 2.3 application.

Basically i have a PHP page that is on our server and when called with certain parameters returns data relating to the servers condition etc.

i have managed to get a small Xcode application working where by it reads the data from the page and populates an NSTextView with the data.

however to make sure this information stays safe i have setup basic HTTP Authentication on the page, but i cannot work out how to provide the username and password in XCode.

here is my code to retrieve the page.

NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSString *content = [NSString stringWIthContentsOfUrl:url];
[myTextView setString:content];

i am still at a very basic beginner level regarding xcode and obj c, so nice simple examples of how i go about this would really be appreciated.

Thanks Kris

ok following on from the intial comment i got about looking at a website regarding this issue here is whats happened, ive had a look through the webpage supplied and have struggled to get code working in my program.

now when i run my program and click the button to-do the login the debug window pops up on this line

NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@",   
    [NSString stringWithCString:encodedLoginData length:strlen(encodedLoginData)]]; 

this is in the debug log at this point

Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/kristiaandavies/getWebData/build/Debug/getWebData.app/Contents/MacOS/getWebData', process 982.
Pending breakpoint 1 - ""AppController.m:10" resolved

i click continue to attempt to get it going further and then get this from the debug log

(gdb) continue
Current language:  auto; currently objective-c
Program received signal:  "EXC_BAD_ACCESS".
(gdb) 

and the program freezes???


Here is a link that may get you started in the right direction.

http://www.chrisumbel.com/article/basic_authentication_iphone_cocoa_touch

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜