Re: trying to glue a cocoa ui to a pthread application / subclassing nsview

2008-06-03 Thread Sean McBride
On 6/2/08 7:49 PM, Michael Toy said:

trying to put a cocoa ui on an existing pthreads app.

You might want to take note of this warning then:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/
Multithreading/CreatingThreads/chapter_4_section_4.html#//apple_ref/doc/
uid/1057i-CH15-125024-BAJGFJED

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


trying to glue a cocoa ui to a pthread application / subclassing nsview

2008-06-02 Thread Michael Toy
trying to put a cocoa ui on an existing pthreads app.  need to figure out how 
to let some random thread report to the ui that re-drawing the view would be a 
good idea. 


here is what i am trying to do, and this could be quite stupid but this is the 
best i've been able to figure out all by myself.

in my view class i do

- (id)initWithFrame:(NSRect)frameRect
{
[super initWithFrame:frameRect];
cache_view_obect(self);
}

- (void)dataIsDirty
{
   [self setNeedsDisplay:YES];
}

in my application delegate i do

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
   NSView* dataview = get_cached_view();
   tell_pthread_app_about_nsview(dataview);
}

and then deep in my pthread code i do:

if (ns_view_object) {
  [ns_view_object performSelectorOnMainThread:dataDirtySelector withObject:nil 
waitUntilDone:NO];
}

what I find is that my initWithFrame method is not being called ... so i have 
two questions ...

my drawRect: IS being called, so I know my custom view is being instantiated.  
why is my init not being called? i thought i figured out the documentaiton 
enough to understand that the phrase This method is the designated initializer 
for the NSView class. Returns an initialized object. meant that this was the 
only method i needed to write to have custom behavior at creation time.

forget that, is there another way to win?

thanks in advance, i am happy to accept pointers to the documentation i should 
have found.

-michael
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: trying to glue a cocoa ui to a pthread application / subclassing nsview

2008-06-02 Thread Quincey Morris


On Jun 2, 2008, at 19:49, Michael Toy wrote:

what I find is that my initWithFrame method is not being called ...  
so i have two questions ...


my drawRect: IS being called, so I know my custom view is being  
instantiated.  why is my init not being called? i thought i figured  
out the documentaiton enough to understand that the phrase This  
method is the designated initializer for the NSView class. Returns  
an initialized object. meant that this was the only method i needed  
to write to have custom behavior at creation time.


forget that, is there another way to win?

thanks in advance, i am happy to accept pointers to the  
documentation i should have found.


If you designed your view in IB, so that it's in a nib file,  
initWithFrame is not necessarily called when your application runs.  
(initWithCoder may be called instead.) See:


	http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/chapter_6_section_2.html#/ 
/apple_ref/doc/uid/TP40002978-CH7-SW20


In that case, it's simplest to put your custom initialization in  
awakeFromNib instead.


If you're creating your view programatically, then, yes, initWithFrame  
should be getting called.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]