ios - NSNotification - 在发布通知之前检查是否添加了观察者
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>已结束。</b>此问题不符合 <a href="https://stackoverflow.com/help/closed-questions" rel="noreferrer noopener nofollow">Stack Overflow guidelines</a> .它目前不接受答案。
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你应该这样做:</p>
<pre><code>[ addObserver:self selector:@selector(getItems:) name:kgotNotification object:nil];
[ postNotificationName:kgotNotification object:self userInfo:dictionary];
</code></pre>
<p>然后你的 getItems 方法:</p>
<pre><code>-(void)getItems:(NSNotification* )note
{
NSLog(@"UserInfo: %@", note.userInfo);
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - NSNotification - 在发布通知之前检查是否添加了观察者,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21836592/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21836592/
</a>
</p>
页:
[1]