When I define a new class inheriting from NSObject
:
@interface Photo : NSObject
{
NSString* caption;
NSString* photographer;
}
@property NSString* caption;
@property NSString* photographer;
@end
are all the class methods (like alloc
) in NSObject
inherited by the new class Photo
?
Yes, Photo
can use any method/property/ivar/etc (except for those iVars declared @private
) of a NSObject
when you subclass NSObject
:
Photo *myPhoto;
myPhoto = [[Photo alloc] init];
// ... Do some myPhoto stuff ...
NSLog(@"Photo object: %@", myPhoto);
NSLog(@"Photo description: %@", [myPhoto description]);
NSLog(@"Photo caption: %@", [myPhoto caption]);
NSLog(@"Photo photographer: %@", [myPhoto photographer]);
More about @private
-> SO Question: what-does-private-mean-in-objective-c
NSObject
Class Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With