if i have a number of classes with something like
@property (nonatomic, retain) NSString* myString;
and want to access that property in a object that is one of these classes (but don’t know which so it is type id), i obviously get “request for member ‘myString’ in something not a structure or union” error.
so if each of these classes conforms to :
@protocol myProtocol <NSObject>
@required
@property (nonatomic, retain) NSString* myString;
@end
then i cast like this to get the property:
(id<myProtocol>)anObject.myString
why doesn’t this work? i still get the same error.
In this case I prefer the messages-sending notation over the dot-notation, as it shows clearly, when the cast will happen:
These lines are equal:
And these are: