叹息,关于这一点有一百万个问题,但没有一个对我有用..所以:
我的应用适用于iPhone。我有一个tableView,当我离开时,数据移动正常。
对于iPad,我没有在splitView中获取详细数据。但是当我记录detailView对象时,我看到以下内容:
2014-08-28 17:44:26.298 GuessGreek[59754:607] -[WordViewController tableView:didSelectRowAtIndexPath:]
2014-08-28 17:44:26.299 GuessGreek[59754:607] -[WordDetailsViewController viewDidLoad]
2014-08-28 17:44:26.300 GuessGreek[59754:607] detailItem 1<WordEntity: 0x786853e0> (entity: WordEntity; id: 0x78685810 <x-coredata://B2B61C41-1855-46EB-AA5E-04697CA6B025/WordEntity/p1454> ; data: {
category = uncategorized;
changeFlag = nil;
englishScore = 0;
englishText = "unmarried, single";
example = nil;
favorite = nil;
greekScore = 0;
greekText = "\U03ac\U03b3\U03b1\U03bc\U03bf\U03c2-\U03b7-\U03bf";
type = Adjective;
uid = 1454;
})
2014-08-28 17:44:26.302 GuessGreek[59754:607] 1 greekTextField: (null)
2014-08-28 17:44:26.303 GuessGreek[59754:607] 1 englishTextField: (null)
详细对象看起来已填充,但是当我记录单个组件时,它们是空白的。
我的代码如下:
WordView
// ipad的
> -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
> if (_IPAD) {
>
> id object;
> if (self.searchResults.count > 0)
> {
> object = [self.searchResults objectAtIndex:indexPath.row];
> [self.searchDisplayController setActive:NO];
> }
> else
> {
> object = [self.fetchedResultsController objectAtIndexPath:indexPath];
>
> }
>
> wordDetailsViewController.detailItem = object;
> [wordDetailsViewController viewDidLoad];
>
> } }
// iPhone
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"wordToDetails"])
NSIndexPath *indexPath = [self.searchDisplayController.searchResultsTableView indexPathForCell:(UITableViewCell *)sender];
id object;
if (indexPath != nil)
{
object = [self.searchResults objectAtIndex:indexPath.row];
[self.searchDisplayController setActive:NO];
}
else
{
indexPath = [self.wordTable indexPathForCell:(UITableViewCell *)sender];
object = [self.fetchedResultsController objectAtIndexPath:indexPath];
}
WordDetailsViewController *destinationController = segue.destinationViewController;
destinationController.detailItem = object;
}
}
DetailView - viewDidLoad
NSLog(@"detailItem 1%@", detailItem);
self.greekTextField.text = [self.detailItem valueForKey:@"greekText"];
self.englishTextField.text = [self.detailItem valueForKey:@"englishText"];
我将不胜感激任何帮助/建议..
答案 0 :(得分:1)
如果您使用核心数据的@dynamic属性会怎样?
self.greekTextField.text = self.detailItem.greekText;
self.englishTextField.text = self.detailItem.englishText;