У меня есть NSMutableString, определенный в моем файле AppDelegate.h.Использование и обновление NSMutableString в AppDelegate для двух диспетчеров просмотра
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>{
@public
NSMutableString *nidForDetailDisplay;
}
Затем я установил эту строку в файле ViewController.m. Я сохраняю строку (nidForDetailDisplay), чтобы перейти от tableview к detailview.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
rowNumber = indexPath.row;
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
// this is where I set the string to a string of text
appDelegate->theNidForDetailDisplay = [arrayOfNids objectAtIndex:rowNumber];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIViewController *detailViewController;
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
[self.navigationController pushViewController:detail animated:YES];
}
В ViewController, когда я вхожу theNidForDetailDisplay, я получаю правильную строку.
Далее я пытаюсь открыть обновленный NSMutableString (nidForDetailDisplay) в последующем DetailViewController
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSMutableString *storyid;
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate->theNidOnDetailDisplay = storyid;
}
Однако, когда я печатаю строку (storyid) или (theNidOnDetailDisplay) они оба возвращение нулевой.
Я что-то упустил? Должен ли я использовать переменные экземпляра? Спасибо заранее.
Спасибо, я не понимаю, что я мог бы сделать это. – Spenciefy