2) In Xcode, in your project, click on the file folder icon, which is the top left button, so that you can see all the .h and .m files in your project.
3) Open the .tar file in Finder, and drag-and-drop the Classes/ASI* files to Xcode, on the left hand side, in the same directory that the rest of your .h and .m files are. NOTE: Don't copy the files manually through the command line (Terminal) nor outside of Xcode.
4) If you are creating an iPhone app, drag-and-drop the External/Reachability/Reachability* files to Xcode, on the left hand side, in that same directory.
5) Go to http://allseeing-i.com/ASIHTTPRequest/Setup-instructions and follow the step 2 directions, which is setting up the Build Phases.
6) If you are using ARC, then you need to disable ARC for the ASI* and Reachability* files. Click on your main project on the left hand side, then choose "Build Phases", and expand the "Compile Sources" section. For all of the ASI* and Reachability.m files, add in the following flag for "Compiler Flags": -fno-objc-arc (Also see http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project)
7) At the top of your .m file where you want to download the webpage, paste the following line:
#import "ASIHTTPRequest.h"
8) In that same .m file, download the file by doing this:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:nsurl];
[request setUsername:@"enterUsernameHere"];
[request setPassword:@"enterPasswordHere"];
if (!error) {
NSString *response = [request responseString];
NSLog(response);
}
NSString* url = @"http://www.google.com";
NSURL *nsurl = [NSURL URLWithString:url];ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:nsurl];
[request setUsername:@"enterUsernameHere"];
[request setPassword:@"enterPasswordHere"];
[request startSynchronous];
NSError *error = [request error];if (!error) {
NSString *response = [request responseString];
NSLog(response);
}
That's it!
No comments:
Post a Comment