Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
516 views
Welcome To Ask or Share your Answers For Others

1 Answer

Xcode 4 Refactor > Convert to Objective-C ARC transforms:

@interface XYZ : NSObject
{
    id delegate;
}
@property (assign) id delegate;
...
@synthesize delegate;

into:

@interface XYZ : NSObject
{
    id __unsafe_unretained delegate;
}
@property (unsafe_unretained) id delegate;
...
@synthesize delegate;

If I remember correctly it is also mentioned in WWDC 2011 video about ARC.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...