• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EXC_BAD_ACCESS on returning an int?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >EXC_BAD_ACCESS on returning an int? (From: Ian Havelock <email@hidden>)

  • Prev by Date: Re: EXC_BAD_ACCESS on returning an int?
  • Next by Date: Re: EXC_BAD_ACCESS on returning an int?
  • Previous by thread: Re: EXC_BAD_ACCESS on returning an int?
  • Next by thread: Re: EXC_BAD_ACCESS on returning an int?
  • Index(es):
    • Date
    • Thread