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:

But now I'm not sure, how do I make sure that the object I pass as a parameter is weak?

Thanks in advance.

asked 12/15/2011 05:28

Snapples's gravatar image

Snapples ♦♦

3 Answers:
The delegate was always "assign". So we ARC it should be:
@property (weak) id <MyDelegate> delegate;
I think so.
An interesting post about ARC



pgnatyuk's gravatar image


Yes, I get that, and that is the perfect solution for iOS5, but my app supports iOS4 and above, where weak isn't available.

answered 2011-12-16 at 05:23:03

Snapples's gravatar image


I still use assign for the delegates and do not support ARC in my apps.

answered 2011-12-16 at 18:45:01

pgnatyuk's gravatar image


Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments


Asked: 12/15/2011 05:28

Seen: 2158 times

Last updated: 12/17/2011 07:10

Related questions