ios - 如何监听 iOS NSHTTPCookieStorage 中设置的 cookie?
<p><p>我想知道什么时候在 NSHTTPCookieStorage 中设置了 cookie。是否有 on change 方法或事件处理程序?我想阻止设置 cookie。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以通过以下通知收听cookie更改。</p>
<p>NSHTTPCookieManagerCookiesChangedNotification。</p>
<p>Apple 文档链接如下。 </p>
<p> <a href="https://developer.apple.com/documentation/foundation/nshttpcookiemanagercookieschangednotification?language=objc" rel="noreferrer noopener nofollow">https://developer.apple.com/documentation/foundation/nshttpcookiemanagercookieschangednotification?language=objc</a> </p>
<p>例子:</p>
<pre><code>[ addObserver:self
selector:@selector(methodYouWantToInvoke) //note the ":" - should take an NSNotification as parameter
name:NSHTTPCookieManagerCookiesChangedNotification
object:nil];
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何监听 iOS NSHTTPCookieStorage 中设置的 cookie?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/50053482/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/50053482/
</a>
</p>
页:
[1]