I'm new to iOS programming and I have just built an iPhone app that can ask user a question and return an answer. The building environment is OS X 10.9 and Xcode 5.0.2. Every time I starts the iPhone simulator, the Debug Navigator shows that the memory usage is 13.5mb but it keeps going up even after I returned to Home screen. After a minute the memory usage will become stabilized around 17.5mb. Is this a normal behavior or I need to add some memory management code?
#import "QuizViewController.h"
@interface QuizViewController ()
@property (nonatomic) int currentQuestionIndex;
@property (nonatomic, copy) NSArray *questions;
@property (nonatomic, copy) NSArray *answers;
@property (nonatomic,weak) IBOutlet UILabel *questionLable;
@property (nonatomic,weak) IBOutlet UILabel *answerLable;
@end
@implementation QuizViewController
- (instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self){
self.questions = @[@"From what is cognac made?",
@"What is 8 + 8 ?",
@"What is the capital of Minnesota?"];
self.answers = @[@"Grapes",
@"16",
@"St.Paul"];
}
return self;
}
- (IBAction)showQuestion:(id)sender
{
self.currentQuestionIndex++;
if (self.currentQuestionIndex == [self.questions count]){
self.currentQuestionIndex = 0;
}
NSString *question = self.questions[self.currentQuestionIndex];
self.questionLable.text = question;
self.answerLable.text = @"???";
}
- (IBAction)showAnswer:(id)sender
{
NSString *answer = self.answers[self.currentQuestionIndex];
self.answerLable.text = answer;
}
@end