I’m trying to learn about Objective-C for iPhone development, and while looking at action examples, I often saw things like:
- (IBAction)sliderMoved:(id)sender
{
UISlider *aSlider = (UISlider *)sender;
}
What is the purpose of entering the type (id) and then casting it immediately (UISlider *). Why not just do the following:
- (IBAction)sliderMoved:(UISlider *)aSlider;
{
}
Is there a technical reason for this, or is it just an agreement or made for readability?
Thanks in advance,
source
share