Re: Randomly shuffle my core data dataset?
Re: Randomly shuffle my core data dataset?
- Subject: Re: Randomly shuffle my core data dataset?
- From: Joshua Scott Emmons <email@hidden>
- Date: Tue, 28 Mar 2006 13:32:42 -0600
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.
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.
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.
That is, at least, what I would try. If these suggestions are
dangerously misguided, I hope someone will step in to correct me.
Cheers,
-Joshua Emmons
_______________________________________________
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