Re: [NSCFNumber intValue]: unrecognized selector
Re: [NSCFNumber intValue]: unrecognized selector
- Subject: Re: [NSCFNumber intValue]: unrecognized selector
- From: Steve Rossi <email@hidden>
- Date: Fri, 26 Sep 2008 23:41:36 -0500
- Resent-date: Sun, 28 Sep 2008 23:02:31 -0500
- Resent-from: Steve Rossi <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
On Sep 26, 2008, at 11:12 PM, Clark Cox wrote:
On Fri, Sep 26, 2008 at 8:57 PM, <email@hidden>
wrote:
On Sep 26, 2008, at 11:22 AM, j o a r wrote:
On Sep 25, 2008, at 6:22 AM, Steve Rossi wrote:
I've deduced that he crash seems to be something timing related
which
occurs only at application startup, and only under certain
conditions (i.e.
reproduce occassionlly by opening an NSOpenPanel modal dialog
before the
application is fully up and running). When I say the application
is fully up
and running, I mean a secondary thread has retrieved data from a
network
source and populated a model class. This secondary thread
cyclically updates
the data about 8x per second by means of a timer in the secondary
thread's
run loop.
I use Cocoa bindings to display the data in the UI. I'm sure the
problem
is happening in the bindings, but I'm having trouble finding where.
In the general case, and with few exceptions, you can't call your
UI on
non-main threads. This means that you can't drive UI updates based
on KVO
notifications from non-main threads. Could this be your problem?
j o a r
Yes, that is correct. A separate thread is spawned which updates
the model -
consequently driving UI updates based on KVO notifications.
It is the only thread that is updating the model -
That does not matter, the UI is not thread safe; causing the KVO
notifications that are listened to by UI elements to be fired on any
thread other than the main one is asking for trouble.
the main thread does very
little except respond to fairly minimal UI events.
It works very reliably it seems ... except on these occassions when
the
OpenPanel is opened from the main thread.
I can think through whether I really need that separate thread. But
is there
a way to make the model updates from the 2nd thread safe?
No. If UI elements are observing the model, you *must* perform the
model modifications on the main thread. As Joar suggested, this can be
accomplished through the use of the -performSelectorOnMainThread:...
methods.
Thanks! I understand now. I've reworked it so that model updates are
performed in the Main thread and it works great!
I much appreciate the help!
_______________________________________________
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