Connect to the Internet in the Mac app

The last GUI programming I did was with Visual Basic, which included objects like Winsock and Inet to easily connect to the Internet and fetch a source from web pages.

I just started working in Xcode and was wondering if there is a similar component. I see there is a Webkit option in the library, but I have no idea how to use it.

Any help would be appreciated.


I want to simulate a browser as well as possible (including cookies, headers, etc.). Is the Webkit approach better than the link you just gave me? Sorry I was not clearer in the OP.

0


source to share


3 answers


Apple has two tutorials in the documentation you want to look at, the URL Loading System and the WebKit Objective-C Programming Guide . You are probably most interested in the former if you want to request data from a web server behind the scenes, or the latter if you want to actually put a web browser control in your application. Both docs should explain the classes you will be using and the general process, but let me know if you have any questions.



Many of Cocoa's core datatypes like NSString, NSDate, and even NSArray and NSDictionary have methods to load data from a URL like Heng-Cheong Leong, but they abstract all the low level stuff and probably won't fit if you want to deal with HTTP headers.

+3


source


Webkit is the correct answer. Here is a tutorial from 2003 showing how to create a web browser using webkit:

http://cocoadevcentral.com/articles/000077.php



Basically, webkit allows you to embed a web browser into your application's user interface.

+3


source


The NSString class has methods for retrieving the source from web pages, such as stringWithContentsOfURL: encoding: error :.

For more control, take a look at the classes described at http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html .

WebKit is more like an MSIE ActiveX control.

0


source







All Articles