세 개의 객체가 포함 된 사전이 있으며이 사전을 스택의 이전 뷰에서 NSMutableArray에 추가하려고합니다. 이 배열은 mainviewcontroller에서 올바르게 합성됩니다. 그러나 시도 할 때다른 뷰에서 NSMutableArray에 객체 추가
[mainVC.fotoObjectArray addObject:[NSMutableDictionary dictionaryWithDictionary:fotoObject]];
아무 것도 배열에 추가되지 않습니다.
alloc/init 제대로하지 못했지만 이전 뷰 컨트롤러의 속성에서 유지됩니다.
사용자가 사진을 찍거나 단추로 앨범에서 선택합니다. 그가 돌아 오면 : 뷰가
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D location = newLocation.coordinate;
fotoObject = [[NSMutableDictionary alloc] init];
[fotoObject setObject:[NSNumber numberWithDouble:location.latitude] forKey:@"latitude"];
[fotoObject setObject:[NSNumber numberWithDouble:location.longitude] forKey:@"longitude"];
}
를로드되는 경우 GPS가 PhotoViewController.m에 기록됩니다 동시에
PhotoViewController.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSArray *viewControllers = [self.navigationController viewControllers];
MainViewController *mainVC = (MainViewController *)[viewControllers objectAtIndex:viewControllers.count - 2];
[mainVC setFotoGenomen:@"Ja"];
i = @"foto";
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
[fotoObject setObject:[NSData dataWithData:imageData] forKey:@"image"];
[mainVC.fotoObjectArray addObject:[NSMutableDictionary dictionaryWithDictionary:fotoObject]];
//display image
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setFrame:CGRectMake(10.0f, 120.0f, 300.0f, 300.0f)];
imageView.backgroundColor = [UIColor whiteColor];
[[self view] addSubview:imageView];
[imageView setImage:image];
[self dismissModalViewControllerAnimated:YES];
[self.tableView reloadData];
[imageView release];
}
은 'fotoObject'딕셔너리는 권리를 포함 키 및 값. 이제 그 사전을 MainViewController.m의 NSMutableArray에 넣으면됩니다.
디버거에서 mainVC가 실제로 생각하는 객체인지 확인하십시오. mainVC.fotoObjectArray를 로깅하면 아무 것도 보이지 않습니까? 거기에 다른 물건이 있습니까? – jrturton
아니요, 기록 할 때 null을 반환합니다. – MaikelS
mainVC 또는 mainVC.fotoObjectArray? – jrturton