Anには anNSNotificationと呼ばれるプロパティがあります。はを投稿しているです。通常、 をセットアップするときにを使用します。を使用してを渡したい場合は、次のようにします。userInfoNSDictionaryobjectNSObjectNSNotificationselfobjectNSNotificationselfNSObjectNSNotificationNSArrayNSNotification
NSArray *myArray = ....;
NSDictionary *theInfo =
[NSDictionary dictionaryWithObjectsAndKeys:myArray,@"myArray", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData"
object:self
userInfo:theInfo];
そして、次を使用してそれをキャッチします。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(doTheReload:)
name:@"reloadData"
object:sendingObject];
sendingObjectを送信しているオブジェクトはどこにありますかNSNotification。
最後に、doTheReload:次を使用して配列をデコードします。
NSArray *theArray = [[notification userInfo] objectForKey:@"myArray"];
それはいつも私にとってうまくいきます。幸運を!