gpt4 book ai didi

objective-c - 将 Reactive Cocoa doNext^ 转换为 Swift

转载 作者:行者123 更新时间:2023-11-28 05:35:00 26 4
gpt4 key购买 nike

我有以下 Obj-C 方法:

- (RACSignal *)updateCurrentConditions {
return [[self.client fetchCurrent:self.coordinate] doNext:^(WXCondition *condition) {
self.currentCondition = condition;
}];
}

我正在尝试弄清楚如何将它转换为 Swift,但我不确定如何正确返回它。

我该怎么做:

[[self.client fetchCurrent:self.coordinate] doNext:^(WXCondition *condition) {}];?

func updateCurrentConditions() -> RACSignal {
return client.fetchCurrent(coordinate: coordinate) {
currentCondition = condition
}
}

这里是 ReactiveCocoa 的链接以及有关 -doNext:

的信息

最佳答案

你可以试试这个:

func updateCurrentConditions() -> RACSignal {
let fetchSignal = client.fetchCurrent(coordinate: coordinate)
return fetchSignal.doNext(block: {condition: WXCondition? -> Void in
let wxCondition = condition as WXCondition
currentCondition = wxCondition
})
}

关于objective-c - 将 Reactive Cocoa doNext^ 转换为 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24226528/

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