سؤال

here is another question about how to next detailView like in Mail-App from me. There, i wanted to know how to solve that with an array.

Now i am using coreData. I have an entity named EntityAlphabet with - for example - 5 attributes. The attributes doesnt matter here. In the DetailView, i want to iterate this Entity. How can i do that?

I want to "switch" the entitys in the detailView.

BTW: I am populating my tableView with NSFetchedResultsController.

هل كانت مفيدة؟

المحلول

I have the exact same situation and I just passed an array of managedObjects to the detailView. Then, based upon which up/down arrow they press on the detail view, I select the appropriate object from the array. So it would be similar to the solution from the link you provided. To get the array of objects, in your didSelectRowForIndexPath: method do something along the lines of the following:

// Assumes your detail view controller has a an NSArray ivar and property setup 
detailViewController.alphabetObjects=[self.fetchedResultsController fetchedObjects];

This solution is decidedly low tech and I implemented it because of my lack of knowledge at the time, i.e. 2 years ago. Now, I could think of a couple of additional ways of doing it.

  1. Utilize block call backs to the tableView being managed by the NSFetchedResultsController. So when your didSelectRowAtIndexPath method, you would provide the detailViewController with a block that basically takes an indexPath and returns the new managedObject from your NSFetchedResultsController.
  2. Create a protocol that the tableViewController implements. Through the various methods of the protocol you can request the new object as well as update the detailViewController UI. i.e. queries whether or not it is the first or last object in the set of managedObjects.

Hope this helps. Good luck

نصائح أخرى

You can use NSFetchedResultsController in a similar manner. Try calling - (id)objectAtIndexPath:(NSIndexPath *)indexPath. Pass it the newIndexPath you are already using in your - (IBAction)nextRow:(id) sender.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top