Can someone explain this crash I'm getting when attempting to use a view-based NSOutlineView? The crash only happens on OS X Lion (10.7), not Mountain Lion (10.8). If I run the app on ML, everything works fine. But if I run it on Lion, it crashes with the "cannot decode object of class (NSSourceListBackgroundView)" error below. This happens even if I set the build target (not just the deployment target) to the 10.7 SDK (it builds against both the 10.7 and 10.8 SDKs with no warnings or errors, and runs fine on 10.8 when built against either).
Am I unknowingly using some 10.8-only feature here that isn't being flagged by the compiler? I have customized the backgrounds of the NSTableCellView and NSTableRowView objects used by the outline view, if that matters, and my app uses Autolayout. I couldn't find anything in the Apple changelogs, header files, or NSOutlineView/NSTableView documentation about this, and I was under the impression that view-based NSOutlineViews were compatible with 10.7. I've used NSTableView extensively before, and never had problems like this, although this is the first time I've tried doing an NSOutlineView.
I searched for this on Google and quite a few other places, and all I was able to find was some discussion of what looks like an identical problem on a German-language site that didn't seem to have a resolution (from what I could tell using Google Translate).
*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSSourceListBackgroundView)
0 CoreFoundation 0x00007fff944fcf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff95110d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff944fcd8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff944fcd14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff96f29705 _decodeObjectBinary + 2714
5 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
6 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
7 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
8 Foundation 0x00007fff96f28ab2 _decodeObject + 201
9 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
10 AppKit 0x00007fff91e2667f -[NSScrollView initWithCoder:] + 240
11 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
12 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
13 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
14 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
15 Foundation 0x00007fff96f28ab2 _decodeObject + 201
16 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
17 AppKit 0x00007fff91e083a1 -[NSCustomView initWithCoder:] + 652
18 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
19 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
20 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
21 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
22 Foundation 0x00007fff96f28ab2 _decodeObject + 201
23 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
24 AppKit 0x00007fff91e083a1 -[NSCustomView initWithCoder:] + 652
25 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
26 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
27 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
28 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
29 Foundation 0x00007fff96f28ab2 _decodeObject + 201
30 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
31 AppKit 0x00007fff91e083a1 -[NSCustomView initWithCoder:] + 652
32 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
33 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
34 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
35 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
36 Foundation 0x00007fff96f28ab2 _decodeObject + 201
37 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
38 AppKit 0x00007fff91e083a1 -[NSCustomView initWithCoder:] + 652
39 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
40 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
41 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
42 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
43 Foundation 0x00007fff96f28ab2 _decodeObject + 201
44 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
45 AppKit 0x00007fff91e279cf -[NSClipView initWithCoder:] + 56
46 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
47 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
48 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
49 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
50 Foundation 0x00007fff96f28ab2 _decodeObject + 201
51 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
52 AppKit 0x00007fff91e2667f -[NSScrollView initWithCoder:] + 240
53 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
54 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
55 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
56 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
57 Foundation 0x00007fff96f28ab2 _decodeObject + 201
58 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
59 AppKit 0x00007fff91e083a1 -[NSCustomView initWithCoder:] + 652
60 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
61 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
62 Foundation 0x00007fff96f0145c -[NSArray(NSArray) initWithCoder:] + 486
63 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
64 Foundation 0x00007fff96f28ab2 _decodeObject + 201
65 AppKit 0x00007fff91e08832 -[NSView initWithCoder:] + 1051
66 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
67 Foundation 0x00007fff96f28ab2 _decodeObject + 201
68 AppKit 0x00007fff91ef993e -[NSWindowTemplate initWithCoder:] + 3998
69 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
70 Foundation 0x00007fff96f2a976 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1193
71 Foundation 0x00007fff96f2a377 -[NSSet(NSSet) initWithCoder:] + 519
72 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
73 Foundation 0x00007fff96f28ab2 _decodeObject + 201
74 AppKit 0x00007fff91d0d1b9 -[NSIBObjectData initWithCoder:] + 2099
75 Foundation 0x00007fff96f29797 _decodeObjectBinary + 2860
76 Foundation 0x00007fff96f28ab2 _decodeObject + 201
77 AppKit 0x00007fff91d0c864 loadNib + 235
78 AppKit 0x00007fff91d0bdb8 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
79 AppKit 0x00007fff91d0bcd3 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
80 AppKit 0x00007fff91d0bc16 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
81 AppKit 0x00007fff91f7ccd7 NSApplicationMain + 398
Additional Info: Since NSSourceListBackgroundView is apparently not part of the public API, I started looking around for where it's being instantiated. From looking at the XML in my .xib file, I was able to determine that they are apparently subviews of the NSScrollView that contains the NSOutlineView in question (so IB puts them in there, apparently?). I inserted a log statement to dump the subviews of the NSScrollView and there are a bunch of NSSourceListBackgroundView objects in there.
There are two NSScroller objects and one NSClipView, as expected. But there are also a bunch of these NSSourceListBackgroundView objects that apparently can't be instantiated on Lion (and that have no corresponding public header file that I can see). None of my other view-based NSTableView objects have this, except for the NSOutlineView.
Also, I DO NOT have the highlight style set to "source list": it is set to "None".
Does anyone know what the purpose of these objects is, or why IB added them to my XIB file? Is my XIB corrupt? I would REALLY rather not have to rebuild it, so I'm hoping not.
I ended up fixing this by simply deleting the entire NSOutlineView and its containing NSScrollView from my xib file and reconstructing them exactly the same way from scratch. When I did this, the mysterious NSSourceListBackgroundView objects were no longer present in the xib, and the crash on Lion stopped happening. It seems to still work perfectly fine on both Lion and Mountain Lion without them.
I never found a great explanation for why they were ever there in the first place (and would be interested if anyone can reproduce it), but my guess is that this was caused by an Xcode/IB bug. I've noticed in the past that files created by IB can be a bit "brittle" and intolerant of lots of fiddling around with their options (which is sort of annoying since making it easy to change options is kind of the whole point of having IB instead of just doing everything in code). So probably I changed some option on that part of the UI that left these objects behind as "cruft" in the xib because IB didn't clean it up. Going straight to the final design when reconstructing it avoided the issue.