drawing in a separate thread

2008-05-02 Thread Graham Cox
I think I would like to try drawing my app's content in a secondary  
thread to see if it will improve performance and teh snappy™. Docs on  
this topic are a bit sketchy, and I've not been able to put my finger  
on any sample code that is pertinent.


The docs mention bracketing all drawing between lockFocusIfCanDraw:  
and unlockFocus, which sounds OK, but it's when I should be creating  
my thread that has me puzzled. Should I spawn a new thread for each  
update, or should I have a worker thread that just keeps going,  
repeatedly doing any needed drawing? If the former, where should I  
spawn the thread? If the latter, how will it know when something needs  
to be drawn (and if nothing, can I make it sleep until there is)? Do I  
need one thread per view, or can a single thread handled different  
views of the same class (that do share the same drawing code otherwise).


I realise these questions must sound rather fundamental, but nothing  
in the Cocoa Drawing Guide or Thread Guide really addresses them. I  
have used threads before to perform tasks not involving drawing, so  
I'm not completely unfamiliar with them, but I haven't tried drawing  
on a secondary thread before.


Any pointers (to sample code, 3rd party code, or just tips) gratefully  
received - thanks in advance.



G.___

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: drawing in a separate thread

2008-05-02 Thread Kyle Sluder
On Fri, May 2, 2008 at 3:13 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
>  I realise these questions must sound rather fundamental, but nothing in the
> Cocoa Drawing Guide or Thread Guide really addresses them. I have used
> threads before to perform tasks not involving drawing, so I'm not completely
> unfamiliar with them, but I haven't tried drawing on a secondary thread
> before.

The reason these questions aren't addressed in the guide is because
they are highly dependent on just what you are doing.  Only you can
determine when something needs to be updated.

As for spawning multiple threads, you want your drawing to be
performed really quickly.  I would strongly advocate keeping a thread
around for the life of your view and having it sit an a loop that ends
with it performing a blocking read on some IPC port.  That way it gets
scheduled off the processor but you don't suffer the thread-creation
or -destruction penalty every time you perform a draw.

Drawing from a secondary thread isn't an easy task, so perhaps you
might want to consider whether it's possible to avoid doing so.  Maybe
you can draw into an image on the secondary thread, and then when
necessary use -performSelectorOnMainThread:withObject:waitUntilDone:
to send the view a -setNeedsDisplay: message when after your thread
has completed its drawing.  Then the view can overwrite its own buffer
with it.  Be careful of synchronization issues, of course.

HTH,
--Kyle Sluder
___

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: Interesting NSPathControl Behavior

2008-05-02 Thread Kyle Sluder
On Thu, May 1, 2008 at 9:47 PM, Mike Rossetti <[EMAIL PROTECTED]> wrote:
> So I've discovered an interesting behavior in NSPathControl and am wondering
> if it warrants a Radar.

Since you are overriding -setObjectValue: it's pretty much necessary
for you to post your code before making any conjectures regarding a
bug in NSPathControl.

--Kyle Sluder
___

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]


Disabling screen turning off

2008-05-02 Thread Jere Gmail
Hi.
I know I can stop the machine from going to sleep through calling the function
UpdateSystemActivity ( UInt8 activity );
But I also want to stop it from turning off the screen, as quicktime or vlc do.
How can I do this?

-- 
http://zon7blog.wordpress.com/
And again we fall.
___

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: CGevent and cocoa compatibility

2008-05-02 Thread John Clayton
Probably means you'll need to use the event taps API and swallow the  
event - which is relatively simple to achieve as long as you can  
install an event tap that isnt a listener only.  I presume since  
you're already talked about CGEvent structures, that this is indeed  
what you are doing - correct me if I'm wrong.


Installing an event tap that modifies the event chain won't require  
special privs (from memory), so long as you don't install it at the  
window server level.


Does this send you in the right direction?

--
John Clayton
http://www.coderage-software.com/


On 2/05/2008, at 8:32 AM, Ben Lachman wrote:

Does anyone know how to get the keycode out of a NX_SYSDEFINED  
CGEvent?  If so, is that keycode the same thing you'd get out of say  
(([event data1] & 0x) >> 16)? I'm trying to support the  
media keys on the Apple aluminum keyboards without having iTunes  
also get the events.


Thanks,

->Ben

--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: [EMAIL PROTECTED]
twitter: @benlachman
mobile: 740.590.0009



___

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/john_clayton 
%40mac.com


This email sent to [EMAIL PROTECTED]


___

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]


Graphics seen when volume is modified.

2008-05-02 Thread John Clayton

Hi All,

Does anyone know of some code that mimics the graphics that are  
displayed by Apple when one modifies the system volume?  Specifically  
the grey box + white shadowed text that pops up briefly.  I want to do  
something similar in my app, so any kind of guiding code would be  
useful.


Any info about the box or code that emulates this would be useful,

Thanks!

--
John Clayton
http://www.coderage-software.com/



___

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: Xcode debugger quality

2008-05-02 Thread Jean-Daniel Dupas
No, but it remain the "Load symbols lazily" preference that should be  
disabled.


It may solve some "debugger does not break" issues.

Le 2 mai 08 à 06:36, Scott Ribe a écrit :


This may not apply anymore


It doesn't even exist in Xcode 3.

--
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]



___

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: CGevent and cocoa compatibility

2008-05-02 Thread Bill Cheeseman
on 2008-05-02 4:34 AM, John Clayton at [EMAIL PROTECTED] wrote:

> Installing an event tap that modifies the event chain won't require
> special privs (from memory), so long as you don't install it at the
> window server level.

Working with the key down and key up events via event taps requires the user
to turn on the "Enable access for assistive devices" setting in the
Universal Access pane of System Preferences.

Traditionally, apps that require this setting to be turned on test whether
it is on and, if not, ask the user to turn it on (often opening the
Universal Access pane for the user on request). Starting with Tiger, you can
turn this setting on programmatically by embedding an AppleScript script in
your application, but it requires the user to authenticate and leave the
setting turned on globally. Starting with Leopard, you can make a single
application "trusted" by accessibility, by authenticating once at install
time or first launch without turning on the global setting at all (this
feature was implemented in Tiger but is said to have been rendered useless
by a bug; I haven't tried it in Tiger, but I suspect it might actually have
worked if done right).

However, I'm not sure event taps will notice the special function keys on
any keyboard. The OP could do some initial testing of this with my free
PreFab Event Taps Testbench application, here:
.

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.com


___

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: class_addMethod and type encodings.

2008-05-02 Thread Keith Duncan
3) The only doco I can find for type encodings in ObjC is the  
"Runtime System > Type Encodings" page. Is there any other doco I  
should be reading?


You can use the @encode() helper. This is also useful when using  
NS(U)Integer as it will encode the correct type for 32/64 bit  
depending on the compile without you having to worry about changing  
the strings yourself.


Keith
___

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: drawing in a separate thread

2008-05-02 Thread Graham Cox


On 2 May 2008, at 6:13 pm, Kyle Sluder wrote:

On Fri, May 2, 2008 at 3:13 AM, Graham Cox <[EMAIL PROTECTED]>  
wrote:
I realise these questions must sound rather fundamental, but  
nothing in the
Cocoa Drawing Guide or Thread Guide really addresses them. I have  
used
threads before to perform tasks not involving drawing, so I'm not  
completely
unfamiliar with them, but I haven't tried drawing on a secondary  
thread

before.


The reason these questions aren't addressed in the guide is because
they are highly dependent on just what you are doing.  Only you can
determine when something needs to be updated.



Well the current single-threaded app already does all of that, and so  
I end up with setNeedsDisplayInRect: calls being made to the view as  
usual. Then I get a drawRect: to draw whatever accumulated on the  
previous loop. It's the actual rendering that I'm hoping to offload  
onto another thread - and so use a separate core, leaving the main  
thread to continue handling user input which *should* make the app  
feel faster even though the amount of drawing going on is the same  
(Corollary question: does Quartz thread any of its drawing anyway?  
Maybe there's no advantage in this if it does).


I found this old posting by John C Randolph:


"In a multithreaded application, the main thread is still responsible
for redisplaying dirty views through the same process as a
single-threaded application. The drawRect: method of every dirty view
is called in the main thread. If the drawing needs to be done in
another thread, the drawRect: method for the view should arrange for
the secondary thread to do the drawing and not do any drawing in
drawRect:."



So what I guess needs to happen is that when the view gets a drawRect:  
call it needs to flag to the secondary thread that it should go ahead  
and perform the redraw, instead of doing it synchronously itself, so  
something like:



- (void)drawRect:(NSRect) updateRect
{
if( threaded )
	[thread doDrawingWithRect:updateRect inView:self]; // thread wakes up  
and calls [view doDrawingWithRect:] then sleeps

else
[self doDrawingWithRect:updateRect]; // standard synchronous drawing
}


All of my drawing is completely within the rules, in that it's  
performed within drawRect:, and any updates needed end up in  
setNeedsDisplayInRect:, so it seems to me that the drawing in the  
second thread should be straightforward enough (and also easy to  
switch between the two "modes" of operation). At this stage I consider  
it an experiment to see what the benefits or difficulties might be.




As for spawning multiple threads, you want your drawing to be
performed really quickly.  I would strongly advocate keeping a thread
around for the life of your view and having it sit an a loop that ends
with it performing a blocking read on some IPC port.  That way it gets
scheduled off the processor but you don't suffer the thread-creation
or -destruction penalty every time you perform a draw.


From what you're saying, I should have a worker thread that waits for  
a request to draw, do the drawing, then go back to sleep until next  
time. What isn't clear is if this thread should be per-view, or used  
by all views that work this way, and how exactly it should be flagged  
to do the drawing (and all the sleep issues, etc). I'm not sure what  
an IPC port is (I will look it up) but I get the general idea. If you  
can point me in the right direction to answer some of these, I'm happy  
to experiment with what's needed on the drawing side of things (and  
I'm hoping it's relatively little different from the single-threaded  
case).


So my question at this stage isn't about drawing but about setting up  
and controlling the worker thread, (I think).


Drawing from a secondary thread isn't an easy task, so perhaps you
might want to consider whether it's possible to avoid doing so.  Maybe
you can draw into an image on the secondary thread, and then when
necessary use -performSelectorOnMainThread:withObject:waitUntilDone:
to send the view a -setNeedsDisplay: message when after your thread
has completed its drawing.  Then the view can overwrite its own buffer
with it.  Be careful of synchronization issues, of course.

HTH,
--Kyle Sluder


___

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: drawing in a separate thread

2008-05-02 Thread Jean-Daniel Dupas
You can have a look at DistributedObject. I think you can publish a  
drawer object in your drawing thread and then, just call draw fro your  
main thread.


To be more generic, a worker thread may do this:

- start and setup thread.
- create IPC objects. (publish an object using Distributed object for  
example)

- wait and dispatch messages. ([[NSRunLoop currentRunLoop] run]);
- release resources.
- end.


Le 2 mai 08 à 13:07, Graham Cox a écrit :



On 2 May 2008, at 6:13 pm, Kyle Sluder wrote:

On Fri, May 2, 2008 at 3:13 AM, Graham Cox <[EMAIL PROTECTED]>  
wrote:
I realise these questions must sound rather fundamental, but  
nothing in the
Cocoa Drawing Guide or Thread Guide really addresses them. I have  
used
threads before to perform tasks not involving drawing, so I'm not  
completely
unfamiliar with them, but I haven't tried drawing on a secondary  
thread

before.


The reason these questions aren't addressed in the guide is because
they are highly dependent on just what you are doing.  Only you can
determine when something needs to be updated.



Well the current single-threaded app already does all of that, and  
so I end up with setNeedsDisplayInRect: calls being made to the view  
as usual. Then I get a drawRect: to draw whatever accumulated on the  
previous loop. It's the actual rendering that I'm hoping to offload  
onto another thread - and so use a separate core, leaving the main  
thread to continue handling user input which *should* make the app  
feel faster even though the amount of drawing going on is the same  
(Corollary question: does Quartz thread any of its drawing anyway?  
Maybe there's no advantage in this if it does).


I found this old posting by John C Randolph:


"In a multithreaded application, the main thread is still responsible
for redisplaying dirty views through the same process as a
single-threaded application. The drawRect: method of every dirty view
is called in the main thread. If the drawing needs to be done in
another thread, the drawRect: method for the view should arrange for
the secondary thread to do the drawing and not do any drawing in
drawRect:."



So what I guess needs to happen is that when the view gets a  
drawRect: call it needs to flag to the secondary thread that it  
should go ahead and perform the redraw, instead of doing it  
synchronously itself, so something like:



- (void)drawRect:(NSRect) updateRect
{
   if( threaded )
	[thread doDrawingWithRect:updateRect inView:self]; // thread wakes  
up and calls [view doDrawingWithRect:] then sleeps

   else
[self doDrawingWithRect:updateRect]; // standard synchronous drawing
}


All of my drawing is completely within the rules, in that it's  
performed within drawRect:, and any updates needed end up in  
setNeedsDisplayInRect:, so it seems to me that the drawing in the  
second thread should be straightforward enough (and also easy to  
switch between the two "modes" of operation). At this stage I  
consider it an experiment to see what the benefits or difficulties  
might be.




As for spawning multiple threads, you want your drawing to be
performed really quickly.  I would strongly advocate keeping a thread
around for the life of your view and having it sit an a loop that  
ends
with it performing a blocking read on some IPC port.  That way it  
gets

scheduled off the processor but you don't suffer the thread-creation
or -destruction penalty every time you perform a draw.


From what you're saying, I should have a worker thread that waits  
for a request to draw, do the drawing, then go back to sleep until  
next time. What isn't clear is if this thread should be per-view, or  
used by all views that work this way, and how exactly it should be  
flagged to do the drawing (and all the sleep issues, etc). I'm not  
sure what an IPC port is (I will look it up) but I get the general  
idea. If you can point me in the right direction to answer some of  
these, I'm happy to experiment with what's needed on the drawing  
side of things (and I'm hoping it's relatively little different from  
the single-threaded case).


So my question at this stage isn't about drawing but about setting  
up and controlling the worker thread, (I think).


Drawing from a secondary thread isn't an easy task, so perhaps you
might want to consider whether it's possible to avoid doing so.   
Maybe

you can draw into an image on the secondary thread, and then when
necessary use -performSelectorOnMainThread:withObject:waitUntilDone:
to send the view a -setNeedsDisplay: message when after your thread
has completed its drawing.  Then the view can overwrite its own  
buffer

with it.  Be careful of synchronization issues, of course.

HTH,
--Kyle Sluder


___

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 you

Re: Graphics seen when volume is modified.

2008-05-02 Thread I. Savant

Any info about the box or code that emulates this would be useful,


  There's no public API, but there's this:
  http://growl.info/documentation/developer/

--
I.S.


___

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: Cache Class review (low priority)

2008-05-02 Thread Gregory Weston

Jens Alfke wrote:


On 1 May '08, at 4:49 PM, Western Botanicals wrote:


[NSTimer scheduledTimerWithTimeInterval: defaultSleepTime target:
self selector: @selector(run:) userInfo: nil repeats: YES];


That timer is autoreleased, so you have to retain it or it'll go away
after your init method returns.


Not unless the docs are lying (and based on heavy timer usage in some  
of my apps, I'm going to claim they're not). From the NSTimer overview:


"Note in particular that run loops retain their timers, so you can  
release a timer after you have added it to a run loop."


That said, proper conformance to the memory contract would be that  
you *do* retain it if you do this...


Typically you'd then assign it to an ivar; then when you need to  
stop the

timer, you call -invalidate and -release on it.


But as long as the OP has no intention of manually invalidating the  
timer, what's already there is sufficient.

___

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]


Unit Test error XCode 3.1 (Beta)

2008-05-02 Thread Rakesh Vidyadharan
I am a beginner with Cocoa and XCode.  I am trying to develop a simple  
game for iPhone/iPod Touch and OS X.  To get started I created a  
simple framework that represents (code only for iPhone) the data model  
and logic engine for the game.  I am now writing some simple unit  
tests for the core framework.  I went through the unit test  
documentation provided by Apple to set up my test.  However, I could  
not get very far with the unit test.  It seems to be an error in  
invoking the framework rather than an issue with my code (mainly  
because I do not see any output related to test case execution).  The  
following is the error I get:


"error: Failed tests for architecture 'i386' (GC OFF)" at line 376 in  
RunPlatformUnitTests.include.


Can someone point in the right direction as to the cause of this  
error.  I am assuming this has something to do with settings for my  
Test target.


Thanks
Rakesh

smime.p7s
Description: S/MIME cryptographic signature
___

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: Disabling screen turning off

2008-05-02 Thread Jeff Nouwen

On May-2-2008, at 2:26 AM, Jere Gmail wrote:
I know I can stop the machine from going to sleep through calling  
the function

UpdateSystemActivity ( UInt8 activity );
But I also want to stop it from turning off the screen, as quicktime  
or vlc do.

How can I do this?


Pass in UsrActivity as your activity value:
UsrActivity
Delays idle sleep and dimming by timeout time.
Available in Mac OS X v10.0 and later.
Declared in Power.h

- Jeff
___

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: NSFormatter, NSTextfield and bindings

2008-05-02 Thread Yann Disser

Ok, I found my problem myself. In


-(BOOL)getObjectValue:(id*)obj forString:(NSString*)string
  errorDescription:(NSString**)error
{
  if(obj)
*obj = string;
  return YES;
}


the line

*obj = string;

needs to be replaced with
  *obj = [NSString stringWithString:string];

I always assume that gc takes care of all my memory managing needs...

I hope this helps someone in the future ^^

Yann

On 1. May 2008, at 15:51, Yann Disser wrote:

I have a NSTextfield which is bound to some string-valued attribute.  
It is set to update continuously and everything works fine.


As I only want to allow the user to enter numbers, I subclassed  
NSFormatter and attached an instance to the NSTextField "formatter"  
outlet in IB.


Now my attribute gets set exactly ONCE (?) - the very first time I  
enter a valid character in the text field. I found the following  
with google: http://www.cocoabuilder.com/archive/message/cocoa/2007/6/26/185130

and it seems that this behaviour might be intentional... (?!)

How can I obtain the desired behaviour of my text field with  
continuous updates?


This is how my Formatter looks like:

@implementation StrictNumberFormatter

-(NSString*)stringForObjectValue:(id)anObject
{
  if(![anObject isKindOfClass:[NSString class]])
return nil;
  return anObject;
}

-(BOOL)getObjectValue:(id*)obj forString:(NSString*)string
  errorDescription:(NSString**)error
{
  if(obj)
*obj = string;
  return YES;
}

-(BOOL)isPartialStringValid:(NSString*)partialString
  newEditingString:(NSString**)newString
  errorDescription:(NSString**)error
{
  //return YES; //doesn't help either
  if([partialString isEqual:@""])
return YES;
  NSString* correct =
[[NSNumber numberWithInt:[partialString intValue]] stringValue];
  return [correct isEqual: partialString];
}

@end

Thanks for your help,
Yann


___

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]


CALayer backgroundFilters can't cope with animated backgrounds?

2008-05-02 Thread Jonathan del Strother
Hi,
I have a CALayer covering my view, with a blur background filter.
Works fine for static cases - everything behind the blur layer is
blurred.
However, for layers that update themselves continuously - eg
QTMovieLayer or QCCompositionLayer - or even just plain layers that
move, I get ugly trails around the edges of the layers behind the
blurring layer, as though it's not properly redrawing anything outside
the bounds of the layer being blurred.

To try and get round this, I subclassed CALayer and tried hooking into
a variety of display methods (drawInContext, display,
setNeedsDisplay), in the hope that I could call setNeedsDisplay on the
blur layer whenever one of the layers being blurred changes, but those
methods don't seem to be called during normal operation (eg when a
QCCompositionLayer renders a new frame, or when a layer changes
position).

See http://pastie.org/190470 - this is a simple QC layer on the left,
and a couple of moving red/green layers.  The QC Layer is permanently
surrounded by that white border, and the moving layers leave a trail
behind them as they move around.

What am I missing?
Jon
___

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]


Forwarding messages from an application delegate

2008-05-02 Thread Matthew Gertner
Hi,

I am implementing an application delegate for a framework (Mozilla)
that already registers its own delegate internally. Ideally I would
like to be able to handle specific delegate messages in my class (in
this case adding items to the dock tile menu) and forward all other
invocations to the old delegate. So before I call [[NSApplication
sharedApplication] setDelegate] for my delegate, I retrieve the
existing delegate and save it in a member variable (mOldDelegate). I
thought that I could get invocations to forward automatically like
this:

- (void)forwardInvocation:(NSInvocation *)anInvocation
{
 if ([mOldDelegate respondsToSelector:[anInvocation selector]])
   [anInvocation invokeWithTarget:mOldDelegate];
 else
   [super forwardInvocation:anInvocation];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
 if ([mOldDelegate respondsToSelector:aSelector])
   return [mOldDelegate methodSignatureForSelector:aSelector];
 else
   return [super methodSignatureForSelector: aSelector];
}

For some reason neither methodSignatureForSelector nor
forwardInvocation is ever called. Perhaps this has something to do
with the way messages are sent to the delegate by the application. As
a result, my delegate never forwards to the old delegate. Any guidance
would be appreciated.

Matt
___

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: Forwarding messages from an application delegate

2008-05-02 Thread Graham Cox
You also need to override -respondsToSelector: and return a logical OR  
of your delegate plus the old delegate's response, something like:


- (BOOL)respondsToSelector:(SEL) aSelector
{
BOOL responds = [super respondsToSelector:aSelector];

if( !responds )
responds = [[self oldDelegate] respondsToSelector:aSelector];

return responds;
}

Also, forwardInvocation isn't called unless your object has already  
rejected the message, so its implementation should look like:


- (void)forwardInvocation:(NSInvocation*) invocation
{
SEL aSelector = [invocation selector];

if ([[self oldDelegate] respondsToSelector:aSelector])
[invocation invokeWithTarget:[self controller]];
else
[self doesNotRecognizeSelector:aSelector];
}


hth,


G.




On 3 May 2008, at 12:35 am, Matthew Gertner wrote:


Hi,

I am implementing an application delegate for a framework (Mozilla)
that already registers its own delegate internally. Ideally I would
like to be able to handle specific delegate messages in my class (in
this case adding items to the dock tile menu) and forward all other
invocations to the old delegate. So before I call [[NSApplication
sharedApplication] setDelegate] for my delegate, I retrieve the
existing delegate and save it in a member variable (mOldDelegate). I
thought that I could get invocations to forward automatically like
this:

- (void)forwardInvocation:(NSInvocation *)anInvocation
{
if ([mOldDelegate respondsToSelector:[anInvocation selector]])
  [anInvocation invokeWithTarget:mOldDelegate];
else
  [super forwardInvocation:anInvocation];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
if ([mOldDelegate respondsToSelector:aSelector])
  return [mOldDelegate methodSignatureForSelector:aSelector];
else
  return [super methodSignatureForSelector: aSelector];
}

For some reason neither methodSignatureForSelector nor
forwardInvocation is ever called. Perhaps this has something to do
with the way messages are sent to the delegate by the application. As
a result, my delegate never forwards to the old delegate. Any guidance
would be appreciated.

Matt
___

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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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: Forwarding messages from an application delegate

2008-05-02 Thread Andy Lee
Delegate methods aren't sent at all unless the delegate implements  
them.  I think your delegate is going to have to implement all  
possible delegate methods and then forward them *if* the old delegate  
implements them, and otherwise return an appropriate default value if  
there is a return value.


This means the application will send all possible delegate methods to  
you, as opposed to just the ones the old delegate implements, but  
hopefully that won't cause any problems.  I suppose you could do some  
low-level hacking where you detect which methods the old delegate  
implements and then remove unneeded methods from your delegate class.


--Andy

On May 2, 2008, at 10:35 AM, Matthew Gertner wrote:

Hi,

I am implementing an application delegate for a framework (Mozilla)
that already registers its own delegate internally. Ideally I would
like to be able to handle specific delegate messages in my class (in
this case adding items to the dock tile menu) and forward all other
invocations to the old delegate. So before I call [[NSApplication
sharedApplication] setDelegate] for my delegate, I retrieve the
existing delegate and save it in a member variable (mOldDelegate). I
thought that I could get invocations to forward automatically like
this:

- (void)forwardInvocation:(NSInvocation *)anInvocation
{
if ([mOldDelegate respondsToSelector:[anInvocation selector]])
  [anInvocation invokeWithTarget:mOldDelegate];
else
  [super forwardInvocation:anInvocation];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
if ([mOldDelegate respondsToSelector:aSelector])
  return [mOldDelegate methodSignatureForSelector:aSelector];
else
  return [super methodSignatureForSelector: aSelector];
}

For some reason neither methodSignatureForSelector nor
forwardInvocation is ever called. Perhaps this has something to do
with the way messages are sent to the delegate by the application. As
a result, my delegate never forwards to the old delegate. Any guidance
would be appreciated.

Matt
___

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/aglee%40mac.com

This email sent to [EMAIL PROTECTED]


___

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: Forwarding messages from an application delegate

2008-05-02 Thread Andy Lee

This is smarter than my suggestion.

--Andy

On May 2, 2008, at 10:44 AM, Graham Cox wrote:
You also need to override -respondsToSelector: and return a logical  
OR of your delegate plus the old delegate's response, something like:


- (BOOL)respondsToSelector:(SEL) aSelector
{
BOOL responds = [super respondsToSelector:aSelector];

if( !responds )
responds = [[self oldDelegate] respondsToSelector:aSelector];

return responds;
}

Also, forwardInvocation isn't called unless your object has already  
rejected the message, so its implementation should look like:


- (void)forwardInvocation:(NSInvocation*) invocation
{
   SEL aSelector = [invocation selector];

   if ([[self oldDelegate] respondsToSelector:aSelector])
   [invocation invokeWithTarget:[self controller]];
   else
   [self doesNotRecognizeSelector:aSelector];
}


hth,


G.




On 3 May 2008, at 12:35 am, Matthew Gertner wrote:


Hi,

I am implementing an application delegate for a framework (Mozilla)
that already registers its own delegate internally. Ideally I would
like to be able to handle specific delegate messages in my class (in
this case adding items to the dock tile menu) and forward all other
invocations to the old delegate. So before I call [[NSApplication
sharedApplication] setDelegate] for my delegate, I retrieve the
existing delegate and save it in a member variable (mOldDelegate). I
thought that I could get invocations to forward automatically like
this:

- (void)forwardInvocation:(NSInvocation *)anInvocation
{
if ([mOldDelegate respondsToSelector:[anInvocation selector]])
 [anInvocation invokeWithTarget:mOldDelegate];
else
 [super forwardInvocation:anInvocation];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
if ([mOldDelegate respondsToSelector:aSelector])
 return [mOldDelegate methodSignatureForSelector:aSelector];
else
 return [super methodSignatureForSelector: aSelector];
}

For some reason neither methodSignatureForSelector nor
forwardInvocation is ever called. Perhaps this has something to do
with the way messages are sent to the delegate by the application. As
a result, my delegate never forwards to the old delegate. Any  
guidance

would be appreciated.

Matt
___

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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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/aglee%40mac.com

This email sent to [EMAIL PROTECTED]


___

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: Forwarding messages from an application delegate

2008-05-02 Thread Matthew Gertner
Thanks, Graham. It seems like the superclass deals with rejecting the
message, but I was missing respondsToSelector. Added that and now it
works perfectly!

Matt

On Fri, May 2, 2008 at 4:44 PM, Graham Cox <[EMAIL PROTECTED]> wrote:
> You also need to override -respondsToSelector: and return a logical OR of
> your delegate plus the old delegate's response, something like:
>
>  - (BOOL)respondsToSelector:(SEL) aSelector
>  {
> BOOL responds = [super respondsToSelector:aSelector];
>
> if( !responds )
> responds = [[self oldDelegate]
> respondsToSelector:aSelector];
>
> return responds;
>  }
>
>  Also, forwardInvocation isn't called unless your object has already
> rejected the message, so its implementation should look like:
>
>  - (void)forwardInvocation:(NSInvocation*) invocation
>  {
> SEL aSelector = [invocation selector];
>
> if ([[self oldDelegate] respondsToSelector:aSelector])
> [invocation invokeWithTarget:[self controller]];
> else
> [self doesNotRecognizeSelector:aSelector];
>  }
>
>
>  hth,
>
>
>  G.
>
>
>
>
>
>
>  On 3 May 2008, at 12:35 am, Matthew Gertner wrote:
>
>
> >
> >
> >
> > Hi,
> >
> > I am implementing an application delegate for a framework (Mozilla)
> > that already registers its own delegate internally. Ideally I would
> > like to be able to handle specific delegate messages in my class (in
> > this case adding items to the dock tile menu) and forward all other
> > invocations to the old delegate. So before I call [[NSApplication
> > sharedApplication] setDelegate] for my delegate, I retrieve the
> > existing delegate and save it in a member variable (mOldDelegate). I
> > thought that I could get invocations to forward automatically like
> > this:
> >
> > - (void)forwardInvocation:(NSInvocation *)anInvocation
> > {
> > if ([mOldDelegate respondsToSelector:[anInvocation selector]])
> >  [anInvocation invokeWithTarget:mOldDelegate];
> > else
> >  [super forwardInvocation:anInvocation];
> > }
> >
> > - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
> > {
> > if ([mOldDelegate respondsToSelector:aSelector])
> >  return [mOldDelegate methodSignatureForSelector:aSelector];
> > else
> >  return [super methodSignatureForSelector: aSelector];
> > }
> >
> > For some reason neither methodSignatureForSelector nor
> > forwardInvocation is ever called. Perhaps this has something to do
> > with the way messages are sent to the delegate by the application. As
> > a result, my delegate never forwards to the old delegate. Any guidance
> > would be appreciated.
> >
> > Matt
> > ___
> >
> > 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/graham.cox%40bigpond.com
> >
> > This email sent to [EMAIL PROTECTED]
> >
>
>



-- 
*** Note that my email has changed to [EMAIL PROTECTED]
Please update your address book accordingly. ***
___

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: Forwarding messages from an application delegate

2008-05-02 Thread Matthew Gertner
Seems like you can "pretend" you implement them using
respondsToSelector (see Graham's reply).

On Fri, May 2, 2008 at 4:53 PM, Andy Lee <[EMAIL PROTECTED]> wrote:
> Delegate methods aren't sent at all unless the delegate implements them.  I
> think your delegate is going to have to implement all possible delegate
> methods and then forward them *if* the old delegate implements them, and
> otherwise return an appropriate default value if there is a return value.
>
>  This means the application will send all possible delegate methods to you,
> as opposed to just the ones the old delegate implements, but hopefully that
> won't cause any problems.  I suppose you could do some low-level hacking
> where you detect which methods the old delegate implements and then remove
> unneeded methods from your delegate class.
>
>  --Andy
>
>
>
>  On May 2, 2008, at 10:35 AM, Matthew Gertner wrote:
>
> >
> >
> >
> > Hi,
> >
> > I am implementing an application delegate for a framework (Mozilla)
> > that already registers its own delegate internally. Ideally I would
> > like to be able to handle specific delegate messages in my class (in
> > this case adding items to the dock tile menu) and forward all other
> > invocations to the old delegate. So before I call [[NSApplication
> > sharedApplication] setDelegate] for my delegate, I retrieve the
> > existing delegate and save it in a member variable (mOldDelegate). I
> > thought that I could get invocations to forward automatically like
> > this:
> >
> > - (void)forwardInvocation:(NSInvocation *)anInvocation
> > {
> > if ([mOldDelegate respondsToSelector:[anInvocation selector]])
> >  [anInvocation invokeWithTarget:mOldDelegate];
> > else
> >  [super forwardInvocation:anInvocation];
> > }
> >
> > - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
> > {
> > if ([mOldDelegate respondsToSelector:aSelector])
> >  return [mOldDelegate methodSignatureForSelector:aSelector];
> > else
> >  return [super methodSignatureForSelector: aSelector];
> > }
> >
> > For some reason neither methodSignatureForSelector nor
> > forwardInvocation is ever called. Perhaps this has something to do
> > with the way messages are sent to the delegate by the application. As
> > a result, my delegate never forwards to the old delegate. Any guidance
> > would be appreciated.
> >
> > Matt
> >
> > ___
> >
> > 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/aglee%40mac.com
> >
> > This email sent to [EMAIL PROTECTED]
> >
>
>  ___
>
>  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/matthew%40allpeers.com
>
>  This email sent to [EMAIL PROTECTED]
>



-- 
*** Note that my email has changed to [EMAIL PROTECTED]
Please update your address book accordingly. ***
___

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: Displaying one NSTextStorage with two sets of temporary attributes

2008-05-02 Thread Ross Carter
I'm not sure whether you need to change a particular set of attributes  
(font, line spacing, tabs, etc) in each layout manager or merely  
suppress the display of text in other series. If the former, I would  
think that the layout manager is not best place to handle the  
attribute fixing. I'd think about either subclassing NSTextStorage and  
have it modify the attributes that it receives from and sends to the  
various layout managers, or subclassing the typesetter and overriding  
setAttributedString: to change the attributes as needed. I haven't  
ever done either of those things, mind you, so I don't know whether  
they would work.


It just seems to me that by the time the layout manager goes to work,  
it's difficult to change the attributes (except for things that don't  
affect the layout, such as underlining) because of the complex  
interaction between the layout manager and the typesetter. You  
probably want to intervene before the attributedString gets converted  
into glyphs.


On May 1, 2008, at 8:25 PM, Adam C.M. Solove wrote:


Hello all,

In the episode of Late Night Cocoa on the text system, [
http://www.macdevnet.com/index.php/shows/latenightcocoa/37-latenightcocoa/93-lnc005
] Juan Pablo Claude described a setup with multiple NSLayoutManagers
editing text from the same NSTextStorage and then said, off-hand, that
you might do this if you wanted to display the same text with
different fonts. I am curious if anyone could discuss how this might
be done: displaying the same underlying attributed string, but
formatting it before the NSLayoutManager tries to lay it out and
formatting it back when the NSTextView sends back changes. I cannot
find specific information on subclassing NSLayoutManager to make these
sorts of changes.

(I know there is an Apple demo [TextViewConfig,
http://developer.apple.com/samplecode/TextViewConfig/index.html] which
shows multiple layout managers, but these both render the exact same
attributed string (except that one view has been essentially zoomed to
twice the size). I am curious if it is possible to actually change
temporary attributes in one LayoutManager but not the other, and then
change them back appropriately before sending events to the
NSTextStorage.)

End technical discussion

Begin back story for those interested:

I am a relatively new Cocoa developer working on an open-source
project for academics. I  recently spent considerable time working on
a web-based version of this application before learning that the
hardest part was technically infeasible because of some limitations in
HTML's designmode. In starting with Cocoa, I will be happy if the
project and required learning takes many years, so long as there is an
answer in advance to this one difficult question.

The application is an editor for a specific subset of the TEI XML
guidelines for encoding literary works and scholarly commentaries on
them. The underlying data maps very nicely into an attributed string,
because it is a single text divided up into separate 'series' (main
text, footnotes, cross-links) The series are all anchored together,
but would best be displayed apart, with first the main text, then each
series of notes. I believe the easiest way to do this would be to have
a single underlying NSTextStorage, to attribute every range of text to
one series, and then to create various subclasses (or formatters) for
NSLayoutManager that each display only text in one particular series.
I suspect this could also be done with a custom Typesetter and the
method setNotShownAttribute:forGlyphAtIndex:, but am curious if there
is a more general hook to set attributes on the string before layout.

Thank you,

Adam Solove
___

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/rosscarter%40mac.com

This email sent to [EMAIL PROTECTED]



___

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: Forwarding messages from an application delegate

2008-05-02 Thread Bill Cheeseman
on 2008-05-02 10:44 AM, Graham Cox at [EMAIL PROTECTED] wrote:

> You also need to override -respondsToSelector: and return a logical OR
> of your delegate plus the old delegate's response, something like:

I use this techhnique in my PreFab Event Taps Testbench utility.

I call this the "delegate server" design pattern. In a general sense, it
allows you to control programmatically whether a class "implements" a
delegate method. For example, you could have a preference setting in an
application that turns the delegate methods on or off, or switches between
different sets of delegate methods. The uses for this are probably few, but
it served me perfectly for a test utility that is designed to see how a
variety of applications handle certain system-level facilities with a
variety of delegate method and callback method implementations.

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.com


___

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: Forwarding messages from an application delegate

2008-05-02 Thread Graham Cox


On 3 May 2008, at 12:56 am, Matthew Gertner wrote:


Seems like you can "pretend" you implement them using
respondsToSelector (see Graham's reply).



Exactly - the delegate is sent the message if it says it implements  
it, even if it really doesn't. Then NSObject says "wait a minute, I  
don't implement that!" so it checks if -forwardInvocation: is  
implemented, and if so turns the message into an invocation and passes  
it to -forwardInvocation:, which can then pass it to the real object  
that does implement it. If -forwardInvocation: isn't implemented, it  
gives up by calling -doesNotRecognizeSelector:


It's a very neat mechanism.

And you can take it further: One use I've found for this is getting  
messages from first responder down to some more appropriate object  
deeper inside a complex hierarchy - the view (firstR) forwards  
anything it doesn't handle to its controller, which does the same to  
other objects it knows about, which do the same to things they  
contain... it makes it seem as if the view can magically handle all  
sorts of messages and actions but in reality they are implemented by  
the underlying objects that can implement the messages directly,  
including all the usual protocols such as e.g. NSMenuItemValidation.  
As the internal context changes, menu items magically enable/disable  
as appropriate, and yet the view needs to know nothing about what's  
going on underneath.


Coming from a C++ background, this sort of thing is what makes Obj-C  
so compelling.


G.


___

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: Cache Class review (low priority)

2008-05-02 Thread Jens Alfke


On 2 May '08, at 4:37 AM, Gregory Weston wrote:

Not unless the docs are lying (and based on heavy timer usage in  
some of my apps, I'm going to claim they're not). From the NSTimer  
overview:


"Note in particular that run loops retain their timers, so you can  
release a timer after you have added it to a run loop."


Yikes! Guess I still have a few things left to learn :-P Thanks for  
the tip.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: drawing in a separate thread

2008-05-02 Thread Jens Alfke


On 2 May '08, at 4:20 AM, Jean-Daniel Dupas wrote:

You can have a look at DistributedObject. I think you can publish a  
drawer object in your drawing thread and then, just call draw fro  
your main thread.


DO might be overkill for this scenario. The background thread really  
just needs to run a while() loop that waits on a condition-lock, then  
draws. The main thread's -drawRect: method just sets the condition on  
the lock to trigger the background thread.


If more information needs to be passed to the thread, you can use a  
producer/consumer queue, but unfortunately Foundation doesn't come  
with one of those built-in; there must be source code for one lying  
around, though.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: drawing in a separate thread

2008-05-02 Thread Graham Cox
OK, I have managed to implement this after a lot of poring over the  
docs. I'm not sure if it's the most efficient way to actually handle  
the thread communication, but it does work (using NSMachPort). As I  
hoped, there isn't a big problem with drawing the graphics as they  
should be, apart from a bit of occasional blank output when the window  
is resized - BUT, performance is terrible. Worse than synchronous  
drawing by a long shot - I haven't measured it because it's really  
obvious how much the drawing lags the user - must be an order of  
magnitude slower.


Question is of course, why? The thread is calling the exact same  
drawing code as the view normally does, so that's a constant. So it  
must be down to the thread communication/overhead. Or perhaps just my  
minimal understanding of threads, locks, ports etc. ;-)


When I need to draw, I flag that fact to the class (the class is  
handling all views using a single secondary thread, but in fact I only  
have tried it so far with one), and the class bundles the update rect  
and view into an NSInvocation, which is placed in a queue. An  
NSPortMessage is used to wake up the thread which pulls the invocation  
off the queue and invokes it, which does the drawing. Maybe the use of  
NSInvocation is slow? Not sure why it should be.


Here's the pertinent parts of the code - have I done something silly?  
(all vars starting with 's' are static globals):



+ (void)setDrawUsingSecondaryThread:(BOOL) threaded
{
if ( threaded && !sThreadedDrawing )
{
// create the thread and a port for it

NSPort* port = [NSMachPort port];
[port setDelegate:self];

		// create a queue for the drawing invocations that are received -  
this is done to maintain order when

// several views may be needing update.

sDrawingThreadInvocationQueue = [[NSMutableArray alloc] init];

// create a lock used to mediate access to the queue

sQueueLock = [[NSLock alloc] init];

// start the thread

		[NSThread  
detachNewThreadSelector:@selector(secondaryThreadEntryPoint:)  
toTarget:self withObject:port];


sThreadedDrawing = YES;
sDrawingThreadPort = port;
}

sDrawingThreadShouldRun = threaded;
}


+ (void)secondaryThreadEntryPoint:(NSPort*) port
{
NSAutoreleasePool*  pool = [[NSAutoreleasePool alloc] init];
NSRunLoop*  loop = [NSRunLoop currentRunLoop];

[loop addPort:port forMode:NSDefaultRunLoopMode];
NSDate* endDate = [NSDate distantFuture];

do
{
[loop runMode:NSDefaultRunLoopMode beforeDate:endDate];
}
while([self updateThreadShouldRun]);

[loop removePort:port forMode:NSDefaultRunLoopMode];
[port invalidate];
[pool drain];
}


+ (void)		signalSecondaryThreadShouldDrawInRect:(NSRect) rect withView: 
(NSView*) aView

{
if([self drawUsingSecondaryThread])
{
		NSInvocation* invocation = [NSInvocation  
invocationWithMethodSignature:[aView 	 
methodSignatureForSelector:@selector(drawContentInRect:)]];


[invocation setTarget:aView];
[invocation setSelector:@selector(drawContentInRect:)];
[invocation setArgument:&rect atIndex:2];

// queue the invocation for processing by the thread

[sQueueLock lock];
[sDrawingThreadInvocationQueue insertObject:invocation 
atIndex:0];
[sQueueLock unlock];

// tell the thread to process the queue:

		NSPortMessage* pm = [[NSPortMessage alloc]  
initWithSendPort:sDrawingThreadPort receivePort:nil components:nil];


[pm setMsgid:1234];
[pm sendBeforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[pm release];
}
}


+ (void)handlePortMessage:(NSPortMessage*) portMessage
{
	// receive the update request on the secondary thread via the port  
message


unsigned msg = [portMessage msgid];

if( msg == 1234 && [sQueueLock tryLock])
{
		NSInvocation* inv = [[sDrawingThreadInvocationQueue lastObject]  
retain];


if ( inv != nil )
{
[sDrawingThreadInvocationQueue removeObject:inv];
[sQueueLock unlock];

NSAutoreleasePool* pool = [NSAutoreleasePool new];

NSView* aView = [inv target];

if( aView != nil

Re: drawing in a separate thread

2008-05-02 Thread Jean-Daniel Dupas


Le 2 mai 08 à 17:27, Jens Alfke a écrit :



On 2 May '08, at 4:20 AM, Jean-Daniel Dupas wrote:

You can have a look at DistributedObject. I think you can publish a  
drawer object in your drawing thread and then, just call draw fro  
your main thread.


DO might be overkill for this scenario. The background thread really  
just needs to run a while() loop that waits on a condition-lock,  
then draws. The main thread's -drawRect: method just sets the  
condition on the lock to trigger the background thread.


You're right for the.




If more information needs to be passed to the thread, you can use a  
producer/consumer queue, but unfortunately Foundation doesn't come  
with one of those built-in; there must be source code for one lying  
around, though.


—Jens


You're too. The Cocoa Threading Programmming Guide shows a way to  
implements producer/consumer using NSConditonalLock.
(http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/chapter_5_section_7.html 
)




___

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: Unit Test error XCode 3.1 (Beta)

2008-05-02 Thread Kyle Sluder
Xcode 3.1 is in beta and is therefore subject to NDA.  The iPhone SDK
is subject to NDA.  This question has nothing to do with Cocoa.

Perhaps you've posted to the wrong list?

--Kyle Sluder
___

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: Unit Test error XCode 3.1 (Beta)

2008-05-02 Thread Sean frazier

is there an Xcode 3.1/iPhone list?

thx.

sean


On May 2, 2008, at 12:16 PM, Kyle Sluder wrote:


Xcode 3.1 is in beta and is therefore subject to NDA.  The iPhone SDK
is subject to NDA.  This question has nothing to do with Cocoa.

Perhaps you've posted to the wrong list?

--Kyle Sluder
___

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/seanfrazier%40mac.com

This email sent to [EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature
___

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: Displaying one NSTextStorage with two sets of temporary attributes

2008-05-02 Thread Adam C.M. Solove
Actually, you're right that merely suppressing display is all I need.
I was assuming this would have to be done with temporary attributes,
but is there an easier way?

THank you,

Adam Solove

On Fri, May 2, 2008 at 7:57 AM, Ross Carter <[EMAIL PROTECTED]> wrote:
> I'm not sure whether you need to change a particular set of attributes
> (font, line spacing, tabs, etc) in each layout manager or merely suppress
> the display of text in other series. If the former, I would think that the
> layout manager is not best place to handle the attribute fixing. I'd think
> about either subclassing NSTextStorage and have it modify the attributes
> that it receives from and sends to the various layout managers, or
> subclassing the typesetter and overriding setAttributedString: to change the
> attributes as needed. I haven't ever done either of those things, mind you,
> so I don't know whether they would work.
>
>  It just seems to me that by the time the layout manager goes to work, it's
> difficult to change the attributes (except for things that don't affect the
> layout, such as underlining) because of the complex interaction between the
> layout manager and the typesetter. You probably want to intervene before the
> attributedString gets converted into glyphs.
>
>
>  On May 1, 2008, at 8:25 PM, Adam C.M. Solove wrote:
>
>
> >
> >
> >
> > Hello all,
> >
> > In the episode of Late Night Cocoa on the text system, [
> >
> http://www.macdevnet.com/index.php/shows/latenightcocoa/37-latenightcocoa/93-lnc005
> > ] Juan Pablo Claude described a setup with multiple NSLayoutManagers
> > editing text from the same NSTextStorage and then said, off-hand, that
> > you might do this if you wanted to display the same text with
> > different fonts. I am curious if anyone could discuss how this might
> > be done: displaying the same underlying attributed string, but
> > formatting it before the NSLayoutManager tries to lay it out and
> > formatting it back when the NSTextView sends back changes. I cannot
> > find specific information on subclassing NSLayoutManager to make these
> > sorts of changes.
> >
> > (I know there is an Apple demo [TextViewConfig,
> > http://developer.apple.com/samplecode/TextViewConfig/index.html] which
> > shows multiple layout managers, but these both render the exact same
> > attributed string (except that one view has been essentially zoomed to
> > twice the size). I am curious if it is possible to actually change
> > temporary attributes in one LayoutManager but not the other, and then
> > change them back appropriately before sending events to the
> > NSTextStorage.)
> >
> > End technical discussion
> > 
> > Begin back story for those interested:
> >
> > I am a relatively new Cocoa developer working on an open-source
> > project for academics. I  recently spent considerable time working on
> > a web-based version of this application before learning that the
> > hardest part was technically infeasible because of some limitations in
> > HTML's designmode. In starting with Cocoa, I will be happy if the
> > project and required learning takes many years, so long as there is an
> > answer in advance to this one difficult question.
> >
> > The application is an editor for a specific subset of the TEI XML
> > guidelines for encoding literary works and scholarly commentaries on
> > them. The underlying data maps very nicely into an attributed string,
> > because it is a single text divided up into separate 'series' (main
> > text, footnotes, cross-links) The series are all anchored together,
> > but would best be displayed apart, with first the main text, then each
> > series of notes. I believe the easiest way to do this would be to have
> > a single underlying NSTextStorage, to attribute every range of text to
> > one series, and then to create various subclasses (or formatters) for
> > NSLayoutManager that each display only text in one particular series.
> > I suspect this could also be done with a custom Typesetter and the
> > method setNotShownAttribute:forGlyphAtIndex:, but am curious if there
> > is a more general hook to set attributes on the string before layout.
> >
> > Thank you,
> >
> > Adam Solove
> >
> > ___
> >
> > 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/rosscarter%40mac.com
> >
> > This email sent to [EMAIL PROTECTED]
> >
> >
>
>
___

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

Re: Cache Class review (low priority)

2008-05-02 Thread Western Botanicals
Thanks for more input. I have revised it yet again... and it seems to  
be working just fine.


The reason I put the AutoReleasePools in there is because I am getting  
these errors in the output. So if you can help me find what is wrong  
that would be great. Every time I create a Date or Timer object, I get  
one or both of these:


_NSAutoreleaseNoPool(): Object 0x10a810 of class __NSCFDate  
autoreleased with no pool in place - just leaking


_NSAutoreleaseNoPool(): Object 0x10b100 of class NSCFTimer  
autoreleased with no pool in place - just leaking


I had to use a different server for the code this time. I have  
included a tester class


http://expresslanevideo.com/transfer/code/CacheTesterh.txt
http://expresslanevideo.com/transfer/code/CacheTesterm.txt
http://expresslanevideo.com/transfer/code/Cacheh13.txt
http://expresslanevideo.com/transfer/code/Cachem13.txt

Justin Giboney





On May 2, 2008, at 9:22 AM, Jens Alfke wrote:



On 2 May '08, at 4:37 AM, Gregory Weston wrote:

Not unless the docs are lying (and based on heavy timer usage in  
some of my apps, I'm going to claim they're not). From the NSTimer  
overview:


"Note in particular that run loops retain their timers, so you can  
release a timer after you have added it to a run loop."


Yikes! Guess I still have a few things left to learn :-P Thanks for  
the tip.


—Jens___

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/graphics%40westernbotanicals.com

This email sent to [EMAIL PROTECTED]


___

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]


Very strange Xcode debugger issue.

2008-05-02 Thread David Springer
Folks,

Xcode 2.5 on Leopard, app and all libs built with 10.4u SDK.

If I debug my app using Xcode 2.5 (in the GUI), I get these errors
while calling the destructor of an object created on the stack:

MyApp(26961,0xa02e3fa0) malloc: *** error for object 0x28001660:
pointer being freed was not allocated

However, when I run the app from the command line, or launch from
Finder, or even debug using gdb form the command line I do NOT get
these errors.

Has anyone seen this?  Any ideas on what is going on here?

Thanks!
- Dave.S
___

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: CGevent and cocoa compatibility

2008-05-02 Thread Ben Lachman
Yup, this is true as far as I can tell. I've got the event tap  
installed, the issue is that I'm not able to pull any useful data out  
of NX_SYSDEFINED typed events.  Any thoughts on that?


->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: [EMAIL PROTECTED]
twitter: @benlachman
mobile: 740.590.0009



On May 2, 2008, at 4:34 AM, John Clayton wrote:

Probably means you'll need to use the event taps API and swallow  
the event - which is relatively simple to achieve as long as you  
can install an event tap that isnt a listener only.  I presume  
since you're already talked about CGEvent structures, that this is  
indeed what you are doing - correct me if I'm wrong.


Installing an event tap that modifies the event chain won't require  
special privs (from memory), so long as you don't install it at the  
window server level.


Does this send you in the right direction?

--
John Clayton
http://www.coderage-software.com/


On 2/05/2008, at 8:32 AM, Ben Lachman wrote:

Does anyone know how to get the keycode out of a NX_SYSDEFINED  
CGEvent?  If so, is that keycode the same thing you'd get out of  
say (([event data1] & 0x) >> 16)? I'm trying to support  
the media keys on the Apple aluminum keyboards without having  
iTunes also get the events.



___

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: Displaying one NSTextStorage with two sets of temporary attributes

2008-05-02 Thread Ross Carter

Hi Adam,

I guess that the approach you will take depends on how the textStorage  
string is set up. Sorry, I don't know anything about TEI, so I can  
only offer general comments.


If the textStorage series are sequential and the number and sequence  
of series are known in advance, and the text has no page break  
characters (NSFormFeedCharacter), you could insert a page break at the  
end of each series. That will throw layout over to the next  
textContainer. If you have a textContainer/textView set up for each  
series, then the text will flow into the textViews that you have set  
up to show the content of each series.


If you know the character range of each series, you could override  
NSLayoutManager drawGlyphsForGlyphRange:atPoint: and have it send the  
message to super only if the glyphs in glyphRange are in the character  
range you want to display.


In short, if the question is "Is there a simple way to tell  
NSLayoutManager not to display certain character ranges," then the  
answer is: I don't think so. Personally, I wouldn't adopt either of  
the approaches I mentioned because of the complications in  
coordinating the various displays using one textStorage. For example,  
if the user pasted in some text that contains a form feed character,  
it could throw off everything.


XML is easy to parse. I think you'll find it simpler in the end to  
split the original string into separate series, make each series the  
textStorage for a textView, let the user edit each series as he  
desires, and then reassemble the series into a single string when you  
archive. Even if there were a way to tell the layoutManagers to be  
selective about what they display, you've still got a lot of work to  
do in keeping them all synchronized as the user adds and removes text.


That's just my opinion, though. Text experts like Douglas and Martin  
might have a better idea. I'd be happy to continue this discussion  
offline if you to want to kick around some more ideas.


Ross

On May 2, 2008, at 12:47 PM, Adam C.M. Solove wrote:


Actually, you're right that merely suppressing display is all I need.
I was assuming this would have to be done with temporary attributes,
but is there an easier way?

THank you,

Adam Solove

On Fri, May 2, 2008 at 7:57 AM, Ross Carter <[EMAIL PROTECTED]>  
wrote:
I'm not sure whether you need to change a particular set of  
attributes
(font, line spacing, tabs, etc) in each layout manager or merely  
suppress
the display of text in other series. If the former, I would think  
that the
layout manager is not best place to handle the attribute fixing.  
I'd think
about either subclassing NSTextStorage and have it modify the  
attributes

that it receives from and sends to the various layout managers, or
subclassing the typesetter and overriding setAttributedString: to  
change the
attributes as needed. I haven't ever done either of those things,  
mind you,

so I don't know whether they would work.

It just seems to me that by the time the layout manager goes to  
work, it's
difficult to change the attributes (except for things that don't  
affect the
layout, such as underlining) because of the complex interaction  
between the
layout manager and the typesetter. You probably want to intervene  
before the

attributedString gets converted into glyphs.


On May 1, 2008, at 8:25 PM, Adam C.M. Solove wrote:






Hello all,

In the episode of Late Night Cocoa on the text system, [


http://www.macdevnet.com/index.php/shows/latenightcocoa/37-latenightcocoa/93-lnc005

] Juan Pablo Claude described a setup with multiple NSLayoutManagers
editing text from the same NSTextStorage and then said, off-hand,  
that

you might do this if you wanted to display the same text with
different fonts. I am curious if anyone could discuss how this might
be done: displaying the same underlying attributed string, but
formatting it before the NSLayoutManager tries to lay it out and
formatting it back when the NSTextView sends back changes. I cannot
find specific information on subclassing NSLayoutManager to make  
these

sorts of changes.

(I know there is an Apple demo [TextViewConfig,
http://developer.apple.com/samplecode/TextViewConfig/index.html]  
which

shows multiple layout managers, but these both render the exact same
attributed string (except that one view has been essentially  
zoomed to

twice the size). I am curious if it is possible to actually change
temporary attributes in one LayoutManager but not the other, and  
then

change them back appropriately before sending events to the
NSTextStorage.)

End technical discussion

Begin back story for those interested:

I am a relatively new Cocoa developer working on an open-source
project for academics. I  recently spent considerable time working  
on

a web-based version of this application before learning that the
hardest part was technically infeasible because of some  
limitations in

HTML's designmode. In starting with Cocoa, I will be ha

Re: Cache Class review (low priority)

2008-05-02 Thread Jens Alfke


On 2 May '08, at 9:32 AM, Western Botanicals wrote:

The reason I put the AutoReleasePools in there is because I am  
getting these errors in the output. So if you can help me find what  
is wrong that would be great. Every time I create a Date or Timer  
object, I get one or both of these:


You're probably running this as a GUI-less tool process, i.e. directly  
calling your code from main(). If you do this, you need to create a  
top-level autorelease pool before calling into your code. In general,  
main() looks like:

int main( int argc, const char **argv ) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int result = 0;
// your program code goes here
[pool drain];
return result;
}

In a GUI application (or even a runloop-based tool) you don't have to  
worry about this, because NSRunLoop makes sure to create an  
autorelease pool whenever it calls into application code.


Speaking of runloops, your test code needs to idle the runloop in  
between its tests, to give the timer a chance to expire entries. You  
currently have some (commented-out) usleep calls, but those won't  
work, because the runloop is on your thread and has to be explicitly  
given time to run. You can replace those with
	[[NSRunLoop currentRunLoop] runUntilDate: [NSDate  
dateWithTimeIntervalSinceNow: 0.25];


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Image reflection in IKImageBrowserView

2008-05-02 Thread Jens Alfke


On 1 May '08, at 11:57 PM, Aby wrote:

   How to implement Image reflection for all the images in  
IKImageBrowserView.


You can't make the view draw reflections; it's not very customizable  
at all.


The best you can do is give it images that already have reflections in  
them. Take each of your images, draw it into a larger image, draw the  
reflection below (using a y-flip transform and a mask with an alpha  
gradient), then put the larger image in the browser.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Interesting NSPathControl Behavior

2008-05-02 Thread Corbin Dunn


On May 1, 2008, at 6:47 PM, Mike Rossetti wrote:
So I've discovered an interesting behavior in NSPathControl and am  
wondering if it warrants a Radar.


I'm building up my own presentation of the file path to be shown in  
the NSPathControl.  Specifically, if the file for which the path is  
being presented is in some standard location then I'm abbreviating  
the path.  As a simple example, if the file is in ~/Documents/ 
FIle.txt then instead of:


Users > User A > Documents > File.txt

I will show:

Documents > File.txt

The approach I'm taking is to pass a payload (an NSArray) to my  
customization of NSPathControl's setObjectValue.  In setObjectValue  
I compose a string ("/Documents/File.txt") that I pass on to [super  
setObjectValue:], which sets up the NSPathComponentCells just fine.   
Then I iterate over the pathComponentCells calling each one's  
setURL.  (And in this example that would be 'file://localhost/Users/ 
User A/Documents/' for the first cell, and 'file://localhost/Users/ 
User A/Documents/File.txt' for the second cell.)


Doing this in a forward direction gives the following cell URLs:

0. file://localhost/Users/User A/Documents/File.txt
1. NSPathCell://localhost/Documents/File.txt

Say what?

Interestingly, if I do this in a reverse direction I get the  
_proper_ cell URLs:


0. file://localhost/Users/User A/Documents/
1. file://localhost/Users/User A/Documents/File.txt

If this is a bug, I'll be happy to write up a small test app to  
present the problem.


This isn't a bug. If you pass a given string to NSPathCell, it doesn't  
know if it is a file path. Since it doesn't know it is a file path, it  
assumes the string represents some arbitrary non-file:// path, and  
creates the URL with:


result = [[[NSURL alloc] initWithScheme:[self className]  
host:@"localhost" path:[[self stringValue]  
stringByExpandingTildeInPath]] autorelease];


This lets it avoid finding icons for things which aren't really paths  
(even if they "look" like paths).


When filling up each of the pathcomponent cells, it passes along the  
same scheme, host, etc to it:


NSURL *itemUrl = [[NSURL alloc] initWithScheme:[url scheme]  
host:(host ? host : @"") path:path];


It is possible that there is an error in there, but I didn't see any  
when I was looking at the code.


Long story short: use setURL:, or manually manage the path component  
cells after calling super setObjectValue:


corbin

___

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: Graphics seen when volume is modified.

2008-05-02 Thread Christopher Nebel

On May 2, 2008, at 4:00 AM, I. Savant wrote:


Any info about the box or code that emulates this would be useful,


 There's no public API, but there's this:
 http://growl.info/documentation/developer/


Alternatively, you could mimic the effect using a transparent panel  
[1] -- I expect that's what Growl is doing.


--Chris Nebel

[1]  See 

___

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: Displaying one NSTextStorage with two sets of temporary attributes

2008-05-02 Thread Adam C.M. Solove
First, Ross, thank you for your comments. I was going about this
somewhat wrong and you took the time to think it through.

I think you are right that it would be easiest to separate the
different note series into their own TextStorage. Then I could add
custom attributes to each text that determine where they are tied
together. The delegate methods would be lots of code, but fairly
straight-forward.

I also would be curious to hear from text experts how footnotes are
normally done. I have the luxury of small blocks of text and not
worrying about page breaks, which makes the situation somewhat easier.

-Adam

On Fri, May 2, 2008 at 10:38 AM, Ross Carter <[EMAIL PROTECTED]> wrote:
> Hi Adam,
>
>  I guess that the approach you will take depends on how the textStorage
> string is set up. Sorry, I don't know anything about TEI, so I can only
> offer general comments.
>
>  If the textStorage series are sequential and the number and sequence of
> series are known in advance, and the text has no page break characters
> (NSFormFeedCharacter), you could insert a page break at the end of each
> series. That will throw layout over to the next textContainer. If you have a
> textContainer/textView set up for each series, then the text will flow into
> the textViews that you have set up to show the content of each series.
>
>  If you know the character range of each series, you could override
> NSLayoutManager drawGlyphsForGlyphRange:atPoint: and have it send the
> message to super only if the glyphs in glyphRange are in the character range
> you want to display.
>
>  In short, if the question is "Is there a simple way to tell NSLayoutManager
> not to display certain character ranges," then the answer is: I don't think
> so. Personally, I wouldn't adopt either of the approaches I mentioned
> because of the complications in coordinating the various displays using one
> textStorage. For example, if the user pasted in some text that contains a
> form feed character, it could throw off everything.
>
>  XML is easy to parse. I think you'll find it simpler in the end to split
> the original string into separate series, make each series the textStorage
> for a textView, let the user edit each series as he desires, and then
> reassemble the series into a single string when you archive. Even if there
> were a way to tell the layoutManagers to be selective about what they
> display, you've still got a lot of work to do in keeping them all
> synchronized as the user adds and removes text.
>
>  That's just my opinion, though. Text experts like Douglas and Martin might
> have a better idea. I'd be happy to continue this discussion offline if you
> to want to kick around some more ideas.
>
>  Ross
>
>
>
>  On May 2, 2008, at 12:47 PM, Adam C.M. Solove wrote:
>
>
> > Actually, you're right that merely suppressing display is all I need.
> > I was assuming this would have to be done with temporary attributes,
> > but is there an easier way?
> >
> > THank you,
> >
> > Adam Solove
> >
> > On Fri, May 2, 2008 at 7:57 AM, Ross Carter <[EMAIL PROTECTED]> wrote:
> >
> > > I'm not sure whether you need to change a particular set of attributes
> > > (font, line spacing, tabs, etc) in each layout manager or merely
> suppress
> > > the display of text in other series. If the former, I would think that
> the
> > > layout manager is not best place to handle the attribute fixing. I'd
> think
> > > about either subclassing NSTextStorage and have it modify the attributes
> > > that it receives from and sends to the various layout managers, or
> > > subclassing the typesetter and overriding setAttributedString: to change
> the
> > > attributes as needed. I haven't ever done either of those things, mind
> you,
> > > so I don't know whether they would work.
> > >
> > > It just seems to me that by the time the layout manager goes to work,
> it's
> > > difficult to change the attributes (except for things that don't affect
> the
> > > layout, such as underlining) because of the complex interaction between
> the
> > > layout manager and the typesetter. You probably want to intervene before
> the
> > > attributedString gets converted into glyphs.
> > >
> > >
> > > On May 1, 2008, at 8:25 PM, Adam C.M. Solove wrote:
> > >
> > >
> > >
> > > >
> > > >
> > > >
> > > > Hello all,
> > > >
> > > > In the episode of Late Night Cocoa on the text system, [
> > > >
> > > >
> > >
> http://www.macdevnet.com/index.php/shows/latenightcocoa/37-latenightcocoa/93-lnc005
> > >
> > > > ] Juan Pablo Claude described a setup with multiple NSLayoutManagers
> > > > editing text from the same NSTextStorage and then said, off-hand, that
> > > > you might do this if you wanted to display the same text with
> > > > different fonts. I am curious if anyone could discuss how this might
> > > > be done: displaying the same underlying attributed string, but
> > > > formatting it before the NSLayoutManager tries to lay it out and
> > > > formatting it back when the NSTextView sends back chang

[ANN] New version of AMRollOverButton with IB3 plugin

2008-05-02 Thread Andreas Mayer

Rollover buttons highlight when you move the mouse pointer over them.
The appearance is widely configurable.

Now comes with an Interface Builder 3.x plugin.

http://www.harmless.de/cocoa-code.php#rollover

This source code is available under the BSD License.


Andreas
___

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]


Making my own menubar

2008-05-02 Thread Mike
I need to make a fullscreen app in which my window takes over the main 
display. I need to be able to prevent the user from accessing the main 
system menu bar. Hiding it is no problem but I need to create my own 
menubar at the top of the fullscreen window that I create.


Is there an easy way to do this or do I have to do all my own drawing in 
order to create my own custom menubar at the top of my fullscreen window?


Thanks,

Mike
___

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: Making my own menubar

2008-05-02 Thread Shawn Erickson
On Fri, May 2, 2008 at 12:06 PM, Mike <[EMAIL PROTECTED]> wrote:
> I need to make a fullscreen app in which my window takes over the main
> display. I need to be able to prevent the user from accessing the main
> system menu bar. Hiding it is no problem but I need to create my own menubar
> at the top of the fullscreen window that I create.
>
>  Is there an easy way to do this or do I have to do all my own drawing in
> order to create my own custom menubar at the top of my fullscreen window?

What do you mean by your own menu bar exactly?

-Shawn
___

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: Making my own menubar

2008-05-02 Thread Jens Alfke


On 2 May '08, at 12:06 PM, Mike wrote:

Is there an easy way to do this or do I have to do all my own  
drawing in order to create my own custom menubar at the top of my  
fullscreen window?


You're pretty much on your own. Probably the best start is to make a  
row of NSPopUpButton controls in 'drop-down' mode. It won't be exactly  
like the real menu-bar, though (dragging from one menu to another  
won't work, nor will the accessibility keyboard shortcuts.)


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Graphics seen when volume is modified.

2008-05-02 Thread Kyle Sluder
On Fri, May 2, 2008 at 2:41 PM, Christopher Nebel <[EMAIL PROTECTED]> wrote:
>  Alternatively, you could mimic the effect using a transparent panel [1] --
> I expect that's what Growl is doing.

Unfortunately if you pass NSBorderlessWindowMask to a HUD window you
lose the rounded corners.  I'm sure there's an unsupported way to do
it, but I'm going to file a radar which asks that borderless HUD
windows get the rounded corners.

--Kyle Sluder
___

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: Cache Class review (low priority)

2008-05-02 Thread Uli Kusterer


Am 02.05.2008 um 20:03 schrieb Jens Alfke:

You're probably running this as a GUI-less tool process, i.e.  
directly calling your code from main(). If you do this, you need to  
create a top-level autorelease pool before calling into your code.  
In general, main() looks like:

int main( int argc, const char **argv ) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int result = 0;
// your program code goes here
[pool drain];
return result;
}


Well, this only shuts up the warnings, it doesn't really keep the  
memory from leaking because the pool isn't drained until the app quits.


If you have any sort of loop in your app, you'll want to put the pool  
inside that loop, so a new pool gets created and the old pool gets  
released for every command you execute.


But don't put the pool inside your accessors or other such small  
places. Particularly as generally you want a pool outside a function  
when you're returning an object from it, so the pool can temporarily  
take ownership of the object after your function has terminated. That  
is, if you're not garbage-collected, in which case this doesn't apply.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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: Unit Test error XCode 3.1 (Beta)

2008-05-02 Thread Shawn Erickson
On Fri, May 2, 2008 at 9:26 AM, Sean frazier <[EMAIL PROTECTED]> wrote:
> is there an Xcode 3.1/iPhone list?

No. Check the release notes for information on how to submit feedback
/ ask for assistance.

-Shawn
___

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: Making my own menubar

2008-05-02 Thread Mike

Shawn Erickson wrote:

On Fri, May 2, 2008 at 12:06 PM, Mike <[EMAIL PROTECTED]> wrote:

I need to make a fullscreen app in which my window takes over the main
display. I need to be able to prevent the user from accessing the main
system menu bar. Hiding it is no problem but I need to create my own menubar
at the top of the fullscreen window that I create.

 Is there an easy way to do this or do I have to do all my own drawing in
order to create my own custom menubar at the top of my fullscreen window?


What do you mean by your own menu bar exactly?

-Shawn


I mean that I need a menubar in a fullscreen window that my app owns, 
but it can't be the standard system menubar because one of the things my 
app has to do is prevent the user from accessing anything outside my app.

___

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: Graphics seen when volume is modified.

2008-05-02 Thread Shawn Erickson
On Fri, May 2, 2008 at 1:09 PM, Kyle Sluder
<[EMAIL PROTECTED]> wrote:
> On Fri, May 2, 2008 at 2:41 PM, Christopher Nebel <[EMAIL PROTECTED]> wrote:
>  >  Alternatively, you could mimic the effect using a transparent panel [1] --
>  > I expect that's what Growl is doing.
>
>  Unfortunately if you pass NSBorderlessWindowMask to a HUD window you
>  lose the rounded corners.  I'm sure there's an unsupported way to do
>  it, but I'm going to file a radar which asks that borderless HUD
>  windows get the rounded corners.

You can get rounded corners, etc. by setting the background color for
the window to be an image of the color and shape you want or by having
the content view define the shape.

/me points at 


-Shawn
___

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: Graphics seen when volume is modified.

2008-05-02 Thread Kyle Sluder
On Fri, May 2, 2008 at 4:51 PM, Shawn Erickson <[EMAIL PROTECTED]> wrote:
>  You can get rounded corners, etc. by setting the background color for
>  the window to be an image of the color and shape you want or by having
>  the content view define the shape.

Well yes, of course you can have arbitrarily-shaped windows, but that
means you can only approximate the appearance of a bezel window with
your best guess, and it isn't future-proof if Apple decides to change
the appearance in a later version of the OS.  For the same reason as
the introduction of standard template images, I think it would be
beneficial to have a standardized bezel window style.

--Kyle Sluder
___

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: Making my own menubar

2008-05-02 Thread Kyle Sluder
On Fri, May 2, 2008 at 4:44 PM, Mike <[EMAIL PROTECTED]> wrote:
>  I mean that I need a menubar in a fullscreen window that my app owns, but
> it can't be the standard system menubar because one of the things my app has
> to do is prevent the user from accessing anything outside my app.

Have you taken a look at TN2062, "Guide to Creating Kiosks on Mac OS
X"?  This document specifically addresses ways to create such an
application without resorting to something as drastic as implementing
a custom menu bar.

--Kyle Sluder
___

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: Making my own menubar

2008-05-02 Thread Andy Lee

On May 2, 2008, at 3:54 PM, Jens Alfke wrote:
Probably the best start is to make a row of NSPopUpButton controls  
in 'drop-down' mode. It won't be exactly like the real menu-bar,  
though (dragging from one menu to another won't work, nor will the  
accessibility keyboard shortcuts.)


And on Tiger the top-right and top-left corners won't be rounded.

--Andy


___

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]


Loading a .nib?

2008-05-02 Thread J. Todd Slack

Hello Guys,

So I am creating an iTunes PLugin, can anyone show me how to  
load ..nib file?


I have looked for examples and I am just not finding what I need.

Thanks,

-Jason


___

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]


NSKeyedUnarchiver memory management ?

2008-05-02 Thread Angel Todorov
Hi all,
I want to serialize in an archive a set of objects (big ones) that are
instances of a class which implements NSCoding. On deserialization, I don't
want the whole archive to be loaded in memory, but only the object for the
*key* that I am requesting.

Does NSKeyedUnarchiver (I mean, the archiving infragstructure in general) do
that ? Thanks very much

Angel
___

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: Loading a .nib?

2008-05-02 Thread J. Todd Slack

Hi Guys,

Just to clarify,

I might do this in Obj-C

[NSBundle loadNibNamed:@"SettingsDialog" owner:self;]

But not sure how to do it from a .c file.

Thoughts?

-Jason

On May 2, 2008, at 3:29 PM, J. Todd Slack wrote:


Hello Guys,

So I am creating an iTunes PLugin, can anyone show me how to  
load ..nib file?


I have looked for examples and I am just not finding what I need.

Thanks,

-Jason


___

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/mailinglists%40jasonandannette.us

This email sent to [EMAIL PROTECTED]


___

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: Loading a .nib?

2008-05-02 Thread Jonathan Hess

Hey Jason -

I don't know the specifics of iTunes plug-ins, but normally you load a  
NIB with -[NSBundle loadNibFile:externalNameTable:withZone:] method.  
That method, and some more convenient form of it are available in  
AppKit and declared in NSNibLoading.h.


Good Luck -
Jon Hess

On May 2, 2008, at 3:29 PM, J. Todd Slack wrote:


Hello Guys,

So I am creating an iTunes PLugin, can anyone show me how to  
load ..nib file?


I have looked for examples and I am just not finding what I need.

Thanks,

-Jason


___

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/jhess%40apple.com

This email sent to [EMAIL PROTECTED]


___

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: Loading a .nib?

2008-05-02 Thread J. Todd Slack

Hi Jon,

Thank you for the reply.

I don't know the specifics of iTunes plug-ins, but normally you load  
a NIB with -[NSBundle loadNibFile:externalNameTable:withZone:]  
method. That method, and some more convenient form of it are  
available in AppKit and declared in NSNibLoading.h.


Yeah, I am using:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self;]

But that is Objective-C, I need to do it from a .c file.

-Jason
___

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: Graphics seen when volume is modified.

2008-05-02 Thread Jean-Daniel Dupas


Le 2 mai 08 à 23:00, Kyle Sluder a écrit :

On Fri, May 2, 2008 at 4:51 PM, Shawn Erickson <[EMAIL PROTECTED]>  
wrote:

You can get rounded corners, etc. by setting the background color for
the window to be an image of the color and shape you want or by  
having

the content view define the shape.


Well yes, of course you can have arbitrarily-shaped windows, but that
means you can only approximate the appearance of a bezel window with
your best guess, and it isn't future-proof if Apple decides to change
the appearance in a later version of the OS.  For the same reason as
the introduction of standard template images, I think it would be
beneficial to have a standardized bezel window style.

--Kyle Sluder


The bezel item that is displayed when you change the volume has  
nothing to do with a HUD panel.
You can submit a "feature request" to request an API to use the  
BezelService but filling a bug report to say that you cannot reproduce  
the volume notification window using an HUD panel is meaningless IMH.



___

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: Loading a .nib?

2008-05-02 Thread Nick Zitzmann


On May 2, 2008, at 4:38 PM, J. Todd Slack wrote:


Yeah, I am using:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self;]

But that is Objective-C, I need to do it from a .c file.



Change the file's extension from .c to .m and then it becomes an ObjC  
file. ObjC is a true superset of C, so there's no problem in doing this.


Nick Zitzmann


___

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: Loading a .nib?

2008-05-02 Thread Uli Kusterer

Am 03.05.2008 um 00:38 schrieb J. Todd Slack:

But that is Objective-C, I need to do it from a .c file.



 No you don't. Objective C is a superset of C, so if you want to us  
Objective C, just change the file into a .m file.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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: Loading a .nib?

2008-05-02 Thread Michael Vannorsdel
You can convert this to the C equivalent if you absolutely must use C  
(off the top of my head):


Class mclass = objc_getMetaClass("NSBundle");
SEL s = @selector(loadNibNamed:owner:);
IMP f = class_getMethodImplementation(mclass,  s);

BOOL res = f(mclass, s, @"SettingsDialog", self);


On May 2, 2008, at 4:38 PM, J. Todd Slack wrote:


Yeah, I am using:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self;]

But that is Objective-C, I need to do it from a .c file.


___

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: Loading a .nib?

2008-05-02 Thread J. Todd Slack

Hi,

One question though.

When I use:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self]; // the nib name  
is SettingsDialog.nib


Xcode complains that this is the first time that self is used.

I am a bit rusty right now, can anyone explain why? I thought self  
could be used like this.


What am I missing?

Thanks.
-Jason


On May 2, 2008, at 4:31 PM, Michael Vannorsdel wrote:

You can convert this to the C equivalent if you absolutely must use  
C (off the top of my head):


Class mclass = objc_getMetaClass("NSBundle");
SEL s = @selector(loadNibNamed:owner:);
IMP f = class_getMethodImplementation(mclass,  s);

BOOL res = f(mclass, s, @"SettingsDialog", self);


On May 2, 2008, at 4:38 PM, J. Todd Slack wrote:


Yeah, I am using:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self;]

But that is Objective-C, I need to do it from a .c file.


___

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/mailinglists%40jasonandannette.us

This email sent to [EMAIL PROTECTED]


___

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]


Read XML from the web

2008-05-02 Thread Mr. Gecko

Hello how would you get xml data from the web and read it in cocoa.
My xml file is like this



	http://www.example.com/file1"; size="522656" name="File  
Number 1"/>
	http://www.example.com/file2"; size="4533" name="File  
Number 2"/>



I am using the same one that I am using for flash.
___

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: Loading a .nib?

2008-05-02 Thread Michael Vannorsdel
I should have mentioned, if you're calling from C there probably is no  
'self' since you're not calling from inside an object's method.   
You'll have to pass a pointer to the object you want to be the owner.



On May 2, 2008, at 5:33 PM, J. Todd Slack wrote:


One question though.

When I use:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self]; // the nib  
name is SettingsDialog.nib


Xcode complains that this is the first time that self is used.

I am a bit rusty right now, can anyone explain why? I thought self  
could be used like this.


What am I missing?


___

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: Loading a .nib?

2008-05-02 Thread Nick Zitzmann


On May 2, 2008, at 5:33 PM, J. Todd Slack wrote:


When I use:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self]; // the nib  
name is SettingsDialog.nib


Xcode complains that this is the first time that self is used.

I am a bit rusty right now, can anyone explain why? I thought self  
could be used like this.



If you're calling that from a C function, then "self" is undefined.  
You need to set the owner to an instance of the object that was set as  
the file's owner, if any, in the nib.


Nick Zitzmann


___

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: Read XML from the web

2008-05-02 Thread Nick Zitzmann


On May 2, 2008, at 5:36 PM, Mr. Gecko wrote:


Hello how would you get xml data from the web and read it in cocoa.



[[NSXMLDocument alloc] initWithData:[NSData dataWithContentsOfURL:@"http://somewhere.com/something.xml 
"] options:0 error:NULL];


You might want to set options and an error object though. See the  
NSData and NSXMLDocument documentation for details.


Nick Zitzmann


___

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: Rotating an NSTableView.

2008-05-02 Thread Michael Nickerson


On May 1, 2008, at 8:27 AM, Peter Hudson wrote:

I have an NSTable View inside an NSSplitView.
I rotate the table view by sending   rotateByAngle:270  to the  
enclosing scroll view.

The table lands up exactly as I want it with vertical rows.





The problem is that when I resize the split view the NSTableView  
does not change size to fit the split view movement as it does when  
the table is not rotated.


Does anyone have any idea what is going on.  I've tried all the  
usual games with setting frame and bounds etc - but to no avail.



It looks like there's a bug in NSScrollView, where it stops calling - 
tile when it's rotated.


You can work around the problem by listening to the scroll view's  
frame change notifications, and calling -tile on it manually.



I submitted a bug against this with source code to demonstrate the  
problem: 



Corbin - there's also a bug where the table headers aren't drawn  
correctly when it's rotated.  I didn't submit a bug on that one - let  
me know if you'd like me to.  It'd take just a quick edit of the  
sample code I did above to have the table headers showing.



--
Darkshadow
(aka Michael Nickerson)
http://www.nightproductions.net


___

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: Read XML from the web

2008-05-02 Thread Mr. Gecko

Thanks I will look into it
On May 2, 2008, at 6:40 PM, Nick Zitzmann wrote:



On May 2, 2008, at 5:36 PM, Mr. Gecko wrote:


Hello how would you get xml data from the web and read it in cocoa.



[[NSXMLDocument alloc] initWithData:[NSData dataWithContentsOfURL:@"http://somewhere.com/something.xml 
"] options:0 error:NULL];


You might want to set options and an error object though. See the  
NSData and NSXMLDocument documentation for details.


Nick Zitzmann




___

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]


Putting an Icon in the MenuBar

2008-05-02 Thread J. Todd Slack

Hi Everyone,

Does anyone have an example on how to put an icon in the menu bar for  
my app. I want something like the airport menu, volume menu, spaces  
menu (on Leopard), etc if this helps explain what I want to do. I am  
not even sure what to call this


Any thoughts?

Thanks,
-Jason

___

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: Putting an Icon in the MenuBar

2008-05-02 Thread Nick Zitzmann


On May 2, 2008, at 6:18 PM, J. Todd Slack wrote:

Does anyone have an example on how to put an icon in the menu bar  
for my app. I want something like the airport menu, volume menu,  
spaces menu (on Leopard), etc if this helps explain what I want to  
do. I am not even sure what to call this


Any thoughts?



Search the documentation, and the archives, for NSStatusItem.

Nick Zitzmann


___

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]


Implementing fast enumeration

2008-05-02 Thread Ben

Re-sending as this did not seem to get make it to the list.

I have been reading the documentation for implementing the  
NSFastEnumeration protocol and am having some difficulties following it.


For completeness, here is the protocol method:
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState  
*)state objects:(id *)stackbuf count:(NSUInteger)len;


typedef struct {
unsigned long state;
id *itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5]; } NSFastEnumerationState;

I have a C array where the elements within it can be converted into  
multiple objects. Say I have 5 objects. Do I provide them all in one  
go and return the total number? Or just one per call and return the  
number remaining?


Also, should the objects be returned by reference in the stackbuf  
variable, or in the itemsPtr field of the state structure?


Apologies if these are basic questions, but I got decidedly lost  
trying to follow the docs.


Ben.
___

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: Loading a .nib?

2008-05-02 Thread Graham Cox
iTunes is a Carbon app, so there is no Cocoa runtime available. You  
can use a nib, but it has to be a Carbon one, so the functions you  
need to look at are in the HIView family of Carbon functions.


There may be a way to set up a Cocoa runtime in an iTunes plugin but  
I'm not sure about that.


If you can use C++ you can at least get some object-oriented goodness  
(not as good as Obj-C though). Some years ago I wrote an iTunes plugin  
and created a little mini-framework in C++ to ease the process. It  
also uses (Carbon) nibs to display its options dialog. You might find  
it useful (source code and binary available):


http://apptree.net/ledsa.htm


hth,

G.



On 3 May 2008, at 8:29 am, J. Todd Slack wrote:

So I am creating an iTunes PLugin, can anyone show me how to  
load ..nib


___

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: Loading a .nib?

2008-05-02 Thread Brian Stern


On May 2, 2008, at 7:33 PM, J. Todd Slack wrote:


Hi,

One question though.

When I use:

[NSBundle loadNibNamed:@"SettingsDialog" owner:self]; // the nib  
name is SettingsDialog.nib


Xcode complains that this is the first time that self is used.



You probably want to create an instance of a NSWindowController  
subclass and have it load the bundle.


Also, simply converting your .c to a .m doesn't turn your plugin into  
a friendly Cocoa host.  You probably need to call NSApplicationLoad(),  
create an NSAutoReleasePool and wrap your objective-C code in a @try  
block so exceptions don't propagate back through your C code and to  
the host app.


Isn't there some sample code for building Cocoa iTunes plugins  
available somewhere that will answer these questions for you?


--
Brian Stern
[EMAIL PROTECTED]



___

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: Loading a .nib?

2008-05-02 Thread J. Todd Slack

Hi Brian,

[NSBundle loadNibNamed:@"SettingsDialog" owner:self]; // the nib  
name is SettingsDialog.nib


Xcode complains that this is the first time that self is used.



Isn't there some sample code for building Cocoa iTunes plugins  
available somewhere that will answer these questions for you?


I actually want to try to stay as cross-platform as possible since  
this will need to work on Windows down the road.


-Jason

___

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: NSKeyedUnarchiver memory management ?

2008-05-02 Thread Jens Alfke


On 2 May '08, at 3:29 PM, Angel Todorov wrote:


I want to serialize in an archive a set of objects (big ones) that are
instances of a class which implements NSCoding. On deserialization,  
I don't
want the whole archive to be loaded in memory, but only the object  
for the

*key* that I am requesting.


Cocoa archiving doesn't do that; it always reads or writes the entire  
archive.


But by coincidence, I recently wrote a class that does exactly what  
you're asking. I've been meaning to announce its availability as open  
source, but kept getting sidetracked. Here it is:


http://mooseyard.com/projects/CDBStore/

CDBStore is a file-backed persistent dictionary. You can store and  
retrieve values using keys; only the values you ask for get read from  
the file, and only modified values get written back to the file. The  
values can be arbitrary archivable NSObjects. The keys are, by  
default, limited to NSData, but you can easily support other types of  
keys by overriding one method.


CDBStore is a kind of middle ground between simple property-lists or  
archived objects, and CoreData. There's a very large empty space  
there, and I kept getting annoyed by having to cobble together yet  
another bit of code to read and write a dictionary from a file.


Behind the scenes, CDBStore uses CDB, or "Constant DataBase", a simple  
persistence library. CDB is very efficient: usually no more than two  
reads to fetch any value, and the file is memory-mapped so it takes  
advantage of the kernel's caching. It's also very reliable: it never  
updates a file in place, so its files cannot get corrupted on a system  
crash the way SQLite or Berkeley DB databases can. On the other hand,  
it won't be nearly as efficient for large rapidly-updated data sets.


I've been using CDBStore for a few months now in the app I'm  
developing. I can't claim it's fully complete, but it's been working  
very well for me.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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]

ANN: CDBStore, a lightweight persistent dictionary

2008-05-02 Thread Jens Alfke


http://mooseyard.com/projects/CDBStore/

CDBStore is a file-backed persistent dictionary. You can store and  
retrieve values using keys; only the values you ask for get read from  
the file, and only modified values get written back to the file. The  
values can be arbitrary archivable NSObjects. The keys are, by  
default, limited to NSData, but you can easily support other types of  
keys by overriding one method.


CDBStore is a kind of middle ground between simple property-lists or  
archived objects, and CoreData. There's a very large empty space  
there, and I kept getting annoyed by having to cobble together yet  
another bit of code to read and write a dictionary from a file. And  
I'm not the only one, as evidenced by this message:


On 2 May '08, at 3:29 PM, Angel Todorov wrote:

I want to serialize in an archive a set of objects (big ones) that are
instances of a class which implements NSCoding. On deserialization,  
I don't
want the whole archive to be loaded in memory, but only the object  
for the

*key* that I am requesting.



Behind the scenes, CDBStore uses CDB, or "Constant DataBase", a simple  
persistence library. CDB is very efficient: usually no more than two  
reads to fetch any value, and the file is memory-mapped so it takes  
advantage of the kernel's caching. It's also very reliable: it never  
updates a file in place, so its files cannot get corrupted on a system  
crash the way SQLite or Berkeley DB databases can. On the other hand,  
it won't be nearly as efficient for large rapidly-updated data sets.


I've been using CDBStore for a few months now in the app I'm  
developing. I can't claim it's fully complete, but it's been working  
very well for me. It's released under a BSD license, so feel free to  
use it anywhere.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Implementing fast enumeration

2008-05-02 Thread Jens Alfke


On 2 May '08, at 12:18 PM, Ben wrote:

I have a C array where the elements within it can be converted into  
multiple objects. Say I have 5 objects. Do I provide them all in one  
go and return the total number? Or just one per call and return the  
number remaining?


Return as many as you can at once, for best performance. What makes  
this API fast is that it allows the caller to loop over lots of  
objects at once inline, without having to keep calling into the  
enumerator. In tight loops the overhead of the Obj-C method dispatch  
(or CoreFoundation function call) is the dominating factor.


If you can return large numbers of objects at once, the performance of  
fast-iteration becomes nearly as good as using a native C array. (I  
did some of the early prototyping of this, a few years ago; IIRC, at  
about 50 objects per call, the overhead became negligible.)


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Loading a .nib?

2008-05-02 Thread Jens Alfke


On 2 May '08, at 5:41 PM, J. Todd Slack wrote:

I actually want to try to stay as cross-platform as possible since  
this will need to work on Windows down the road.


Well, then you can't use Objective-C, or nibs, at all, as neither of  
those are available on Windows.


You'd be better off using Carbon, because as others have pointed out,  
iTunes is a Carbon app, and I don't know how well Cocoa code will run  
in it.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Loading a .nib?

2008-05-02 Thread Graham Cox


On 3 May 2008, at 10:45 am, J. Todd Slack wrote:


I have a question.

1. Can you point me to where it puts the UI inside the iTunes  
Visualizer window?


Not sure what you mean by "putting the UI in the iTunes visualizer  
window"? It doesn't - it creates a separate dialog window which seems  
to be what all iTunes plug-ins do and are expected to do. You can  
*draw* into the iTunes visualizer window of course, which is mostly  
the point of them, but I don't put any UI there as such. You possibly  
could, but never tried it.


In my mini-framework, the method to draw to the visualizer is  
ITPlugIn::Render() - you override that to put your visual content into  
the visualizer.





2. Also, how does one load a .nib from carbon?



One thing to clarify about Carbon vs. Cocoa - while Cocoa itself is  
unavailable, you can of course use Core Foundation. However everything  
in Carbon is lower level and generally more work than Cocoa, so be  
prepared ;-)



Here's what I did - some vars referenced are data members:



voidITSpectrumAnalyserPlugIn::NewConfigDialog()
{
// default is to load dialog from NIB in bundle

IBNibRefnibRef;
//we have to find our bundle to load the nib inside of it

CFBundleRef iTunesXPlugin;

	iTunesXPlugin =  
CFBundleGetBundleWithIdentifier( CFSTR( "LEDSpectrumAnalyser" ));


if ( iTunesXPlugin )
{   
		CreateNibReferenceWithCFBundle( iTunesXPlugin,  
CFSTR( "SettingsDialog" ), &nibRef );


if ( nibRef )
{
UseResFile( resFile );
			CreateWindowFromNib( nibRef, CFSTR( "PluginSettings" ),  
&configDialog );

DisposeNibReference( nibRef );

			// if window was created, set up callback to handle its events. At  
this stage we are only interested

// in control hit events

if ( configDialog )
{
static EventTypeSpec eventSpec[] = { kEventClassControl,  
kEventControlHit,


kEventClassWindow, kEventWindowClose,

kEventClassTextInput, kEventTextInputUnicodeForKeyEvent };

InstallWindowEventHandler( configDialog,  
NewEventHandlerUPP( DialogEventHandler ), 3, eventSpec, this, NULL );

}
}
}
else
SysBeep( 1 );
}



If you are in the Bay Area, CA, I will take you to lunch...


Thanks ;-) I'm in Australia


G.

___

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: ANN: CDBStore, a lightweight persistent dictionary

2008-05-02 Thread Jeff LaMarche


On May 2, 2008, at 9:07 PM, Jens Alfke wrote:
CDBStore is a kind of middle ground between simple property-lists or  
archived objects, and CoreData. There's a very large empty space  
there, and I kept getting annoyed by having to cobble together yet  
another bit of code to read and write a dictionary from a file. And  
I'm not the only one, as evidenced by this message:


This is very cool, Jens. I'm looking forward to trying this out.

I actually started working on a little different approach to that  
"middle ground" you talk about yesterday. What I've done, although  
it's not production ready yet, is to use some of Objective-C's runtime  
functions to create a class that if you subclass it, all the  
properties you declare are automatically saved to a SQLite database.  
It's implemented as just a single class and a single-method protocol  
that your application delegate needs to conform to (a method that  
opens and returns the database). It dynamically generates the SQL to  
create, delete, insert, and update the database based on the declared  
properties, so you don't have to write any code and don't have to  
create a mapping file, or do anything else. It even handles foreign  
key associations for instance variables that are also subclasses of  
this class, and uses cross reference tables to store arrays and  
dictionaries that contain objects that are subclasses.


It's similar to the Ruby ActiveRecord implementation, except for being  
object-driven rather than table driven. I think the concept has a lot  
of potential, but I've got quite a bit of work to do before I'm  
comfortable publishing it for others to see. Your solution might work  
for me, though, and save me some work. :)

___

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: Implementing fast enumeration

2008-05-02 Thread Adam R. Maxwell


On May 2, 2008, at 12:18 PM, Ben wrote:


Re-sending as this did not seem to get make it to the list.

I have been reading the documentation for implementing the  
NSFastEnumeration protocol and am having some difficulties following  
it.


[...]

Apologies if these are basic questions, but I got decidedly lost  
trying to follow the docs.


I also got lost in the docs (I should file a bug one of these days).   
Anyway, take a look at CFArray.c from Apple's CF source, specifically  
the _CFArrayFastEnumeration function.  Having that for an example  
really helped.


hth,
Adam
___

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]


Custom View initialization: where?

2008-05-02 Thread Markus Spoettl
Following the "View Programming Guide for Cocoa" if I use a Custom- 
View proxy in IB, the view's initWithFrame: method will be called when  
the NIB is loaded (this can be found in "Initializing View Instances  
Created in Interface Builder").


I do have a custom NSView derived view and a simple window with one  
proxy custom view in it. The class name is set to my view's class, but  
the initializer does not get called. awakeFromNib: is called, though.


Is this a documentation error or is there something I have to do  
before the dedicated initializer is getting called by the framework?  
My view has a couple of objects it has to allocate, the initializer  
being the best place.


I'm using Xcode 3.0 on 10.5.2

Regards
Markus
--
__
Markus Spoettl

___

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: Custom View initialization: where?

2008-05-02 Thread Graham Cox

Sounds OK - so post your code. The documentation is correct.

G.


On 3 May 2008, at 12:05 pm, Markus Spoettl wrote:

Following the "View Programming Guide for Cocoa" if I use a Custom- 
View proxy in IB, the view's initWithFrame: method will be called  
when the NIB is loaded (this can be found in "Initializing View  
Instances Created in Interface Builder").


I do have a custom NSView derived view and a simple window with one  
proxy custom view in it. The class name is set to my view's class,  
but the initializer does not get called. awakeFromNib: is called,  
though.


Is this a documentation error or is there something I have to do  
before the dedicated initializer is getting called by the framework?  
My view has a couple of objects it has to allocate, the initializer  
being the best place.


I'm using Xcode 3.0 on 10.5.2

Regards
Markus
--
__
Markus Spoettl

___

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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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: Graphics seen when volume is modified.

2008-05-02 Thread Jamie Phelps
You might also check out the RoundedFloatingPanel code from Matt  
Gemmell: http://mattgemmell.com/source about 60% of the way down.


JP

On May 2, 2008, at 3:38 AM, John Clayton wrote:


Hi All,

Does anyone know of some code that mimics the graphics that are  
displayed by Apple when one modifies the system volume?   
Specifically the grey box + white shadowed text that pops up  
briefly.  I want to do something similar in my app, so any kind of  
guiding code would be useful.


Any info about the box or code that emulates this would be useful,

Thanks!

--
John Clayton
http://www.coderage-software.com/



___

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/jrphelps%40mac.com

This email sent to [EMAIL PROTECTED]


___

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: Cache Class review (low priority)

2008-05-02 Thread Chris Hanson

On May 2, 2008, at 9:32 AM, Western Botanicals wrote:


http://expresslanevideo.com/transfer/code/CacheTesterh.txt
http://expresslanevideo.com/transfer/code/CacheTesterm.txt


You can use Xcode's unit testing functionality -- built atop Sen:te's  
OCUnit framework -- to write tests in a standard fashion, rather than  
creating your own custom test code for everything you do.


I wrote a few posts on my weblog about how to use this in a step-by- 
step fashion .


Also, you appear to have a very Java/C#-like coding style.  It'd be  
better to make your Objective-C code fit the style of other Objective- 
C code you're likely to read in code samples, Open Source projects,  
and so on:


1.  Do not indent everything between @implementation and @end.
2.  Instead of +getInstance, the method to return a shared cache  
object should be +sharedCache.
3.  Your -init method should do "self = [super init]" and check for  
nil return.
4.  Your -get:, -put:with: and -removeItem: methods should be more  
descriptively named.  For example, -objectWithID:, - 
cacheObject:withID:, and -removeObjectWithID:.
5.  Your -run: method should be more descriptively named, for example - 
pruneCache:.
6.  You should have a 2-4 character prefix on your class name, since  
Objective-C doesn't have Java/C#-style namespaces.


Are you really going to be caching arbitrary objects?  Or is this for  
some sort of database front-end application where you have a more  
specific row-snapshot class that's going to be cached?  If so, you  
could leverage that to actually get an ID of the object to cache and  
so on, and rename the class to be something like WBRowCache.


Finally, you're going way, way, WAY overboard trying to make this a  
singleton.  Don't bother with all of the extra work you've gone to --  
overriding +allocWithZone:, -copyWithZone:, -retain, -release, - 
autorelease, -dealloc, -retainCount, and so on -- just create it a  
normal NSObject subclass with normal instance variables that can be  
instantiated by +alloc/-init.  Then, in your application, *just* use  
+sharedCache to get at the cache.  When the time comes that you need  
separate instances for different purposes, you won't have to rip  
anything out, and the work to *ensure* singleton-ness tends to be  
busywork anyway.


  -- Chris

PS - Instead of posting this stuff on your web site as text files,  
give  a try.  It does useful things like  
syntax coloring.  Oh, and use spaces instead of tabs inside your code,  
at least when posting it to the web; most web browsers and editors  
will treat a hard tab in a text file as 8 characters.


___

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]


Mail type in-line objects

2008-05-02 Thread Matthew Weinstein
Hoping that there is somewhere a class or a demo of how to code for  
nstextview and the like little objects like the mail addresses in the  
to: line of apple mail. Hope someone can help; it would help bring my  
app to a new level.

Matthew Weinstein
[EMAIL PROTECTED]



___

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: Mail type in-line objects

2008-05-02 Thread Mike Glass
Have a look at the documentation for NSTokenField, it does what you  
are looking for.


http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTokenField_Class/Reference/Reference.html

-Mike

On May 2, 2008, at 10:27 PM, Matthew Weinstein wrote:

Hoping that there is somewhere a class or a demo of how to code for  
nstextview and the like little objects like the mail addresses in  
the to: line of apple mail. Hope someone can help; it would help  
bring my app to a new level.

Matthew Weinstein
[EMAIL PROTECTED]



___

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: Custom View initialization: where?

2008-05-02 Thread Markus Spoettl

On May 2, 2008, at 7:11 PM, Graham Cox wrote:

Sounds OK - so post your code. The documentation is correct.



Well the code is totally straight forward:

@interface MyView : NSView {
MyObjectData *data;
}

@property (readonly) MyObjectData *data;

- (id)initWithFrame:(NSRect)frame;

@end


@implementation MyView

@synthesize data;

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
data = [[MyObjectData alloc] init];
}
return self;
}

@end

The view is instantiated correctly because it draws right. When I put  
the debugger breakpoint in initWithFrame: it doesn't get called. Is  
there something wrong with this?


Regards
Markus
--
__
Markus Spoettl

___

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: Loading a .nib?

2008-05-02 Thread Michael Ash
On Fri, May 2, 2008 at 9:19 PM, Graham Cox <[EMAIL PROTECTED]> wrote:
>  One thing to clarify about Carbon vs. Cocoa - while Cocoa itself is
> unavailable, you can of course use Core Foundation. However everything in
> Carbon is lower level and generally more work than Cocoa, so be prepared ;-)

Cocoa is available as it is everywhere else. It has been legal to mix
Cocoa and Carbon, to varying degrees, since roughly the dawn of time.
In any halfway recent OS it's not too painful or limited, and if you
can require Leopard then you can even embed Cocoa views in Carbon
windows using HICocoaView. If you need Tiger support then you are
limited to only using each framework's controls in windows created by
that framework, but as long as you respect that you can certainly use
Cocoa inside iTunes.

Mike
___

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: Custom View initialization: where?

2008-05-02 Thread Graham Cox


On 3 May 2008, at 12:34 pm, Markus Spoettl wrote:

The view is instantiated correctly because it draws right. When I  
put the debugger breakpoint in initWithFrame: it doesn't get called.  
Is there something wrong with this?



No, not that I can see. Maybe you aren't actually running in the  
debugger for some reason - try NSLogging from inside initWithFrame:  
instead to see if it's called.





- (id)initWithFrame:(NSRect)frame;



BTW: you don't need to declare methods in @interface that are  
inherited from the superclass.




G.
___

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: Loading a .nib?

2008-05-02 Thread Graham Cox

OK, that's cool :)

What's involved in setting up a Cocoa runtime environment in such a  
case?



G.

On 3 May 2008, at 12:40 pm, Michael Ash wrote:

On Fri, May 2, 2008 at 9:19 PM, Graham Cox <[EMAIL PROTECTED]>  
wrote:

One thing to clarify about Carbon vs. Cocoa - while Cocoa itself is
unavailable, you can of course use Core Foundation. However  
everything in
Carbon is lower level and generally more work than Cocoa, so be  
prepared ;-)


Cocoa is available as it is everywhere else. It has been legal to mix
Cocoa and Carbon, to varying degrees, since roughly the dawn of time.
In any halfway recent OS it's not too painful or limited, and if you
can require Leopard then you can even embed Cocoa views in Carbon
windows using HICocoaView. If you need Tiger support then you are
limited to only using each framework's controls in windows created by
that framework, but as long as you respect that you can certainly use
Cocoa inside iTunes.

Mike
___

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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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]


nstoken for nstextview...

2008-05-02 Thread Matthew Weinstein
Okay, but I'm looking for something related to nstextview rather than  
nstextfield.


Anything that anyone knows out there like that. It's perfect except I  
need something more wordprocessorish.


--Matthew


Have a look at the documentation for NSTokenField, it does what you
are looking for.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTokenField_Class/Reference/Reference.html

-Mike

On May 2, 2008, at 10:27 PM, Matthew Weinstein wrote:


Hoping that there is somewhere a class or a demo of how to code for
nstextview and the like little objects like the mail addresses in
the to: line of apple mail. Hope someone can help; it would help
bring my app to a new level.
Matthew Weinstein
[EMAIL PROTECTED]



Matthew Weinstein
[EMAIL PROTECTED]



___

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: Custom View initialization: where?

2008-05-02 Thread Quincey Morris


On May 2, 2008, at 19:05, Markus Spoettl wrote:

Following the "View Programming Guide for Cocoa" if I use a Custom- 
View proxy in IB, the view's initWithFrame: method will be called  
when the NIB is loaded (this can be found in "Initializing View  
Instances Created in Interface Builder").


I do have a custom NSView derived view and a simple window with one  
proxy custom view in it. The class name is set to my view's class,  
but the initializer does not get called. awakeFromNib: is called,  
though.


Is this a documentation error or is there something I have to do  
before the dedicated initializer is getting called by the framework?  
My view has a couple of objects it has to allocate, the initializer  
being the best place.


I don't know why initWithFrame: isn't being called in your case, but  
someone from Apple did say on this list a few weeks ago that an  
initializer *is* always called. If it's not initWithFrame:, it will be  
initWithCoder:.


Presumably that is getting called, and you could put the object  
allocations in there.



___

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: Custom View initialization: where?

2008-05-02 Thread Andy Lee
The doc I found says there are *two* ways a custom view is  
initialized.  One uses initWithFrame:, the other doesn't.  Are you  
sure your case is the first case?  It sounds like it, but I thought  
I'd double-check.




(see the last two paragraphs)

--Andy

On May 2, 2008, at 10:49 PM, Graham Cox wrote:


On 3 May 2008, at 12:34 pm, Markus Spoettl wrote:

The view is instantiated correctly because it draws right. When I  
put the debugger breakpoint in initWithFrame: it doesn't get  
called. Is there something wrong with this?



No, not that I can see. Maybe you aren't actually running in the  
debugger for some reason - try NSLogging from inside initWithFrame:  
instead to see if it's called.





- (id)initWithFrame:(NSRect)frame;



BTW: you don't need to declare methods in @interface that are  
inherited from the superclass.




G.
___

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/aglee%40mac.com

This email sent to [EMAIL PROTECTED]


___

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: Custom View initialization: where?

2008-05-02 Thread Markus Spoettl

On May 2, 2008, at 8:23 PM, Quincey Morris wrote:
I don't know why initWithFrame: isn't being called in your case, but  
someone from Apple did say on this list a few weeks ago that an  
initializer *is* always called. If it's not initWithFrame:, it will  
be initWithCoder:.


Presumably that is getting called, and you could put the object  
allocations in there.



Turns out it's my fault (I suspected as much). What I did was the  
following:


I had one window with a custom view on it. Instead of setting the  
class of the custom view I set the class if the window's content view.  
I didn't realize it because the view painted correctly. I should have  
been more careful, sorry for wasting your time.


The initializer is not getting called correctly.

Regards
Markus
--
__
Markus Spoettl

___

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: drawing in a separate thread

2008-05-02 Thread Duncan


On May 2, 2008, at 12:49 PM,  Graham Cox <[EMAIL PROTECTED]> wrote:


Subject: Re: drawing in a separate thread


OK, I have managed to implement this after a lot of poring over the  
docs. I'm not sure if it's the most efficient way to actually handle  
the thread communication, but it does work (using NSMachPort). As I  
hoped, there isn't a big problem with drawing the graphics as they  
should be, apart from a bit of occasional blank output when the  
window is resized - BUT, performance is terrible. Worse than  
synchronous drawing by a long shot - I haven't measured it because  
it's really obvious how much the drawing lags the user - must be an  
order of magnitude slower.


Question is of course, why? The thread is calling the exact same  
drawing code as the view normally does, so that's a constant. So it  
must be down to the thread communication/overhead. Or perhaps just  
my minimal understanding of threads, locks, ports etc. ;-)


When I need to draw, I flag that fact to the class (the class is  
handling all views using a single secondary thread, but in fact I  
only have tried it so far with one), and the class bundles the  
update rect and view into an NSInvocation, which is placed in a  
queue. An NSPortMessage is used to wake up the thread which pulls  
the invocation off the queue and invokes it, which does the drawing.  
Maybe the use of NSInvocation is slow? Not sure why it should be.


I think using DO IS overkill, and has too much overhead for your  
application.


I've used a fairly lightweight model for worker threads. I used a  
variation of ThreadSafeQueue, and created a job queue. I then created  
one or more worker threads that looks in the queue for work to do.  
When the thread finds work, it does the work, then blocks on a  
condition lock until there is more work. It works beautifully, and  
without much overhead.


In your case you'd probably only have one worker thread, and let that  
thread handle all your time-consuming drawing.



See this link for info on the ThreadSafeQueue class: 
http://www.cocoadev.com/index.pl?ProducersAndConsumerModel


Duncan C
___

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: Loading a .nib?

2008-05-02 Thread Michael Ash
On Fri, May 2, 2008 at 10:50 PM, Graham Cox <[EMAIL PROTECTED]> wrote:
> OK, that's cool :)
>
>  What's involved in setting up a Cocoa runtime environment in such a case?

ObjC gets set up simply by linking to it, so that happens without any
intervention. Foundation can be used with no additional setup as well.
AppKit requires that you initialize it by calling NSApplicationLoad()
before using it for anything else. Fortunately the call can be made
multiple times without harm, so you don't have to worry about anyone
else doing it too.

Otherwise, standard Cocoa caveats apply. If your plugin can get
invoked on secondary threads, keep in mind the thread safety of Cocoa
classes. Also your callbacks may not have autorelease pools, so you
will have to manage your own in that case.

Apple's Carbon-Cocoa Integration Guide goes into more detail:

http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/CarbonCocoaDoc.html

Of particular interest here would be the "Using a Cocoa User Interface
in a Carbon Application" section.

Mike
___

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: drawing in a separate thread

2008-05-02 Thread Graham Cox


On 3 May 2008, at 1:40 pm, Duncan wrote:



On May 2, 2008, at 12:49 PM,  Graham Cox <[EMAIL PROTECTED]>  
wrote:



Subject: Re: drawing in a separate thread


OK, I have managed to implement this after a lot of poring over the  
docs. I'm not sure if it's the most efficient way to actually  
handle the thread communication, but it does work (using  
NSMachPort). As I hoped, there isn't a big problem with drawing the  
graphics as they should be, apart from a bit of occasional blank  
output when the window is resized - BUT, performance is terrible.  
Worse than synchronous drawing by a long shot - I haven't measured  
it because it's really obvious how much the drawing lags the user -  
must be an order of magnitude slower.


Question is of course, why? The thread is calling the exact same  
drawing code as the view normally does, so that's a constant. So it  
must be down to the thread communication/overhead. Or perhaps just  
my minimal understanding of threads, locks, ports etc. ;-)


When I need to draw, I flag that fact to the class (the class is  
handling all views using a single secondary thread, but in fact I  
only have tried it so far with one), and the class bundles the  
update rect and view into an NSInvocation, which is placed in a  
queue. An NSPortMessage is used to wake up the thread which pulls  
the invocation off the queue and invokes it, which does the  
drawing. Maybe the use of NSInvocation is slow? Not sure why it  
should be.


I think using DO IS overkill, and has too much overhead for your  
application.


I agree ;-)

I've used a fairly lightweight model for worker threads. I used a  
variation of ThreadSafeQueue, and created a job queue. I then  
created one or more worker threads that looks in the queue for work  
to do. When the thread finds work, it does the work, then blocks on  
a condition lock until there is more work. It works beautifully, and  
without much overhead.


In your case you'd probably only have one worker thread, and let  
that thread handle all your time-consuming drawing.



See this link for info on the ThreadSafeQueue class: 
http://www.cocoadev.com/index.pl?ProducersAndConsumerModel



Looks ideal, thanks for the link.


One thing I realised after the previous posting is that the  
performance hit I'm seeing is because unlike the usual drawRect: case,  
I wasn't doing any clipping to the update area, so the entire view was  
getting repainted rather than just some small part of it - adding a  
clipRect: call substantially improved things.


However it also made me realise that just doing the drawing on a  
second thread is not enough - my graphics code makes quite a bit of  
use of the view's -needsToDrawRect: method, which of course when it's  
called by the thread is just not going to be valid, as drawRect: has  
been and gone. I'm not sure how to tackle this - it would seem I'd  
have to cache the result of -getRectsBeingDrawn:count: each time I  
queue a draw from the main thread and somehow make these rects  
available to clients of the view when they are drawn from the second  
thread (by overriding needsToDrawRect: for example). This seems  
complicated and somewhat hackish - or I redesign the drawing code to  
have these rects passed down as a parameter for every draw, which is  
equally awkward.


I'm not yet convinced that drawing on a second thread will really give  
any benefit, so I'm reluctant to change things dramatically to allow  
it when I may end up abandoning the whole idea.


Be useful to hear from anyone who's done something like this to a)  
convince me it's worth it and b) hear about any solutions to the  
update rects issue.



tia,

G.
___

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]


  1   2   >