Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 05-26-2010, 06:46 AM   #17 (permalink)
suejb
Registered Member
 
Join Date: Apr 2010
Posts: 9
suejb is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
That's not a great way to store you data; as you've seen already it makes it hard to do operations at the question level. You'd be better off with a "Question" object that has properties for the question, answer1, answer2, answer3, and correct. Then you can shuffle an array of those objects with the method above.

If you really don't want a custom object (even though you really do, trust me) then you could make an array of five arrays - The master array will have five items, each of those items will be an array representing a single question / answer set. Like so:

Code:
NSArray *quizArray = [[NSArray alloc] initWithObjects:

   [NSArray arrayWithObjects: @"Question number one? (correct A) ",@"A",@"B",@"C",@"D",@"1", nil],

   [NSArray arrayWithObjects: @"Question number two? (correct B) ",@"A",@"B",@"C",@"D",@"2", nil],

   [NSArray arrayWithObjects: @"Question number three? (correct C) ",@"A",@"B",@"C",@"D",@"3", nil],

   [NSArray arrayWithObjects: @"Question number four? (correct D) ",@"A",@"B",@"C",@"D",@"4", nil],

   [NSArray arrayWithObjects: @"Question number five? (correct A) ",@"A",@"B",@"C",@"D",@"1", nil],

   nil];
You get the idea? Now you can shuffle quizArray using the code above without losing the connection between questions and answers.
ok, im trying to explain my problem in details. i have to use this method, because i have written a lot of codes, where from my array get the right answer the question and the four answers. ill describe how it is done:
example my array is like this:
"
NSArray *quizArray = [[NSArray alloc] initWithObjects:
@"Question number one? (correct A) ",@"A",@"B",@"C",@"D",@"1",
@"Question number two? (correct B) ",@"A",@"B",@"C",@"D",@"2",
@"Question number three? (correct C) ",@"A",@"B",@"C",@"D",@"3",
@"Question number four? (correct D) ",@"A",@"B",@"C",@"D",@"4",
@"Question number five? (correct A) ",@"A",@"B",@"C",@"D",@"1",
nil];
self.theQuiz = quizArray;
[quizArray release];
"

and im describing how the objects are sorted: example
@"Question number one? (correct A) ",@"A",@"B",@"C",@"D",@"1",
@"Question number one? (correct A) ",@" - this is the question(the index for this is 0
@"A",@"B",@"C",@"D, - those are choices (the index for this is 1,2,3,4
",@"1", - this is the right answer (it could be 1,2,3,4 variuosly from the right answer)


so this is simple done, but i want this array to shuffle resort.
Is this way possible to be done or i MUST change my way of doing quizarray?
suejb is offline   Reply With Quote
 

» Advertisements
» Online Users: 493
18 members and 475 guests
Absentia, baja_yu, Chickenrig, djbrooks111, Domele, iconomania, jbro, JMLdev, Kieren Harrold, Kirkout, muhimranss, Paul Slocum, roelien, SLIC, spiderguy84, toolifog, tranvutuan, za1407
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,549
Threads: 94,076
Posts: 402,720
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JMLdev
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:26 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.