We came across the issue of NSURLConnection not being called until the Modal was stopped using [NSApp stop] and this is the way around it. We have to use RunLoop.
- (void) awakeFromNib {
NSURL *url=[[NSURL alloc] initWithString:@"/linkout.php?url=olliekett.com"];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
NSURLConnection *c = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self startImmediately:YES];
responseData=[[NSMutableData data] retain];
CFRunLoopRun();
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
NSString *alert = [NSString stringWithFormat:@"Connection failed: %@", [error description]];
NSLog(alert);
CFRunLoopStop(CFRunLoopGetCurrent());
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
CFRunLoopStop(CFRunLoopGetCurrent());
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(responseString);
[connection release];
}