I am writing a new app and I have several view controllers that segue in sequence. In an earlier view controller I added an extension with a function just after the "import UIKit". Then I call this function in ViewDidLoad.
Later in the app another view controller is meant to use the same function in that view controller. So I thought that I should add the extension with that function in the same place in the code for that view controller - just after "import UIKit".
However when I try to build that app then I receive the swift compiler error that it is an invalid redeclaration of that function and it lists both the earlier view controller in the sequence as well as the latest view controller. Why does that happen?
When I remove the code from the latest view controller but leave the extension in the earlier view controller then both view controllers work and the app is built and seems to work correctly.
Could someone explain what is happening in this case? thanks for your help
Later in the app another view controller is meant to use the same function in that view controller. So I thought that I should add the extension with that function in the same place in the code for that view controller - just after "import UIKit".
However when I try to build that app then I receive the swift compiler error that it is an invalid redeclaration of that function and it lists both the earlier view controller in the sequence as well as the latest view controller. Why does that happen?
When I remove the code from the latest view controller but leave the extension in the earlier view controller then both view controllers work and the app is built and seems to work correctly.
Could someone explain what is happening in this case? thanks for your help