私はチャットアプリケーションに取り組んでいます。すべてのView Controllerのアプリケーション状態を保存したい。
アプリの状態を保存する私のコード:
+ (UIViewController *)viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
{
MoreController *vc = nil;
UIStoryboard *storyboard = [coder decodeObjectForKey:UIStateRestorationViewControllerStoryboardKey];
if (storyboard)
{
vc = (MoreController *)[storyboard instantiateViewControllerWithIdentifier:@"MoreController"];
vc.restorationIdentifier = [identifierComponents lastObject];
vc.restorationClass = [MoreController class];
}
return vc;
}
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.view forKey:@"save"];
[coder encodeObject:_btnoiwii forKey:@"save"];
[coder encodeObject:_tblMore forKey:kUnsavedEditStateKey];
[super encodeRestorableStateWithCoder:coder];
}
- (void)decodeRestorableStateWithCoder:(NSCoder *)coder
{
self.view = [coder decodeObjectForKey:@"save"];
_btnoiwii= [coder decodeObjectForKey:@"save"];
_tblMore = [coder decodeObjectForKey:kUnsavedEditStateKey];
[super decodeRestorableStateWithCoder:coder];
}
アプリケーションの状態をエンコードできますが、デコードできません。アプリデリゲートクラスで追加しました shouldRestoreApplicationState,willEncodeRestorableStateWithCoder
iOSでアプリケーションの状態を保存および復元するための適切な解決策を教えてください。