Hi all and thanks in advance for any help you can send my way with this!
I am new to Objective-C (like a lot), but am not new to OO programming (i know java and .net best). I am trying to figure out which is the best way to read a URL page, so I can sift through it for specific "content", and output it in a nice format.
I've been reading through a lot of the api's, but cannot figure out which is the best approach. Let's say I want to download http://www.google.com. Should I use:
or
I also will need to eventually post data to a site's form, and I do believe you can do that with NSURLConnection by setting it's header info (i think), but I'm not to that point just yet. Can someone please state the use of NSURLConnection? Thanks!
I am new to Objective-C (like a lot), but am not new to OO programming (i know java and .net best). I am trying to figure out which is the best way to read a URL page, so I can sift through it for specific "content", and output it in a nice format.
I've been reading through a lot of the api's, but cannot figure out which is the best approach. Let's say I want to download http://www.google.com. Should I use:
Code:
NSString *myUrl = @"http://www.google.com";
NSString *returnData = [NSString stringWithContentsOfURL:[NSURL URLWithString: myUrl]];
or
Code:
NSString *myUrl = @"http://www.google.com";
NSURLRequest *myRequest = [ [NSURLRequest alloc] initWithURL: [NSURL URLWithString:myUrl] ];
NSString *returnData = [ NSURLConnection sendSynchronousRequest:myRequest returningResponse: nil error: nil ];
I also will need to eventually post data to a site's form, and I do believe you can do that with NSURLConnection by setting it's header info (i think), but I'm not to that point just yet. Can someone please state the use of NSURLConnection? Thanks!