iPhone-別のクラスからセレクターを起動します
-
30-09-2019 - |
質問
「Properties」と呼ばれる他のクラスの1つから「writeit_mobileappdelegate」という別のクラスにあるテーブルビューをリロードしたいと思います。 nsnotificationCenterクラスを介してこれを実行しようとしました - ログが呼び出されますが、テーブルは更新されません。
Properties.H:
[[NSNotificationCenter defaultCenter] postNotificationName:@"NameChanged"
object:[WriteIt_MobileAppDelegate class]
userInfo:nil];
writeit_mobileappdelegate.m
- (void)Awakefromnib {
[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(reloaditproperties :) name:@"namechanged" object:self];
}
- (void) reloadItProperties: (NSNotification *)notification {
NSLog(@"Reloading Data"); //this gets called
[[self navigationController] dismissModalViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
[self.tblSimpleTable reloadData];
[self.tblSimpleTable reloadSectionIndexTitles];
// but the rest doesn't
}
ここで何が間違っているのですか?
解決
あなたが使用しているようです object
パラメーターが間違っています:
addobserver:selector:name:object:
通知者
オブザーバーが受信したい通知があるオブジェクト。
つまり、この送信者によって送信された通知のみがオブザーバーに配信されます。 NILを通過した場合、通知センターは通知の送信者を使用して、オブザーバーに配信するかどうかを決定しません。
所属していません StackOverflow