Re: EXC_BAD_ACCESS on returning an int?
Re: EXC_BAD_ACCESS on returning an int?
- Subject: Re: EXC_BAD_ACCESS on returning an int?
- From: mmalc Crawford <email@hidden>
- Date: Sat, 04 Jul 2009 23:42:47 -0700
On Jul 4, 2009, at 5:39 PM, Ian Havelock wrote:
For future reference, in many cases EXC_BAD_ACCESS can be indicative
of a memory management problem. Here, however, you are asking NSLog
to print int values as objects ('%@' is the format specifier for an
object):
NSLog(@"Number of Sides: %@, Min: %@, Max: %@", [poly1
numberOfSides], [poly1 minimumNumberOfSides], [poly1
maximumNumberOfSides]);
The runtime treats the integer as the address of an object and tries
to send it a message, which doesn't work out so well...
From <http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265
>, the specifier for an int is '%d', hence:
NSLog(@"Number of Sides: %d, Min: %d, Max: %d", [poly1
numberOfSides], [poly1 minimumNumberOfSides], [poly1
maximumNumberOfSides]);
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden