0
我正在使用RxSwift,我試圖訪問我的訂閱功能內的單個項目。但是.subscribe給了我ShoppingList的數組,我想要一個單獨的ShoppingList項目。RxSwift中訪問項目
private var disposeBag = DisposeBag()
var shoppingLists :Variable<[ShoppingList]> = Variable([])
override func viewDidLoad() {
super.viewDidLoad()
// add to the shoppinglist
let shoppingList = ShoppingList(title: "Walmart")
self.shoppingLists.value.append(shoppingList)
shoppingLists.asObservable()
.subscribe { shoppingLists in
// how to access the item inside the shoppingList // Walmart
print("subscribe")
print(shoppingLists)
}
.addDisposableTo(disposeBag)
}