Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hop666

macrumors newbie
Original poster
Oct 27, 2009
2
0
minsk maz
Hi
I want to write something in objective-c.I I wrote at the moment short something:
Code:
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>

int main (int argc, const char * argv[]) {
   // NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    
    NSString * adres = @"http://www.google.pl";
    
    DOMDocument * dok1 = [[[DOMDocument alloc] URL] initWithString:adres];
    
    // insert code here...
    NSLog(@"Hello, World!");
    [dok1 release];
    //[pool drain];
    return 0;
}

The program is being compiled but in the process of action it is throwing the exception out: EXC_BAD_ACCESS, after certain (long) time can even hang the computer.Why? What am I doing badly? I've tried also like this:

Code:
DOMDocument * dok1 = [[[DOMDocument alloc] URL] initWithString:&adres];

but still the same : EXC_BAD_ACCESS
 
Code:
DOMDocument * dok1 = [[[DOMDocument alloc] URL] initWithString:adres];

This line is the problem. initWithString: isn't a method (from what I can see looking at the headers) that DOMDocument knows. Also, after alloc you're going to 99% of the time call an init method, so I'm not sure why the URL method is there.

If you're trying to get the DOMDocument object for a given URL, try using the WebView class. alloc/init an instance of that, load your URL into it, wait for it to complete (requires a run loop and a delegate), and then you can grab the DOMDocument object from its main frame.

If that doesn't make sense then you should probably learn some more Cocoa fundamentals before trying to understand this.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.