I used to declare all delegate properties as
@property (assign) id<FooDelegate> delegate;
I was under the impression that all assign properties should now be weak pointers, is this correct?
If I try to declare as:
@property (weak) id<FooDelegate> delegate;
I get an error while trying to @synthesize (autogenerated weak properties are not supported).
What’s the best practice in this case?
Use
__unsafe_unretainedinsteadweakfor ARC projects targeting iOS 4 and 5. The only difference is thatweaknils the pointer when deallocated, and it’s only supported in iOS 5.Your other question is answered in Why are Objective-C delegates usually given the property assign instead of retain?.