I’m trying to upload images to a php file, everything works, but sometimes when the site is
getting slow to load our app start frizzing until the page is done loading so i thought
about using threads to avoid such frizzing, but right now our app display and quit. I dont
see any warnings or problem… it just enter the app and exist right away. Please help me
out
the code:
-(void) source {
NSData *imageData = UIImageJPEGRepresentation(imageView.image, 80);
NSString *urlString = @"http://domain";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
our_label.text = [NSString stringWithFormat:@"%@", returnString];
}
-(void)som:(id)param{
[lock lock];
[lock unlock];
}
You can use the NSURLRequest in an asynch method, however if you want your current code to work follow these insturctions
First change this line
to
Second, you are updating the UI in a non UI thread, so wrap this
around
dispatch_get_main_queuelike the followingFinally remove the locks since you are not really using them