How to print or log the value of CGSize object?

Prasad picture Prasad · Jul 8, 2011 · Viewed 39.5k times · Source

I was trying to log (print) the value of CGSize object like this:

CGSize sizeOfTab = CGSizeMake(self.frame.size.width/tabCount, 49);

NSLog(@"size of tab is %@",sizeOfTab);

Is there anything wrong in this code; my app is crashing while control comes to NSLog statement.

Thanks Prasad

Answer

visakh7 picture visakh7 · Jul 8, 2011

Try this

CGSize sizeOfTab = CGSizeMake(self.frame.size.width/tabCount, 49);
NSLog(@"size of tab is %@",NSStringFromCGSize(sizeOfTab));

The crash occurs because sizeOfTab is not in NSString format.