6
gitpush
6y

I hope I'm doing it wrong and there is actually a way to tell who the sender is, like an Id? But fuck no Apple finds it using tags with numbers a fucking genius idea!

Again, I hope I'm wrong and we can actually do something like: sender.id = txtName.id ...

Comments
  • 1
    Isn't it possible to match the sender with the object instance of your form element?
    It should refer on the same memory position.
  • 0
    @TylerDDevRant tbh inevertried it,I will check thanks for your suggestion
  • 1
    Why are you attaching more than one button action to a single function
  • 0
    @nikilesh122 because all the logic buttons need to do is in separate functions, so I don't want multiple actions just for calling another function

    I don't like to bind my code to certain event, for example in that if condition I call another function to submit data, so that my button is only responsible of telling what the user wants, and the responsible functions will be notified (called) for carrying out the work
  • 0
    As far as iOS app development each button we use in storyboard we should always define a ibaction for every button so that it reduces the code complexity and increase the readability of the code and thats how apple wants the developer to use so that you debugging becomes easy in such a way
  • 0
    @nikilesh122 but when something fails, lets assume from my code submit button fails to complete its task, I don't go back to the action function, I go to submitData() function and debug there, that action is just the cause of submitting data, and no the the one to be submitting data,

    I keep it like that so that if I at some point had to replace that button with lets say, a UITableView that its row is responsible for submitting data, I just remove button action and call the function in didSelectCellAtRow

    it reduces the amount of code to change imo
  • 0
    Yeah some point you want to change the button to some other thing then keep it as type id than uibutton while declaring the ibaction
  • 0
    @nikilesh122 Doesn't this still force me to call that action? My main point is to avoid relying on something specific but keeping it general, that logic does not need to be committed to IBAction, but instead the action is the one that needs it.

    That's why I keep all my actions for the same type in one place and ignore that they exist when I want to debug, I put my logic in a separate extension (in same file) and just work there whenever I need to debug something
  • 0
    Keep it general by keeping ibaction parameter as type id you are keeping it general so when you change from button to label still the code is valid and as far as the internal implementation you are splitting it into different ibaction hence thereby you are segmenting the code which will be very useful while writing test cases
  • 0
    Plus at your current implementation your are creating a bunch of if else stmt which is generally bad way of programming
Add Comment