Re: Race condition with awakeFromNib?
Re: Race condition with awakeFromNib?
- Subject: Re: Race condition with awakeFromNib?
- From: "Kyle Sluder" <email@hidden>
- Date: Wed, 18 Jun 2008 14:09:49 -0400
On Wed, Jun 18, 2008 at 1:04 PM, David Carlisle
<email@hidden> wrote:
> I have a navigator object which maintains a stack of NSViewControllers.
> When I create a new NSViewController and push it to the navigator, I want
> the view's back button to show the name of the previous view. If the
> navigator tries to set the title of the button, the button is still null
> because it has not yet awoke from the nib.
By the time -awakeFromNib is called, all outlets will point to valid
objects. It sounds like you're doing something too early.
> The navigator can pass the
> previous view to the new view so that when the new view does an
> awakeFromNib, it can get the title of the previous view and set its back
> button accordingly.
This also sounds like bad design. Perhaps you want to abstract things
a bit further? I don't know exactly what you're doing, but why do you
have a button that does the same thing on each of your subviews,
rather than one button outside the subviews that sends a -goBack:
action or something of that sort?
> This works, but I'm concerned that if awakeFromNib is
> being done in a separate thread then I have a race condition between
> awakeFromNib and the navigator setting the previous view. Though it works
> now, might it break with a multicore computer?
AppKit is not thread safe, and everything* is done on the main thread.
--Kyle Sluder
* For some value of "everything".
_______________________________________________
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