Refactor To ARC suggest "weak" attribute for property
Refactor To ARC suggest "weak" attribute for property
- Subject: Refactor To ARC suggest "weak" attribute for property
- From: Andreas Grosam <email@hidden>
- Date: Fri, 05 Apr 2013 08:50:40 +0200
When using the "Refactor To Objective-C ARC" tool, Xcode suggests to convert from
(@interface Foo)
@property (atomic, readonly) NSError* error;
to
@property (weak, atomic, readonly) NSError* error;
The property is "readonly". Thus, specifying a "weak" attribute makes no sense anyway. Why is Xcode suggesting to specify it weak?
Thanks for clarification!
Further info:
The property itself was originally an *autoreleased* object which will be created in a helper method whenever the property is read. The implementation after converting is as follows:
@implementation Foo
// property readonly error
- (NSError*) error {
return [self makeError];
}
// Returns an NSError object
- (NSError*) makeError
{
error_t imp_error = self.imp->error(); // error_t is a C struct, imp a C++ instance.
NSDictionary* userInfoDict = …;
NSError* error = [NSError errorWithDomain:@"FooError" code:imp_error.code userInfo:userInfoDict];
return error;
}
Regards
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden