Skip to content

alertController 结合 Alamofire会报错 #237

@lumangmang

Description

@lumangmang

cell.followButton.rx.action = CocoaAction { [weak self] _ in
return Observable.create { [weak self] observer -> Disposable in
let alertController = UIAlertController(title: "Hello world", message: "This alert was triggered by a button action", preferredStyle: .alert)
var ok = UIAlertAction.Action("OK", style: .default)
ok.rx.action = CocoaAction { [weak self] in
guard let self = self else { return .empty() }
return self.viewModel.unfollowing(item.outputs.user.id)
.do(onCompleted: {
observer.onCompleted()
})
}
alertController.addAction(ok)
self?.present(alertController, animated: true, completion: nil)
return Disposables.create()
}
}

会报出异常:
didReceive(_:target:): Received networking error: underlying(Alamofire.AFError.explicitlyCancelled, nil)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions