【发布时间】:2018-04-13 00:58:01
【问题描述】:
这个新的现有项目正在使用带有 RACObserve(Reactive cocoa) 的 Objective-C 代码来读取 api 响应。 我想将 obj-c 转换为 swift 。
当前的 Obj-c 实现是:
@interface ObjCTableViewCell : UITableViewCell
@property (nonatomic, strong) OfferPersonal *offer;
@end
.m 类->
- (void)bindToModel {
[RACObserve(self, offer.lender.name) subscribeNext:^(id x) {
self.nameLabel.text = x;
}];
}
控制器->
{
ObjCTableViewCell TableViewCell *myCell;
myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
[myCell setValue:self.offer forKey:@"offerPersonal"];
[myCell bindToModel];
}
现在如何在 Swift 中使用 RACObserve。我试图在其他地方搜索它。 (http://blog.scottlogic.com/2014/07/24/mvvm-reactivecocoa-swift.html)could 不太明白。
【问题讨论】:
标签: objective-c swift restkit reactive-cocoa