When I declare a property without a storage specification + instance variable, everything works happily:
@interface Foo : NSObject {
NSSomething* mySomething;
}
@property (readonly) NSSomething* mySomething;
Yet, when I delete the instance variable declaration, I get a compilation error stating that I must specify the storage type:
@property (readonly, strong) NSSomething* mySomething;
This made me wonder should I just declare strong, but it should be readonly anyway..
What is happening here? Which is approach should I use for which case?
EDIT (For those unable to replicate the problem):


You have it right. If you want it readonly, leave the readonly in there for sure.
If you want the ivar to be synthesised for you, though, the compiler needs to know whether to make it strong, weak, or unsafe untrained. The default is assign which translates to unsafe unretained (which probably isn’t what you want). Others are reporting that the compiler handles the default properly without warning, but since you’re having trouble, you need the retain attributes in the property declaration.
Alternatively, you can declare the ivar yourself as you originally did.