• 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: What should be the same object doesn't seem to be
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What should be the same object doesn't seem to be


  • Subject: Re: What should be the same object doesn't seem to be
  • From: Fritz Anderson <email@hidden>
  • Date: Tue, 2 Oct 2007 10:48:55 -0500

On 2 Oct 2007, at 9:39 AM, Paul Bruneau wrote:

//now rebuild the menu with the items from operationTypes
NSMenuItem *menuItem;
for (loop = [operationTypes count] - 1; loop >= 0; loop--)
{
menuItem = [menu insertItemWithTitle:[[[self operationTypes] objectAtIndex:loop] operationTypeName]
action:@selector(operationTypeWasSelected:)
keyEquivalent:@""
atIndex:0];
//set the represented object of this new menu item to be the appropriate operation type
[menuItem setRepresentedObject:[operationTypes objectAtIndex:loop]];

}



Then, when the user goes to assign an operationType from the above menu to what I call an "OrderStep", this gets called (by the action: specified above):


//called by the user selecting an operation type from the submenu
- (void)operationTypeWasSelected:(NSMenuItem *)menuItem;
{
NSLog(@"The operation was selected! %@", [menuItem representedObject]);
[[self clickedObject] setOperationType:[menuItem representedObject]];

[stepView setNeedsDisplay:YES];
}


The problem is that even though the selection of the OperationType from the menu seems to go just fine (for instance, the correct information appears, showing the correct operation name on the OrderStep), it appears that the OperationType object is actually not the same object that was attached to the menu, but seems to be a copy of it or something. If I compare them, I see that one of them might be 0x3c8fe0 and the other might be 0x3d2bd0 (what are these? they seem too short to be pointers to the objects)

The first question to ask is whether the inserted object is really not the same as the selected object. Your sample code shows you log the selected object, but not that you log the inserted object (just before or after setRepresentedObject:).


The string representation of pointers is done through a format like "%x", which would suppress leading zeroes in the address. Your pointers don't look wrong to me.

	— F

_______________________________________________

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: What should be the same object doesn't seem to be
      • From: Paul Bruneau <email@hidden>
References: 
 >What should be the same object doesn't seem to be (From: Paul Bruneau <email@hidden>)

  • Prev by Date: Re: CoreData model optimization? (slow on insert with fetches)
  • Next by Date: Re: NSCell subclass editing
  • Previous by thread: What should be the same object doesn't seem to be
  • Next by thread: Re: What should be the same object doesn't seem to be
  • Index(es):
    • Date
    • Thread