NSURLConnection Problem Inside QuickLook Generator
NSURLConnection Problem Inside QuickLook Generator
- Subject: NSURLConnection Problem Inside QuickLook Generator
- From: Dalmazio Brisinda <email@hidden>
- Date: Tue, 8 Dec 2009 03:13:34 -0700
I'm writing a QuickLook plugin that, as part of the preview process, makes an http call to a (localhost) server to obtain data that is then used to generate the preview image.
The code below works fine outside the QuickLook architecture, as a standard Cocoa application. But as soon as I move the (exact) same code over to the QuickLook plugin, a call to the server only returns (null) response, and (null) data. The docs indicate that this means the connection is failing. But why o why is it failing?
If I print the contents of the NSError object to the console, I get the following message:
09-12-08 3:02:05 AM quicklookd[37158] error: Error Domain=NSPOSIXErrorDomain Code=1 UserInfo=0x10049d880 "The operation couldn’t be completed. Operation not permitted"
It appears that sendSynchronousRequest:... is not permitted. So why is this operation not permitted? And is there a workaround? Any help would be most appreciated.
NSURL * url = [NSURL URLWithString:urlString];
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
[request setTimeoutInterval:5];
NSError * error;
NSURLResponse * response;
NSData * data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
Best,
Dalmazio
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden