We have a feature in our application where users can take multiple photos from the cam. All these photos are added to NSMuteArray object and are send to the server after user clicks on save button.
Currently this process is not working for us and whenever user clicks on save , application crashes. We are using below code to add elements NSMuteArray
UIImage *img=[info objectForKey:UIImagePickerControllerOriginalImage];
self.picData=UIImageJPEGRepresentation([[self scaleAndRotateImage:img] fixOrientation], 1.0);
[self.addPhotosBtn setImage:[UIImage imageWithData:self.picData] forState:UIControlStateNormal];
[self.addPhotosBtn setImage:[UIImage imageWithData:self.picData] forState:UIControlStateHighlighted];
[self.addPhotosBtn setImage:[UIImage imageWithData:self.picData] forState:UIControlStateHighlighted];
NSString *ImgData =[[NSString alloc] initWithData:self.picData encoding:NSUTF8StringEncoding];
if (appDelegate.selectedPhotos) {
[self.selectedPhotos addObject:self.picData];
[appDelegate.selectedPhotos addObject:self.picData];
}else{
appDelegate.selectedPhotos=[NSMutableArray arrayWithCapacity:0];
self.selectedPhotos=[NSMutableArray arrayWithCapacity:0];
}
Also here is the code we use while saving..
NSDateFormatter *df1=[[NSDateFormatter alloc]init];
[df1 setDateFormat:@"MMMM dd, yyyy"];
NSDate *dd=[df1 dateFromString:self.date.text];
[df1 setDateFormat:@"yyyy-MM-dd"];
NSDictionary *data=[NSDictionary dictionaryWithObjectsAndKeys:
//appDelegate.selectedPhotos,@"photos",
[appDelegate.allcatches objectForKey:@"catches"],@"allcatches",
[appDelegate.selectedPlace objectForKey:@"id"],@"currentplace",
[df1 stringFromDate:dd ],@"currentdate",
[self.description.text isEqualToString:@""] ? @"NULL" : self.description.text,@"description",
self.fbBtn.selected ? @"Y":@"N",@"facebookshare",
self.twBtn.selected ? @"Y":@"N",@"twittershare",
appDelegate.selectedPhotos,@"photos",
nil];
[appDelegate performSelectorInBackground:@selector(uploadPostDataToServer:) withObject:data];
Can someone help us to fix this?
In your case it would be better to use some multiple upload solution. For example, you can try http://www.aurigma.com/iphone/ Up. By the way it is absolutely free.