setDelegate:self, how does it work?
Posted
by fuzzygoat
on Stack Overflow
See other posts from Stack Overflow
or by fuzzygoat
Published on 2010-05-25T17:56:14Z
Indexed on
2010/05/25
18:01 UTC
Read the original article
Hit count: 471
I have a query regarding how delegates work. My understanding was that delegates take responsibility for doing certain tasks on behalf of another object.
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
Am I right in thinking that in the example code above that the instance of CLLocationManager is created on a new thread so that it can get on with trying to find the location information it needs. When it completes its task (or encounters an error) it calls-back using the appropriate methods located in self e.g.
locationManager:didUpdateToLocation:fromLocation:
Essentially locationManager
sends messages to self
(which conforms to the correct delegate protocol) when things happen
cheers gary
© Stack Overflow or respective owner