-6

I try to add filterview to Viewcontroller. I try to decide how i do but I dont know what is the best way for this implementation. Now I open a xib file(filterView) on the viewcontroller but also I have a tabbar and I dont align to bottom constraint to safearea because of tabbar.

Now I decide to open in new VC but I dont know how can I pass these filter datas. I think I have some method as "Observer" , "Core Data", "UserDefaults" or "Dynamic class" . Which is the best way for this question?

Can you help me for answering this question?

I dont use Segue also I dont want use Segue . I can pass data A to B but in reverse I have to apply an action in A. Also I dont want to use any function in viewDidAppear.

I open the B controller with present(vc , animated: true) and I get back with dismiss(animated: true , completion: nil).

This is not duplicate of any question.

Thanks in advance

Ali Ihsan URAL
  • 1,894
  • 1
  • 20
  • 43
  • 1
    https://stackoverflow.com/questions/25215476/how-do-you-pass-data-between-view-controllers-in-swift – SPatel Feb 11 '19 at 06:49
  • 1
    https://stackoverflow.com/questions/38721370/how-to-pass-data-between-uiviewcontrollers-with-protocols-delegates – SPatel Feb 11 '19 at 06:49

1 Answers1

0

Let's first get in one page. you have viewController and you are presenting another viewController from code? and you want to pass data of first viewController to second one?

In your case for data passing there is no need of "user defaults" and "CoreData".

Since you are not using segues, You can simply do it by delegation or closure or using observers.

I am explaining delegation here.

for example Protocol DataPasser { func dataHolder(data: DataType) } then use delegate in your first viewController like

above ViewDidLoad() method

var delegate: DataPasser?

then when redirecting next viewController just call delegate?.dataHolder(yourData)

and in next viewController make this delegate self and make extension to use this delegate like extension SecondViewController: DataPasser and use delegate method and you will have your data in delegate method argument.

Hope this will help you. if not ask me again.. here to help.

Jayraj Vala
  • 224
  • 2
  • 8