I have an object
@interface QuestionViewModel : NSObject
@property (nonatomic, assign) NSInteger questionId;
@property (nonatomic, strong) NSString *questionText;
@property (nonatomic, assign) NSInteger questionNumber;
@property (nonatomic, strong) NSArray *choices;
@property (nonatomic, strong) QuestionViewModel *nextQuestion;
@property (nonatomic, strong) QuestionViewModel *previousQuestion;
@end
I know when I populate this object it is successful and all properties are initialized fully and correctly.
However, when I pass this object like this:
*This is a different class (it is not in the NSObject defined above).
@property (nonatomic, strong) QuestionViewModel *currentQuestion;
- (void)nextQuestion
{
[self loadQuestion:self.currentQuestion.nextQuestion];
}
- (void)loadQuestion:(QuestionViewModel *)question
{
self.currentQuestion = question;
.
.
.
}
question.nextQuestion
and question.previousQuestion
are nil
.
Why when I pass this object do the subsequent objects (nextQuestion and previousQuestion) become nil? It seems like the object is doing a shallow copy rather than a deep copy, not sure though.
It seems like there is something foundational that I do not know about.