I used below code for calling image posting first and then text posting upon completion of image posting method...
-(IBAction)btnChooseClecked:(id)sender
{
NSOperationQueue *queue = [NSOperationQueue new];
queue.maxConcurrentOperationCount = 1;
[queue addOperationWithBlock:^{
[self sendImage];
}];
[queue addOperationWithBlock:^{
[NSThread sleepForTimeInterval:1.0];//2.0
[self sendText];
}];
///(OR) i used below code also
dispatch_async(dispatch_get_main_queue(), ^{
[self sendImage];
// inside sendImage method I am calling sendText as [self performSelector:@selector(sendText) withObject:nil afterDelay:0.2];
})
}
-(void)sendImage
{
NSData *imageData = UIImageJPEGRepresentation([appDelegate scaleAndRotateImage:imageSelected.image], 0.0);
[appDelegate.hub invoke:@"Send" withArgs:@[([imageData respondsToSelector:@selector(base64EncodedStringWithOptions:)] ? [imageData base64EncodedStringWithOptions:kNilOptions] : [imageData base64Encoding])]];
[self performSelector:@selector(sendText) withObject:nil afterDelay:0.5];
}
But sometimes it is working fine but sometimes text is posting first instead of image. No delegate method is called after completion of first..As we used different API for performing post method. Please suggest any ideas where I am going wrong..Any alternatives for above..
Thanks in Advance..