Here i am facing issue with DelegeProtocol.
Class MainPagesVC : XLPageViewController<PagerDelegate>
{
....
let page1: PageVC
let page2: PageVC
let page3: PageVC
}
Class PageVC : UIViewController {
let tableView: UITableView
....
cellForRowAt() {
let cell = UploadCell..
cell.delegate = self
....
}
}
extension PageVC: CellDelegateProtocol {
//In DelegateProtocol
cellDelegateProcessDone() {
//here reloading tableview for get updated data
print(‘pageIndex:(currentPageIndex)’)
//
}
}
Class UploadCell: UITableViewCell {
....
awakeFromNib(){
self.lbl.text = self.getProgress()
}
//this process will call after done process, so not wasting time
afterDoneProcess() {
self.delegate.cellDelegateProcessDone()
}
}
- PageVC’s table view have cell with display upload process like 10%, 30% till 100%
- In every page’s viewWillApper call API for get different data, so I don’t want to make another screen for just list change.
- I am using DelegateProtocol for do some process in PageVC after done upload cell process.
Now the scenario is,
- First I am on Page1 and tableview reload and UploadCell display with 10%.
- Now swipe to Page2 and tableview reload and UploadCell display till 10%, because upload process display only for Page1, not updating for Page2 (This is also issue).
- Now staying on Page2 till 100% of Page1's cell done.
- Remember: I am on Page2 and process done for Page1 and I want to update something on Page2 with Page1’s cellDelegateProcessDone() method.
Now the issue is:
- When I am on Page2 and process done for Page1 then delegate method call but for Page1, not for Page2,
- And It’s print “pageIndex:0”, still I am on Page2, it should display “pageIndex:1”
- Because in that delegate method if I want to do some reload part than currently only able to update for Page1, not for Page2 (issue).
- It will resolve with NSNotification Observer, but I don’t want to use observer.
Also know the issue, what happen, It’s not updating due to cell.delegate = self,
Because on Page1, it’s like cell.delegate = Page1, and for Page2 like cell.delegate = Page2, So when I am on Page2 and once process done in Page1’s cell then it’s try to call like self.Page1.cellDelegateProcessDone() And it’s print with Page1, I also want to do some process on Page2. Like self.Page2.cellDelegateProcessDone()
I know, it’s might be little confusion flow, but I tried to explain I was faced.
So let me know if anyone have solution for this.
Thanks!!