I am writing a quiz app for iPhone using basic subclasses NSObjectto represent models. At runtime, various controllers create instances of model classes and populate them with data read from disk to disk.
Model classes are a basic quiz hierarchy with several choices:
- There are a lot of quizzes in one application.
- One quiz has a lot of questions.
- There are many answers in one question.
Currently, when a class QuizControllerloads its object Quiz, it fills its property with questions NSArrayinstances Question, and since each of these instances is Questioninitialized, each of them initializes its own NSArrayinstances Answer.
I understand that I do not need every question in memory when loading a quiz, I only need a question with a specific index in the Quizinstance array questions.
I think some kind of dataSource protocol or lazy loading pattern will help reduce the amount of memory that occurs when loading a particular quiz on this system, but I'm not sure how to implement this. I would really appreciate any suggestions the community had:
? , , .