gpt4 book ai didi

ios - 如何使用 ReactiveCocoa 移除观察者?

转载 作者:可可西里 更新时间:2023-11-01 03:36:40 25 4
gpt4 key购买 nike

如何在某些事件后停止接收新名称?

[RACObserve(self, username) subscribeNext:^(NSString *newName) {
if ([newName isEqualToString:@"SomeString"])
{
//Do not observe any more
}
}];

附言很抱歉这个明显的问题,但我找不到答案

最佳答案

您可以使用从“subscribeNext”返回的 RACDisposable 对象的“dispose”方法。

__block RACDisposable *handler = [RACObserve(self, username) subscribeNext:^(NSString *newName) {
if ([newName isEqualToString:@"SomeString"]) {
//Do not observe any more
[handler dispose]
}
}];

关于ios - 如何使用 ReactiveCocoa 移除观察者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29656460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com