• 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
binding crash when not inlined
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

binding crash when not inlined


  • Subject: binding crash when not inlined
  • From: LAURENS Jérôme <email@hidden>
  • Date: Fri, 25 May 2007 14:23:47 +0200

Hi,

Excuse me for being long.

Here is my problem: my app crashes inside the didChangeValueForKey: cocoa method with an EXC_BAD_ACCESS
The didChangeValueForKey: comes from a KVC compliant setter.
When I inline my setter, the crash does not occur.


I have a simple graph of dependent properties, which are bound to buttons and controllers in interface builder.

I have a basic setter for the "macroEditor":

Each time another property name selectedMode changes, the macro editor must change accordingly.
So, here is setSelectedMode: I start by erasing the previous macro editor, then I change the selected mode, and finally I set the new macro editor.


Here comes the funny part: If I use the setter, the app crashes in the didChangeValueForKey:
If I inline the code of the setter, no crash at all:


What is the difference?

- (void)setSelectedMode:(NSString *)newMode;
{
	NSString * oldMode = [self selectedMode];
	id new = nil;
#ifdef __EXC_BAD_ACCESS__
	[self setMacroEditor:new];<--------  HERE IS THE CRASH
#else
// inlined setter
//- (void)setMacroEditor:(id)new;
//{
	id old = [self valueForKey:@"macroEditor_meta"];
	if(![old isEqual:new])
	{
		[self willChangeValueForKey:@"macroEditor"];
		[[old retain] autorelease];
		[self setValue:new forKey:@"macroEditor_meta"];
		[self didChangeValueForKey:@"macroEditor"];
	}
//    return;
//}
#endif
	[self willChangeValueForKey:@"selectedMode"];
	...
}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Re: NSColor + Bindings
  • Next by Date: Non collapsable NSSplitView
  • Previous by thread: NSDocumentController Question
  • Next by thread: Non collapsable NSSplitView
  • Index(es):
    • Date
    • Thread