Suppose I have an object containing some data.
How can I see that data using NSLog?
If anyone is not clear about my question, then can ask me again.
If you want to see an NSArray and NSDictionary and etc objects then you can directly print like NSLog(@"%@",object);
If it is an user defined object then you need to display by calling with property (attribute).
User defined object with name object and properties like
NSString *property1;
int property2;
NSMutableArray *property3;
Print them in the console as follows:
NSLog(@"%@, %d, %@" object.property1,object.property2,object.property3);
If you implement the -(NSString*)description
method in your class then you can use NSLog
to output a summary of the data. Of course, you can also directly output any property.
For example:
NSLog (@"%@ %d", object, object.integer);
The first part calls the description
method and outputs that; the second part gets the value of the integer property of object and outputs that.
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