Snapples
asked on
__unsafe_unretained in ARC
Hi experts,
I'm using ARC for the first time and I have a problem with delegates.
I have a ConnectionObject that inherits from NSObject, it has a NSURLConnection and downloads some data. I have a protocol ConnectionObjectDelegate with several delegate methods that need to be called when the connection finished downloading.
It also has an NSMutableSet containing delegates that need to be called when the connection finishes. The objects I add to this set as delegates may become nil while the data is downloading, so they have to be removed/become nil in the set (or before trying to call the delegate method) as well.
My object has a method for adding a delegate, in the past this would have been:
-(void)addDelegate:(id<Con nectionObj ectDelegat e>)delegat e;
But now I'm not sure, how do I make sure that the object I pass as a parameter is weak?
Thanks in advance.
I'm using ARC for the first time and I have a problem with delegates.
I have a ConnectionObject that inherits from NSObject, it has a NSURLConnection and downloads some data. I have a protocol ConnectionObjectDelegate with several delegate methods that need to be called when the connection finished downloading.
It also has an NSMutableSet containing delegates that need to be called when the connection finishes. The objects I add to this set as delegates may become nil while the data is downloading, so they have to be removed/become nil in the set (or before trying to call the delegate method) as well.
My object has a method for adding a delegate, in the past this would have been:
-(void)addDelegate:(id<Con
But now I'm not sure, how do I make sure that the object I pass as a parameter is weak?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I still use assign for the delegates and do not support ARC in my apps.
ASKER