Specifying the (id)sender in the IBAction


#1

Hello,

I just started to read the Chapter 1 for the iOS Programming book.

How important is to specify the id in the IBAction sender? I saw some developers changing it for the pointer (for example (UIButton *)sender) ) they would like to access instead of keeping the generic (id)sender, what is the difference between these ways?

Thanks,
Igor


#2

If you know the sender’s type, use it; otherwise use id, which is the wildcard for all object pointers.

Using the exact type makes more static type information available, which is good.


#3

If u know the type, changing it from id to for example (UIButton *)sender, lets Xcode give u code completion tailored to only that type.