title: Basic HTTP Authentication using Obj C and Xcode
body: <p>I am hoping someone can help me with a question i have relating to Basic HTTP Authentication in an Xcode 2.3 application.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>here is my code to retrieve the page.</p>
  
  <pre><code>NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
  NSString *content = [NSString stringWIthContentsOfUrl:url];
  [myTextView setString:content];
  </code></pre>
  
  <p>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.</p>
  
  <p>Thanks
  Kris</p>
  
  <p>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.</p>
  
  <p>now when i run my program and click the button to-do the login the debug window pops up on this line</p>
  
  <pre><code>NSString *authHeader = [@"Basic " stringByAppendingFormat:@"%@",   
      [NSString stringWithCString:encodedLoginData length:strlen(encodedLoginData)]]; 
  </code></pre>
  
  <p>this is in the debug log at this point</p>
  
  <pre><code>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
  </code></pre>
  
  <p>i click continue to attempt to get it going further and then get this from the debug log </p>
  
  <pre><code>(gdb) continue
  Current language:  auto; currently objective-c
  Program received signal:  "EXC_BAD_ACCESS".
  (gdb) 
  </code></pre>
  
  <p>and the program freezes???</p>