I have a question, here’s the code:
@interface MyFoo : NSObject {
NSString *nameStr;
}
@end
@implementation MyFoo
- (id)init {
self = [super init];
if (self) {
self->nameStr = [@"some value of the string that is set right into the private ivar" copy];
}
return self;
}
@end
The question is: ignoring all the C++ rules, ignoring memory dump vulnerability, why exactly I shouldn’t use such arrow operator syntax?
Is there somewhere in Apple documentation a rule which says that it’s incorrect because in future class may be represented differently than a pointer to a struct in runtime etc. ?
Thanks in advance!
The use of
self->someIvaris identical tosomeIvar. It’s not wrong but it’s not needed either.The only time I use the arrow notation is in an implementation of
copyWithZone:so I can copy each of the ivars that don’t have properties.Where are you seeing anything that says you shouldn’t use such arrow operator syntax?