user255607
user255607

Reputation: 1869

Does @property (readonly, retain) have a meaning?

XCode accepts it. But will retain be applied when I internally set the property (no setter outside since readonly but when I initialize the value in a class method) ?

Regards, Apple92

Upvotes: 1

Views: 1426

Answers (3)

justin
justin

Reputation: 104698

it's also nice as a form of interface documentation

Upvotes: 0

Joshua Weinberg
Joshua Weinberg

Reputation: 28688

The reason to do this is to allow you to do @property (retain) in a class continuation or category. If you don't have the retain on the outer property, you will get a warning about the properties being mismatched.

Upvotes: 4

Shaggy Frog
Shaggy Frog

Reputation: 27601

You might specify (readonly, retain) for a publicly-facing property, and then inside your .m, re-define it as (readwrite, retain) to be able to assign to it privately. I use this pattern myself occasionally.

Upvotes: 5

Related Questions