I\'m working on an iPhone application that involves uploading full photos from the camera (generally between 1.5 to 2.0 MB each) as well as their thumbnails (much smaller) to Am
Have resolved this error with using operation for request (NSMutableUrlConnection
) with @autorelease{}
for main function.
NSPOXIS appears only sometimes.
- (void)main
NSURLConnection* connection;
@autoreleasepool //urgently needed for 3G upload
{
self.currentRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"test.php"]];
[self.currentRequest setHTTPMethod:@"PUT"];
[self.currentRequest setHTTPBody:self.data];//inpustStream doesn't work
connection = [NSURLConnection connectionWithRequest:self.currentRequest delegate:self];
[connection start];
}//end autorelease pool
do
{
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate distantFuture]];
if ([self isCancelled])
{
connection = nil;
isFailed = YES;
break;
}
self.status(statusUpdateMessage);
}
while (!isFailed && !isCompleted);
[timer invalidate];//test
timer = nil;
//corresponding of status via blocks
self.completed(!isFailed);
self.status(isFailed ? errorMessage : @"Completed");
if (isFailed)
{
self.failed(errorMessage != nil ? errorMessage : @"Undefined error");
}
self.data = nil;
self.currentRequest = nil;
connection = nil;
}