Re: Randomly shuffle my core data dataset?
Re: Randomly shuffle my core data dataset?
- Subject: Re: Randomly shuffle my core data dataset?
- From: "Steven Harms" <email@hidden>
- Date: Tue, 28 Mar 2006 12:23:10 -0800
On 3/28/06, Joshua Scott Emmons <email@hidden> wrote:
> > i must be able to shuffle the array controller. Where can
> > i get a hold of the Array controller and shuffle it?
>
> I'm not sure if it's good design sense, but I would be tempted to
> shuffle my NSManagedObject instances rather that my array controller.
Could you point to me where to do that? How can I get that collection
of NSManagedObject(s). Which method, in which instance is the best
place to do this?
> I would give the card entity an "index" property, and make sure the
> array controller's sortDescriptors were set to sort on the property.
> Then I would bind whatever it is that needs to know about the cards
> to the array controller's arrangedObjects. This will return an array
> of managed card objects sorted by their index property. To shuffle
> the cards, just shuffle their index properties. No tinkering with the
> array controller needed.
>
> > When reviewing a card, i must shuffle the four potential answers (i.e.
> > answer 1 must appear in TextField 4, etc.).
>
> Again, I would do this in the model. Assuming that your card entity
> has four properties like, answer1, answer2, etc., just shuffle those
> properties. In your view, textField1 is always bound to answer1,
> textField2 to answer2, etc. But the values of answer1, answer2, etc.
> are shuffled.
OK, great approach, how can I update the model? Do I do that in the
app delegate? In which method should I put the 'shuffle' technology
in?
> > It must be possible to send a card to a "Wrong Answer" stack so that
> > you can just review your wrong cards at some later point. Essentially
> > i need to be able to add a "card" to an NSArrayController.
>
> I might not understand what you're looking for here, but why not add
> a transient property called "wrongAnswer" to your card entity? It
> could have a type of BOOL and a default value of NO. Each time a card
> is answered wrong by the user, the "wrongAnswer" property gets set to
> YES. Whenever you need to display a list of all missed cards, you can
> just fetch all cards where wrongAnswer=YES. You could even have a
> separate array controller in your nib that does this for you.
This is a very good approach, I will adopt it.
Thanks for the help, I guess all I need is guidance on how to get
those objects for shuffling?
Steven
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden