Faraz Ahmad
Faraz Ahmad

Reputation: 545

Using a copy of a ViewController in the same app with additional functionalities

I've downloaded a calendar app's source code form Github. The app has a CalendarViewController that contains a child UIView (called calendarView).

This has multiple classes (CalendarDayView, CalendarMonthView etc. etc. and the protocols are also written for some of the classes)

I have integrated this calendar app into my custom iPhone app, that has a TableViewController. The rest of the information is given in the image.

Notes:

  1. Programming language = Swift.
  2. I'm a complete novice, so please try to be elaborative.
  3. I don't know if the given information will be enough to get the perfect answer (as I understand that the answer to this type of question depends on how the CalendarApp has been programmed).
  4. Please see the attached file to understand the info.

Thanks in advance. The description of the problem

Upvotes: 1

Views: 63

Answers (1)

Andriy Gordiychuk
Andriy Gordiychuk

Reputation: 6272

This is totally fine. Just ensure that your have two instances of CalendarViewController.

For example, when you instantiate your navigation controller you have:

let calendar1 = CalendarViewController()
let navC = UINavigationController(rootViewController:calendar1)

And then when a button is clicked in your TableViewController:

let calendar2 = CalendarViewController()
self.navigationController.pushViewController(calendar2,animated:true)

Because you are making two initialisations, each CalendarViewController will be a completely separate object and setting some variables on one of them will not result in that variable being updated in the second one.

Upvotes: 1

Related Questions