• 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
Question Regarding the Memory Address of Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question Regarding the Memory Address of Objects


  • Subject: Question Regarding the Memory Address of Objects
  • From: "Carter R. Harrison" <email@hidden>
  • Date: Thu, 18 Dec 2008 14:57:59 -0500

Ok, hopefully this is an easy one.

I have a Nib file setup with an NSView and some NSButton's as subviews of that view. I have IBOutlets for each of the NSButton's in my NSView subclass.

In the awakeFromNib: method of my NSView subclass I do the following:

- (void)awakeFromNib
{
//Initialize NSMutableDictionary instance variable
dict = [[NSMutableDictionary alloc] initWithCapacity:1]; // "dict" is an NSMutableDictionary instance variable


//Set the value "button1" into the dictionary and make it's key the string representation of button1's memory address.
[dict setValue:@"button1" forKey:[NSString stringWithFormat:@"%x", &button1]]; // "button1" is one of my IBOutlets.
}


When a user clicks the button the following method fires and promptly crashes my app.

- (void)buttonClicked:(id)sender
{
// Print out the value for the button pressed. THIS LINE CRASHES
NSString *value = [dict valueForKey:[NSString stringWithFormat:@"%x", &sender]];


	//This next line crashes app - EXC_BAD_ACCESS
	NSLog(@"Value is: %@", value);
}

It seems like the memory address of the sender is different than what it should be. I did some debugging and the address of the sender is always bfffe2e8 which really shouldn't be possible at all.

Any ideas?  As always, thanks in advance.


_______________________________________________

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


  • Follow-Ups:
    • Re: Question Regarding the Memory Address of Objects
      • From: David Duncan <email@hidden>
    • Re: Question Regarding the Memory Address of Objects
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Implementing a record counter (record n of records)
  • Next by Date: Re: Preventing Automatic Gzip Decompression with NSURLConnection?
  • Previous by thread: RE: Implementing a record counter (record n of records)
  • Next by thread: Re: Question Regarding the Memory Address of Objects
  • Index(es):
    • Date
    • Thread