• 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
Argh never-ending troubles with bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Argh never-ending troubles with bindings


  • Subject: Argh never-ending troubles with bindings
  • From: Rick Mann <email@hidden>
  • Date: Wed, 08 Feb 2017 15:44:15 -0800

I have the simplest of Document-based macOS apps created in Xcode 8.2.3. In the Document.makeWindowControllers method, I set my ViewController's representedObject to the document.

override func makeWindowControllers() {
    let storyboard = NSStoryboard(name: "Main", bundle: nil)
    let windowController = storyboard.instantiateController(withIdentifier: "Document Window Controller") as! NSWindowController

    let vc = windowController.contentViewController as! ViewController
    vc.representedObject = self

    self.addWindowController(windowController)
}


In the Storyboard, I bind an Array Controller in the View Controller scene to ViewController.self.representedObject.managedObjectContext.

I don't have anything bound to the Array Controller (yet). But after launching and displaying the window, I get this (note the first message is me making sure my representedObject is getting set):

ViewController.swift:25    Set represented object to: Optional(<PromotionalChargeManager.Document: 0x600000120960>)
2017-02-08 15:39:41.178728 PromotionalChargeManager[51621:17330300] [General] Cannot perform operation without a managed object context
2017-02-08 15:39:41.181165 PromotionalChargeManager[51621:17330300] [General] (
	0   CoreFoundation                      0x00007fffc9edd0db __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fffdeb6ea2a objc_exception_throw + 48
	2   CoreFoundation                      0x00007fffc9f5a9c5 +[NSException raise:format:] + 197
	3   AppKit                              0x00007fffc80281bc -[_NSManagedProxy _managedObjectContext] + 66
	4   AppKit                              0x00007fffc80281dc -[_NSManagedProxy _persistentStoreCoordinator] + 22
	5   AppKit                              0x00007fffc802824f -[_NSManagedProxy _entity] + 46
...

Now, as far as I can tell, I'm doing EXACTLY what Apple says I should do in

	https://developer.apple.com/library/content/qa/qa1871/_index.html

Note that I've also tried setting the Array Controller's content binding to gobbledegook, hoping for a complaint about something not being KVO-compliant for that nonexistent property. No such luck.

What am I doing wrong?

Thanks!

--
Rick Mann
email@hidden



_______________________________________________

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: Argh never-ending troubles with bindings
      • From: Ken Thomases <email@hidden>
    • Re: Argh never-ending troubles with bindings
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: What generates NSURLErrorUnsupportedURL?
  • Next by Date: Re: Argh never-ending troubles with bindings
  • Previous by thread: Re: What generates NSURLErrorUnsupportedURL?
  • Next by thread: Re: Argh never-ending troubles with bindings
  • Index(es):
    • Date
    • Thread