• 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
Re: Debugging Bindings in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging Bindings in Cocoa


  • Subject: Re: Debugging Bindings in Cocoa
  • From: mmalcolm crawford <email@hidden>
  • Date: Tue, 17 Feb 2004 11:19:40 -0800

On Feb 17, 2004, at 9:47 AM, Gabriele de Simone wrote:

On Feb 17, 2004, at 12:07 PM, Scott Anguish wrote:

On Feb 17, 2004, at 9:06 AM, Gabriele de Simone wrote:

Often times, when debugging Bindings-code in Cocoa (adding & removing items) I get this message printed out in my console:
-[_NSStateMarker boolValue]: selector not recognized
It usually takes me a while to find out what the problem is, because the above message is quite abstract. What does it mean, but more importantly are there better ways to extract error conditions from Cocoa?

In general, this message means that you're attempting to send the boolValue method to something that doesn't implement it. This is more indicative of a program error (that is, a code issue) rather than an error condition that the user might encounter.
In this particular case, it looks like you've bound to selection on something, and when there is a multiple selection you're asking the boolean value, when if there is a multiple selection you won't get all the objects, you'll get a Marker instead.
it'd be easier to determine the problem if you showed us some code.

There isn't much source code to show, unfortunately. I implemented interactive filtering on a NSArrayController using one of the examples I found on: http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
What happened is that when the controller was being filtered, any insertion that did not match the filter would fail. I understand that filtering is a bit of a hack, but it also seems odd that none of the controller objects posts something like this: "object could not be inserted". The NSStateMarker warning is a little too late in the chain of events to make sense of what's happening.

I'm not sure why you didn't see an "Object could not be inserted" error -- I got that?

I'm also not sure why you regard filtering as "a bit of a hack"? There's a clear entry point in the API for this, and it generally works well enough.

For this particular case, mea culpa for not noticing the issue before. This can be solved with "a bit of a hack". You can readily enough keep a track of the most-recently added object, and in arrangeObjects: automatically add it to the arrangeObjects array. I've updated the example here:

<http://homepage.mac.com/mmalc/CocoaExamples/FilteringController.zip>

There may be a better solution, but this should work for now, at least. If I come up with something better, I'll post a notice.

In general, it is also hard to follow what goes on behind the scenes without the source code of the Cocoa framework (and without meaningful console messages).

Bindings adds a level of abstraction which certainly can in some cases make it more difficult to determine where a problem lies(*), but most standard rules of debugging still apply. In particular, if you get an error message on the console, take it literally. If you get a message saying that a selector was not recognized, then something somewhere is being sent a message to invoke a method it doesn't implement... A likely situation is that there's an incorrect key specified in a binding.

mmalc

(*) On the other hand, it's likely you have rather less code to wade through, so tracking down any code-based errors should be easier... It is important to remember, of course, that an error may also be present in your nib file.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Debugging Bindings in Cocoa
      • From: Gabriele de Simone <email@hidden>
References: 
 >Debugging Bindings in Cocoa (From: Gabriele de Simone <email@hidden>)
 >Re: Debugging Bindings in Cocoa (From: Scott Anguish <email@hidden>)
 >Re: Debugging Bindings in Cocoa (From: Gabriele de Simone <email@hidden>)

  • Prev by Date: Re: Drawing shadows under views
  • Next by Date: Re: Insert two objects under the same column
  • Previous by thread: Re: Debugging Bindings in Cocoa
  • Next by thread: Re: Debugging Bindings in Cocoa
  • Index(es):
    • Date
    • Thread