Binding name must be same as ivar name?
Binding name must be same as ivar name?
- Subject: Binding name must be same as ivar name?
- From: Ricky Sharp <email@hidden>
- Date: Thu, 24 Feb 2005 07:00:41 -0600
In the document...
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html>
soon after Figure 6 it mentions "Note that the binding name need not necessarily correspond to the name of an actual instance variable"
I started with my working palette item (IIBackground, a subclass of NSView) that has two properties that could be bound: baseColor and baseImageName. Those are the names of the ivars, names uses in the accessors, and the names of my custom bindings.
I then decided to change the binding names to IIBaseColor and IIBaseImageName to be a bit more unique.
I dropped in the modified palette and fired up IB to create a test nib. I was able to see and work with the two bindings just as before. Testing the interface also worked as expected. However, two problems occurred:
(1) In the console, I noticed these entries:
2005-02-24 06:44:59.529 Interface Builder[751] Error accessing property for binding IIBaseColor of object <IIBackground: 0x45f5fb0>
2005-02-24 06:44:59.532 Interface Builder[751] Error accessing property for binding IIBaseImageName of object <IIBackground: 0x45f5fb0>
(2) IB once again crashed on exit:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0xd8000000
Thread 0 Crashed:
0 libobjc.A.dylib 0x90831578 _class_lookupMethodAndLoadCache + 0xd8
1 libobjc.A.dylib 0x90831298 objc_msgSend + 0xb8
2 com.apple.CoreFoundation 0x90197f28 CFDictionaryRemoveAllValues + 0x200
3 com.apple.CoreFoundation 0x901a5fc8 __CFDictionaryDeallocate + 0x54
4 com.apple.CoreFoundation 0x90190cf0 CFRelease + 0x1e8
5 com.apple.Foundation 0x90a5c53c -[NSException dealloc] + 0x44
6 com.apple.Foundation 0x909f15d4 NSPopAutoreleasePool + 0x164
7 com.apple.AppKit 0x92dfdc78 -[NSApplication run] + 0x264
8 com.apple.InterfaceBuilder 0x00017780 0x1000 + 0x16780
9 com.apple.InterfaceBuilder 0x00036914 0x1000 + 0x35914
10 dyld 0x8fe1a558 _dyld_start + 0x64
Unlike the problem I had before, these problems occur every single time.
I then rebuilt my palette with the original names of my bindings (which match the ivars). All is well once again; no console entries, and no crashes.
Have I misread the quote in the documentation? Must the names of bindings match the ivars? If a binding name can be different, is there anything else I need to provide in my code to 'map the binding name to an ivar'?
BTW, I have no problem in leaving my binding names alone; was just trying to avoid future collisions. Although now that I think about it, if Apple ever added _baseColor or _baseImageName attributes to NSView, I'd want to rename my attributes and thus would probably need to rename the binding name too.
Hmm, should I perhaps rename my ivars to start with 'ii' (e.g. iiBaseColor) and then also use that for the binding name? Or am I being too paranoid over collisions :)
Thanks,
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden