I have a tableview, where much like stackoverflow, a user can select an answer as being the best.
I have an NSMutableArray of *answerContainers, which contain an Answer object.
Let's say the question has 10 answers. The user who asked the question choose the 3rd answer as the best.
I fire off a call to mark the answer as the best on the server, and the result is the updated Answer object, which I want to manipulate in my completion block.
So it looks something like this...
- (void)selectBestAnswer {
for (AnswerContainer *answerContainer in self.answerContainers) {
if (answerContainer.selected) { //can only be 1 selected
Answer *answer = answerContainer.answer;
QuestionDetailTableViewController * __weak weakSelf = self;
[answer markAsBestAnswer:^(BOOL success, id responseObject, NSInteger statusCode, NSArray *messages, NSArray *errors) {
if (success) {
QuestionDetailTableViewController *strongSelf = weakSelf;
Answer *answer = [Answer instanceFromDictionary:responseObject];
[strongSelf replaceAnswerWithAnswer:answer];
[strongSelf reloadTableView];
}
}];
}
}
}
Here are my questions
1) Should I make my weak self of the entire controller, like this. Or do you typically only do this for say the answerContainer?