Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

ArrayController in non-document based Applications

I just tried to use the ArrayController in an app. The app was not document based. I did everything as you are supposed to do, I made up a class called AppControll, set it Files Owner of the XIB file, connected the contend Array and so on. There were no warnings or errors, the compiler said No Issues, the Build was suchsessfull. But before the window has opened, the Application crashed. On the console was this log:


2011-05-17 16:28:45.652 MyApp[9637:903] An uncaught exception was raised

2011-05-17 16:28:45.656 MyApp[9637:903] [<NSApplication 0x10011b240> valueForUndefinedKey:]: this class is not key value coding-compliant for the key boxArray.

2011-05-17 16:28:45.792 MyApp[9637:903] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSApplication 0x10011b240> valueForUndefinedKey:]: this class is not key value coding-compliant for the key boxArray.'

*** Call stack at first throw:

(

0 CoreFoundation 0x00007fff8059a7b4 __exceptionPreprocess + 180

1 libobjc.A.dylib 0x00007fff864c30f3 objc_exception_throw + 45

2 CoreFoundation 0x00007fff805f2969 -[NSException raise] + 9

3 Foundation 0x00007fff867abb8e -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 245

4 Foundation 0x00007fff866db488 -[NSObject(NSKeyValueCoding) valueForKey:] + 420

5 AppKit 0x00007fff8810a384 -[NSApplication(NSScripting) valueForKey:] + 492

6 Foundation 0x00007fff866dedcc -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 226

7 AppKit 0x00007fff87e9fb6f -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171

8 AppKit 0x00007fff88065f80 -[NSArrayDetailBinder _refreshDetailContentInBackground:] + 368

9 AppKit 0x00007fff87e92a33 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 557

10 AppKit 0x00007fff87e6f546 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1172

11 AppKit 0x00007fff87e6d88d loadNib + 226

12 AppKit 0x00007fff87e6cd9a +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248

13 AppKit 0x00007fff87e6cbd2 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326

14 AppKit 0x00007fff87e6a153 NSApplicationMain + 279

15 MyApp 0x0000000100001302 main + 34

16 MyApp 0x00000001000012d4 start + 52

)

terminate called after throwing an instance of 'NSException'


The debugger tells me "Programm recieved signal SIGBART"


If I cut the bnding to the contend array, the Applications stats as usual, but it dosent work, because there is no contend array.


Then I tried something else. I made up a new project, this time a document-based one, and did exactly the same as I did before. It worked well and fine the way it should work. There was no problem and the ArrayController worked fine. I don`t think a made mistake writing the name of the array, because I allways copied and pasted the name to the IB. So I would like to know if it is possible to use an ArrayController in a Non-document based Application? What do i have to do differently? The reference about the ArrayController does not mention this. It would be great if you could help me soon, thank you.

Xcode 4-OTHER

Posted on May 17, 2011 7:44 AM

Reply
4 replies

May 17, 2011 10:01 AM in response to K T

No, but actually this was not my Problem But It helped me figure out what the problem is in detail. If you use a document based application, NSDocument can call the subclass NSPersistentDocument. This automatically reads out the model (if you use Core Data. I do`t like Core Data because it`s sometimes a bit strange and it`s hard to hunt down bugs there, but I think basically the problem is the same) and create a managedObjectContext, wich is needed to run the NSArray Controller. The big question is now, how to call something simular to NSPersistentDocument wich is not a subclass ob NSDocument but of NSObject.

May 17, 2011 10:40 AM in response to Elefantosque

I think you are on the wrong track with NSPersistentDocument. While NSArrayController is designed to support Core Data, it doesn't require Core Data.


Your error message says you have bound the key boxArray to NSApplication. That isn't going to work. Which class supports the boxArray key? In a document-based application, that would likely be your NSDocument subclass. If you don't have a document-based application, your application delegate needs to provide that binding.

ArrayController in non-document based Applications

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.