Skip to main content

Posts

Showing posts with the label asihttprequest

Asihttprequest 61 errors [closed]

it should be a simple problem. im using the ASIhttprequest in many project but sins 1 week each new project i'm trying to add the ASIhttprequest classes i got the following 61 error before using classes just when i'm trying to import them. Build finjan of project finjan with configuration Debug Ld build/Debug-iphonesimulator/finjan.app/finjan normal i386 cd /Users/Apple/Desktop/application/finjan setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -F/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -filelist /Users/Apple/Desktop/application/finjan/build/finjan.build/Debug-iphonesimulator/finj

returning UIImage from block

I have the following code: - (UIImage *) getPublisherLogo { //check the cache if the logo already exists NSString * imageUrl = [NSString stringWithFormat:@"%@/%@&image_type=icon", self.baseUrl, self.imageUrl_]; ASIHTTPRequest * imageRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:imageUrl]]; [imageRequest setTimeOutSeconds:30.0]; [imageRequest setDownloadCache:[ASIDownloadCache sharedCache]]; [imageRequest setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy]; [imageRequest setCachePolicy:ASIAskServerIfModifiedWhenStaleCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy]; [imageRequest setCompletionBlock:^(void){ UIImage *img = [UIImage imageWithData:[imageRequest responseData] ]; if (img){ return img; } }]; [imageRequest setFailedBlock:^(void){ NSLog(@"Error in pulling image for publisher %@", [[imageReq

PHP - Saving Uploaded Image to Server

I am trying to save an uploaded image from an iPhone to a server using PHP. I am using ASIHTTPRequest to handle the data request. This is my iPhone code: [request setPostValue:someString forKey:@"string1"]; [request setPostValue:anotherString forKey:@"string2"]; [request addData:[NSData dataWithData:UIImageJPEGRepresentation(anImage, 0.9)] withFileName:@"img.jpg" andContentType:@"image/jpeg" forKey:@"img"]; [request startSynchronous]; On the server side, I am using this PHP code currently to try saving the image to a folder on my server: print_r($_FILES); $folder = 'upload/'; $image_path = basename($_FILES['img']['name']); echo $folder . $image_path . "\n"; if (move_uploaded_file($_FILES['img']['tmp_name'], $folder . $image_path)) { echo 'ok!'; } else { echo 'fail !'; } The strings are uploaded just fine and when I print_r() i see the contents of t

Return Value of method using AsiHTTPRequest

I have a class that uses AsiHTTPRequest. I want to make a method like this: -(NSData*)downloadImageFrom: (NSString*)urlString; { // Set reponse data to nil for this request in the dictionary NSMutableData *responseData = [[NSMutableData alloc] init]; [responseDataForUrl setValue:responseData forKey:urlString]; // Make the request NSURL *url = [NSURL URLWithString:urlString]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [responseDataForUrl setValue:responseData forKey:[request url]]; [request setDelegate:self]; [request startAsynchronous]; // Wait until request is finished (???? Polling ?????) // while(responsedata = nil) { // do nothing // } BAD SOLUTION return responseData; } After that. A delegate method is called when the responseData is ready. Is there a better solution to continue, than doing polling in the variable responseData?

How safely cancel all requests in ASINetworkQueue on view deallocate

I have ASINetworkQueue with more than 1500 requests in it. Performing this number of requests takes for a while. If user leaves view controller while this queue is running the OS deallocates the view controller and I get "message sent to deallocated instance" error. I have tried to use [self.queue cancelAllOperations]; in dealloc method, but seems like it cancels only requests that are waiting in queue, not the request that is currently running and I'm getting the same error. What is the correct way to handle this situation? Is it possible to make the view controller not to be deallocated while queue is not finished even if user left it? Or is there a way to cancel all requests (including requests that are running) in queue?