gpt4 book ai didi

ios - ReactiveCocoa `rac_textSignal` map 完成事件

转载 作者:行者123 更新时间:2023-12-01 16:26:05 24 4
gpt4 key购买 nike

我是 Reactive Cocoa 的新手。

当空白被添加到 UITextView 时,我需要触发东西,在用修剪后的版本替换 TextView 文本之后。所以基本上我正在寻找某种完成事件。我想这是一件简单的事情,但我一定错过了一些重要的东西......这就是我所拥有的:

RACSignal *whitespaceSignal = [self.field.rac_textSignal filter:^BOOL(NSString *input) {
return [self textContainsWhitespace:input];
}];

RAC(self.field, text) = [whitespaceSignal map:^id(NSString *input) {
// The stuff that needs to happen *after* the text field has
// got the new, trimmed value.. But here it gets triggered before
// the UITextView updates its value.
// [self respondToWhiteSpaceTrimmedEvent];
return [self trimWhitespace:input];
}];

我尝试了几种 subscribeCompleted 的组合, then , completed block ,但没有一个被调用。

如何检测 self.field.text已更新其值以响应 whitespaceSignal ,然后才触发我的副作用?

最佳答案

您是否订阅过您创建的信号?您过滤/映射信号,但很明显您没有订阅信号,所以我认为这就是原因。

[[self.field.rac_textSignal map:^id(NSString *input) {
// The stuff that needs to happen *after* the text field has
// got the new, trimmed value.. But here it gets triggered before
// the UITextView updates its value.
// [self respondToWhiteSpaceTrimmedEvent];
return [self trimWhitespace:input];
}] subscribeNext:^(id x) {
// Do some stuff after you replace whitespace ...
}];

关于ios - ReactiveCocoa `rac_textSignal` map 完成事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35298546/

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