prepareForSegue
메서드를 통해 데이터를 전달할 수 있다고 말하지만, 내가하는 방식이 최적이 아니며 항상 코딩 기술을 향상 시키려고합니다. 이것이 올바른 방법인지 확인하고 있습니까? 그것은 작동하지만 '근본적으로'틀릴 수도 있습니다.연속 된 NSArray
은 내가 PLIST 내가이 작품 때문에
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"detailAll"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
DetailTableViewController *destViewController = segue.destinationViewController;
destViewController.title = [self.namesArray objectAtIndex:indexPath.row];
destViewController.nameLabel = [self.namesArray objectAtIndex:indexPath.row];
destViewController.legislationLabel = [self.legislationArray objectAtIndex:indexPath.row];
}
}
로 SEGUE 방법에 대한 준비를 통해 값을 전달하고 jQuery과
// Find out the path of recipes.plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"law" ofType:@"plist"];
// Load the file content and read the data into arrays
self.dataArray = [NSArray arrayWithContentsOfFile:path];
//Sort the array by section
self.sortedArray = [self.dataArray sortedArrayUsingDescriptors:@[
[NSSortDescriptor sortDescriptorWithKey:@"Section" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"Title" ascending:YES]]];
//Title
self.namesArray = [self.sortedArray valueForKeyPath:@"Title"];
self.sectionArray = [self.dataArray valueForKeyPath:@"Section"];
//Legislation
self.legislationArray = [self.sortedArray valueForKeyPath:@"Legislation"];
을 채우는 있습니다. 그러나 이것을 수행하는 더 깨끗한 방법이 있습니까? 값이 다른 배열로 전달 된 다음 상세보기로 채워집니다. UItableview
이것은 적절하고 깨끗합니다. 왜 그것이 잘못되었다고 생각 하는가? –
알아두면 좋겠지 만, 값이 별도로 전달되는 대신 함께 전달 될 수 있다고 생각했습니다. 어쩌면 NSobject에서. – memyselfandmyiphone
괜찮은 것 같습니다. 그러나 세부 값 VC가 해당 값을 편집 할 책임이있는 경우 속성에'copy' 속성이 필요하므로 나중에 취소 된 변경 사항은 원래 값에 영향을 미치지 않습니다. – Droppy