我们的应用程序中有一个功能,用户可以从摄像头拍摄多张照片。所有这些照片都添加到NSMuteArray对象中,并在用户单击“保存”按钮后发送到服务器。
目前这个过程对我们不起作用,每当用户点击保存时,应用程序崩溃。我们使用下面的代码添加元素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];
}
此处还有我们在保存时使用的代码..
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];
有人可以帮我们解决这个问题吗?