What is your best practice with IBActions? Where do u place them? I cannnot decide.
1) If I place them with regular functions, it can be messy but everything if private.
2) When I place them as extension ClassName{} It is more clean BUT it can't work with private variables I have to make them unprivate.
I want to code clean. Thx
If I'm not mistaken, your case is when you add them to an
extension, you won't be able to accessprivatevars/methods.You have (what I suggest) two possible solutions:
1- If you want to keep them in a separated extension (but in the same .swift file) for the purpose of organizing your code, you need to change
privatetofileprivate.For more information about access modifiers in Swift 3, you might want to check this answer.
2- Keep them in the ViewController and use
// MARK: - IBActions, it marks sections in the symbol navigator.For example:
As you can see, there are
// MARK: - Core Data stack,// MARK: - Core Data Saving supportand//MARK: - Machines Core Datato separate the code and make it more readable and organized.Hope it helped.