To print address use %p
format specifier and self pointer:
-(NSString *) description {
return [NSString stringWithFormat:@"<SomeClass: %p>\nparmeterOne: %@\nparameterTwo: %@",
self, self.parameterOne, self.paramterTwo];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ Area: %@, %@", [super description], self.identifier, self.name];
}
So in the case of this model object that is a subclass of NSObject, you can dodge extra work and remembering %p
.
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p> Area: %@, %@", NSStringFromClass([self class]), self, self.identifier, self.name];
}
So in the case of an object model in which you have a concrete implementer that is derived from this class you will show the correct class name.
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