¡@

Home 

2014/10/15 ¤U¤È 10:03:34

iphone Programming Glossary: allanswers

NSDictionary split into two arrays (objects and keys) and then sorted both by the objects array (or a similar solution)

http://stackoverflow.com/questions/3785778/nsdictionary-split-into-two-arrays-objects-and-keys-and-then-sorted-both-by-th

static NSString const QuestionKey @ questionNumber static NSString const AnswerScoreKey @ answerScore NSMutableArray allAnswers NSMutableArray array for int i 0 i 20 i fill allAnswers array with random data NSDictionary answer NSDictionary dictionaryWithObjectsForKeys.. NSString const AnswerScoreKey @ answerScore NSMutableArray allAnswers NSMutableArray array for int i 0 i 20 i fill allAnswers array with random data NSDictionary answer NSDictionary dictionaryWithObjectsForKeys NSString stringWithFormat @ Q d i QuestionKey.. NSString stringWithFormat @ Q d i QuestionKey NSNumber numberWithInt rand AnswerScoreKey nil allAnswers addObject answer sort the allAnswers array based on score highest first NSSortDescriptor sortDesc NSSortDescriptor sortDescriptorWithKey..