diff QuestionnaireViewController.mm @ 43:b91a1859829a

used UIkit sliders
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 19 Apr 2013 18:50:04 +0100
parents a42903c61558
children a1e75b94c505
line wrap: on
line diff
--- a/QuestionnaireViewController.mm	Wed Apr 17 13:44:05 2013 +0100
+++ b/QuestionnaireViewController.mm	Fri Apr 19 18:50:04 2013 +0100
@@ -30,7 +30,7 @@
 
 @synthesize picker;
 @synthesize nextButton = _nextButton;
-@synthesize questionArray;
+@synthesize questionArray = _questionArray;
 
 
 //----------------------------------------------------------------
@@ -77,6 +77,7 @@
 - (void)dealloc {
 
     [_questionText release];
+    [_questionArray release];
     [_titleText release];
     [_finishButton release];
     [_nextButton release];
@@ -111,8 +112,8 @@
 
     Question *q;
     
-    for(int i=0;i<[questionArray count];i++){
-        q = [questionArray objectAtIndex:i];
+    for(int i=0;i<[self.questionArray count];i++){
+        q = [self.questionArray objectAtIndex:i];
         answersArray.push_back(q.answer);
         
     }
@@ -178,10 +179,10 @@
 - (void)loadQuestion:(NSInteger)questionIndex {
     // populate text fields with question
     NSString *qtitle;
-    qtitle = [@"Question " stringByAppendingFormat:@"%d / %d",questionIndex+1, [questionArray count]];
+    qtitle = [@"Question " stringByAppendingFormat:@"%d / %d",questionIndex+1, [self.questionArray count]];
     self.titleText.text = qtitle;
     
-    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
+    Question *curQ = [self.questionArray objectAtIndex:self.currentQuestionIndex];
     
     self.questionText.text = curQ.questionText;
     
@@ -251,7 +252,7 @@
              titleForRow:(NSInteger)row
             forComponent:(NSInteger)component
 {
-    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
+    Question *curQ = [self.questionArray objectAtIndex:self.currentQuestionIndex];
 
     // get array of answers from Question class
     NSArray * answers = [Question answersWithType:curQ.questionType];
@@ -264,7 +265,7 @@
 -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
       inComponent:(NSInteger)component
 {
-    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
+    Question *curQ = [self.questionArray objectAtIndex:self.currentQuestionIndex];
     // set question answerArray
     curQ.answer = row;
     
@@ -291,7 +292,7 @@
 - (IBAction)answerChosen:(id)sender {
     self.pleaseAnswer.hidden = YES;
     UISegmentedControl *seg = (UISegmentedControl *)sender;
-    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
+    Question *curQ = [self.questionArray objectAtIndex:self.currentQuestionIndex];
     // set question answerArray
     curQ.answer = seg.selectedSegmentIndex;