Re: How to Delay, Wait, Pause...

2008-05-24 Thread Peter Burtis

NSThread has a sleepUntilDate: class method.

In the example below, 0.1 = 1/10th of a second.

NSDate *future = [NSDate dateWithTimeIntervalSinceNow: 0.1 ];
[NSThread sleepUntilDate:future];

-Pete


On May 25, 2008, at 2:45 AM, Steve Steinitz wrote:


Hello,

This is hard to google for because they are such common words:

how do I delay, wait, pause for a tenth of a second?

I don't want to use NSTimer because I just want to resume where I  
left off.  I don't want to be in a tight loop because I need the  
system to finish something.  I just want to pause execution for a  
short time.  I think there was a wait() in OS9.  I found a wait() in  
wait.h but it wants an int * and made me nervous.


Specifically, when I send a fetch message to an NSArrayController,  
it sometimes takes a fraction of a second for its selection to  
become valid.  Currently I fire an NSTimer to call a 'part 2' method  
to finish what I am doing (scrolling the selection into view), but  
it lacks niceness.


Thanks,

Steve

___

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/pete 
%40glossysheep.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]


Spaces causes sheet to go behind parent window

2008-05-24 Thread Justin Williams
Hi,

I'm running into an odd issue with Spaces.   If a user browses to a
different Space while a sheet is dropped in my application and then
clicks my app's Dock icon, the sheet will appear behind the main
window.   Clicking it will bring it to the forefront.  Pressing the
escape key will also close the sheet still.  It doesn't happen 100% of
the time, but it's often enough that it's pretty easy to trigger.

I've put together a small sample project that demonstrates the
behavior.  You can download it at
http://secondgearllc.com/attachments/spaces_cadet.zip

Has anyone else run into this or have any suggestions on a different
approach I can take to get around this?

Thanks for the help.

-- 
-
Justin Williams
[EMAIL PROTECTED]
work: http://www.secondgearllc.com/
play: http://www.carpeaqua.com
-
Check out Today: iCal's new best friend 
-
___

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: A documetation suggestion (was Re: Cocoa et al as HCI usability problem)

2008-05-24 Thread Gerriet M. Denkmann


On 25 May 2008, at 03:00, Ken Thomases wrote:


On May 24, 2008, at 12:36 AM, Gerriet M. Denkmann wrote:


On Fri, May 23, 2008 at 9:19 AM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:


So I
- entered "disc recording" into Xcode -> Help -> Documentation -  
nothing at

all



...answering about Xcode Version 2.4:
I did try both modes (Full-Text / API) and both gave the same  
empty result.

Sorry not to have mentioned this in my post.

[...]


Oh.  What do you have selected in the Search Groups list on the  
left-hand side of the documentation window?  Maybe you have  
selected a particular group under the Reference Library master  
group, and that's limiting the scope of the search.


Oh, how embarrassing!
I did have nothing selected, had indeed never looked at this "Search  
Groups list".

What happened: I opened the Xcode Help via ⌘? as I always do for Help.
But Xcode selects "Xcode Help" in the "Search Groups list" in this case.
When I select "Reference Library" on top, everything is as it should  
be, and as you said it is.

Thanks a lot for enlightening me!

Kind regards,

Gerriet.

___

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]


How to Delay, Wait, Pause...

2008-05-24 Thread Steve Steinitz

Hello,

This is hard to google for because they are such common words:

how do I delay, wait, pause for a tenth of a second?

I don't want to use NSTimer because I just want to resume where 
I left off.  I don't want to be in a tight loop because I need 
the system to finish something.  I just want to pause execution 
for a short time.  I think there was a wait() in OS9.  I found a 
wait() in wait.h but it wants an int * and made me nervous.


Specifically, when I send a fetch message to an 
NSArrayController, it sometimes takes a fraction of a second for 
its selection to become valid.  Currently I fire an NSTimer to 
call a 'part 2' method to finish what I am doing (scrolling the 
selection into view), but it lacks niceness.


Thanks,

Steve

___

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: Faster way to test pixels?

2008-05-24 Thread Ken Thomases

On May 25, 2008, at 12:55 AM, Graham Cox wrote:

Trying to squeeze a bit more speed out of certain bottlenecks in my  
code. Here's one of them:


NSBitmapImageRep* bits = [self pathBitmapInRect:ir];

// if any pixels in this bitmap are set, we have a hit.

int x, y;
unsignedpixel;

for( y = 0; y < ir.size.height; ++y )
{
for( x = 0; x < ir.size.width; ++x )
{
[bits getPixel:&pixel atX:x y:y];

if ( pixel < 255 )
{
hit = YES;
goto endOfLoop;
}
}
}

endOfLoop:


The  object is a grayscale bitmap where the background is  
painted white and any set pixels are painted black. I just need to  
know if there are *any* black pixels in the image.  is an NSRect  
which can be any size. The imaging method (not shown) accounts for  
the origin of this rect, so the test scans from 0,0. The purpose is  
to test whether a given rect intersects a rendered object (path),  
not just test a point against it.


Is there any faster way of doing this than just iterating over the  
pixels like this? I can't think of anything but someone might have a  
bright idea.


Well, one approach would be to optimize away the method call overhead  
using its IMP.  


Another approach would be to ask "bits" for direct access to its  
bitmap data (using -bitmapData) and scanning that directly, avoiding  
even a function call per pixel.


Lastly, you should consider using the vImage component of the  
Accelerate framework for the most highly optimized implementation you  
could hope for.    I think you want the vImageHistogramCalculation_Planar8 function .


Cheers,
Ken
___

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: Scope in an interface?

2008-05-24 Thread Ken Thomases

On May 25, 2008, at 12:29 AM, Graham Reitz wrote:

Also, is there some reading for people familiar with c++ trying to  
grok obj-c other than the apple dev docs?   (something quick and  
dirty)


A bit of googling turned up this: 
http://ktd.club.fr/programmation/fichiers/cpp-objc-en.pdf

Cheers,
Ken

___

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]


Faster way to test pixels?

2008-05-24 Thread Graham Cox
Trying to squeeze a bit more speed out of certain bottlenecks in my  
code. Here's one of them:


NSBitmapImageRep* bits = [self pathBitmapInRect:ir];

// if any pixels in this bitmap are set, we have a hit.

int x, y;
unsignedpixel;

for( y = 0; y < ir.size.height; ++y )
{
for( x = 0; x < ir.size.width; ++x )
{
[bits getPixel:&pixel atX:x y:y];

if ( pixel < 255 )
{
hit = YES;
goto endOfLoop;
}
}
}

endOfLoop:


The  object is a grayscale bitmap where the background is  
painted white and any set pixels are painted black. I just need to  
know if there are *any* black pixels in the image.  is an NSRect  
which can be any size. The imaging method (not shown) accounts for the  
origin of this rect, so the test scans from 0,0. The purpose is to  
test whether a given rect intersects a rendered object (path), not  
just test a point against it.


Is there any faster way of doing this than just iterating over the  
pixels like this? I can't think of anything but someone might have a  
bright idea.


tia,


Graham
___

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: Scope in an interface?

2008-05-24 Thread Graham Reitz
Sorry, assume the @implementation/@end are there.  It's not an example  
meant to compile.


It sounds like what I listed can be considered synonymous with a c++  
class?


thanks,
-graham


On May 25, 2008, at 12:36 AM, stephen joseph butler wrote:

On Sun, May 25, 2008 at 12:29 AM, Graham Reitz <[EMAIL PROTECTED]>  
wrote:

Can I think of an @interface as something similar to a c++ class?


A class in Obj-C consists of an interface and an implementation (you
forgot the @implementation/@end in your example). Just like a class in
C++ (usually) consists of the definition in the header and the
function implementations in the cpp/cxx/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/grahamreitz%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: Scope in an interface?

2008-05-24 Thread stephen joseph butler
On Sun, May 25, 2008 at 12:29 AM, Graham Reitz <[EMAIL PROTECTED]> wrote:
> Can I think of an @interface as something similar to a c++ class?

A class in Obj-C consists of an interface and an implementation (you
forgot the @implementation/@end in your example). Just like a class in
C++ (usually) consists of the definition in the header and the
function implementations in the cpp/cxx/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]


Scope in an interface?

2008-05-24 Thread Graham Reitz


I am coming from the c++ world and I feel I don't understand how  
objects are scoped in obj-c.


What is the scope of m_controller (a c++ class) below?   The debugger  
shows m_controller as {...} with no other information. Other than that  
it seems to run fine.


Can I think of an @interface as something similar to a c++ class?

Also, is there some reading for people familiar with c++ trying to  
grok obj-c other than the apple dev docs?   (something quick and dirty)


// simple.h

#include "controller.hpp"

@interface simple : NSView
{
@private
controller m_controller;
}

- (void) initialize_something;
- (void) drawRect: (NSRect) rect;

@end

// simple.mm

- (void) initialize_something
{
m_controller.initialize_something();
}

- (void) drawRect: (NSRect) rect
{
NSLog(@"drawRect");
m_controller.do_something();
}
___

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: to launch safari with an URL

2008-05-24 Thread Peter Burtis

NSURL *url = [NSURL URLWithString:@"http://www.google.com";];
[[NSWorkspace sharedWorkspace] openURL:url];

-Pete

On May 25, 2008, at 12:55 AM, Nick Rogers wrote:

Hi,
How can I launch the default browser supplying it a URL with the  
click of a button?


Please help.

WIshes,
Nick

___

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/pete 
%40glossysheep.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]


to launch safari with an URL

2008-05-24 Thread Nick Rogers

Hi,
How can I launch the default browser supplying it a URL with the click  
of a button?


Please help.

WIshes,
Nick

___

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: NSWindow CoreAnimation Delegate not being called

2008-05-24 Thread Peter Burtis
I just rewired my app to try it your way, and can confirm that, when  
using [window animationForKey:@"frame"] to get the CAAnimation, it  
doesn't call the delegates for me either.  But animationForKey also  
doesn't return nil, so my first theory is out.


Weird.

But yes, creating a new CAAnimation and then adding it to the window  
instead of relying on the animation that the window returns seems to  
solve the problem.


-Pete

On May 25, 2008, at 12:11 AM, Peter Burtis wrote:

I'm no core animation expert, but.

This...

// self is an NSWindow instance
CAAnimation *anim = [CABasicAnimation animation];
[anim setDelegate:self];
	[self setAnimations:[NSDictionary dictionaryWithObject:anim  
forKey:@"frame"]];

[[self animator] setFrame:NSMakeRect(0,0,0,0) display:YES];

... works perfectly in my app, calling the delegate methods and  
all.  All other things being equal, the only difference I see is  
that you use [window animationForKey:@"frame"] whereas I create a  
new animation and then add it to the window with [window  
setAnimations:...].


My *guess* would be that maybe windows don't instantiate default  
animations until they're needed, whereas frames instantiate them at  
init.  So when you call [window animationForKey:@"frame"] you're  
getting nil back.  But that's just a guess.  I really don't know  
enough about it.


Bug? Feature?  I don't know.  But this could be a workaround, anyway.

-Pete

On May 24, 2008, at 7:11 AM, Milen Dzhumerov wrote:


Hi all,

I've been playing with CA and I tried to set up one my objects as  
the delegate for the frame change animation for an NSWindow by  
using the following code:


CABasicAnimation* anim = [window animationForKey:@"frame"];
anim.delegate = self;
[[window animator] setFrame:NSMakeRect(400, 500, 500, 500)  
display:YES];


Using this, the window correctly animates but the delegate methods  
(namely animationDidStop:finished: and animationDidStart:) for the  
CAAnimation do not get called. When I use the exact same piece of  
code for setting the delegate of view animations, the delegates do  
get called.


Thanks,
M




___

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: NSWindow CoreAnimation Delegate not being called

2008-05-24 Thread Peter Burtis

I'm no core animation expert, but.

This...

// self is an NSWindow instance
CAAnimation *anim = [CABasicAnimation animation];
[anim setDelegate:self];
	[self setAnimations:[NSDictionary dictionaryWithObject:anim  
forKey:@"frame"]];

[[self animator] setFrame:NSMakeRect(0,0,0,0) display:YES];

... works perfectly in my app, calling the delegate methods and all.   
All other things being equal, the only difference I see is that you  
use [window animationForKey:@"frame"] whereas I create a new animation  
and then add it to the window with [window setAnimations:...].


My *guess* would be that maybe windows don't instantiate default  
animations until they're needed, whereas frames instantiate them at  
init.  So when you call [window animationForKey:@"frame"] you're  
getting nil back.  But that's just a guess.  I really don't know  
enough about it.


Bug? Feature?  I don't know.  But this could be a workaround, anyway.

-Pete

On May 24, 2008, at 7:11 AM, Milen Dzhumerov wrote:


Hi all,

I've been playing with CA and I tried to set up one my objects as  
the delegate for the frame change animation for an NSWindow by using  
the following code:


CABasicAnimation* anim = [window animationForKey:@"frame"];
anim.delegate = self;
[[window animator] setFrame:NSMakeRect(400, 500, 500, 500)  
display:YES];


Using this, the window correctly animates but the delegate methods  
(namely animationDidStop:finished: and animationDidStart:) for the  
CAAnimation do not get called. When I use the exact same piece of  
code for setting the delegate of view animations, the delegates do  
get called.


Thanks,
M


___

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: Halting a cocoa application?

2008-05-24 Thread Ken Ferry
On Sat, May 24, 2008 at 5:12 PM, Graham Reitz <[EMAIL PROTECTED]> wrote:
> What is the preferred method to halt a cocoa application on a runtime error
> occurring in the initWithFrame method?

For programming errors, like "you called me with inconsistent
arguments!", Cocoa typically uses exceptions.  You can use NSAssert as
a convenience for throwing exceptions on supposedly unreachable
conditions.

For softer errors that the programmer cannot control and you'd like to
actually tell the user about, like inability to read a file from disk,
Cocoa uses NSError.  These are user presentable errors, displayed in a
sheet most often, possibly with recovery options.

It sounds to me like you're in the first category.  See

for more detail.

NSError is discussed at
.

-Ken
___

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]


NSTextField in NSCollectionView aborts editing without notice, solved

2008-05-24 Thread David Carlisle
I have an NSTextField in an NSCollectionView.  If I type in a change  
to the NSTextField, then without hitting tab or clicking elsewhere in  
the NSCollectionView I click on a popup menu in the window, the  
NSTextField aborts the edit and loses the information without any kind  
of notice being given to the NSTextField.


I solved the problem by subclassing NSTextFieldCell and overriding the  
method endEditing, passing it up to the superclass after first sending  
an emergency message to the window controller, along with a copy of  
the NSTextField, indicating it needs to grab the edited string out of  
the NSTextField because the information is about to be lost.


I tried monitoring resignsFirstResponder.  I can then click on the  
NSTextFields in the NSCollectionView and get resignsFirstResponder  
messages as expected.  If I click on an NSTextField and then hit a key  
to begin an edit, the sequence of messages is as follows:


NSTextField gets the message:
textShouldBeginEditing

The NSTextField delegate, which is an NSCollectionViewItem, gets the  
message:

control:textShouldBeginEditing

NSTextField gets the message:
textDidBeginEditing

The NSTextField delegate gets the message:
control:textDidBeginEditing

After I type in some text, if I were to click on the popup as  
described, neither NSTextField nor its delegate gets any of the text  
did/should end editing messages which correspond with the above  
messages.  FWIW, if rather than clicking on the popup menu I click on  
another text field, the NSTextField gets both of the  
textShouldEndEditing messages, but not any textDidEndEditing  
messages.  After those messages, it gets the expected  
resignsFirstResponder message.


If after I click on the popup menu I click on another NSTextField, I  
do get a resignsFirstResponder message from an NSTextField, but by  
that time the information in the field I had edited has already been  
lost.


So is this a bug?  Is it a feature?  Am I missing something?  Has  
someone already found an easier way of dealing with this?  If someone  
else is already wondering about this problem, then this is the way I  
solved it.


DC
___

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: Handling keyDown events results in beeping from a NSView subclass...

2008-05-24 Thread Graham Reitz

Excellent!   Thanks Pete!

-graham


On May 24, 2008, at 9:56 PM, Peter Burtis wrote:

Add the method -(BOOL)acceptsFirstResponder { return YES; } in the  
custom and it will work as desired.  By default, just clicking on an  
custom NSView *doesn't* make it the first responder, and keyboard  
events are sent to the first responder and then up the responder  
chain, unlike mouse events which are sent to the actual object  
clicked.


-Pete

On May 24, 2008, at 10:37 PM, Graham Reitz wrote:



1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Name the Custom View class
4) Write the class files and add them to the project
5) Derive a class from NSView and implement the keyDown method.
- (void)keyDown:(NSEvent *)theEvent;
6) Run the program and hitting a key on the keyboard results in a  
beep with no call to the key Down method.


What am I missing?

Mouse events come through without any issue.

thanks,
-graham

___

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/pete%40glossysheep.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: File's Owner

2008-05-24 Thread Ken Thomases

On May 23, 2008, at 7:21 PM, Johnny Lundy wrote:

My NSArrayControllers can be bound to model objects without anything  
going through File's Owner.


Really?  That implies that your model is contained within the nib,  
which is not how MVC is supposed to work.  The nib should contain the  
V (View) and possibly C (Controller) parts of MVC, but it should not  
contain the M (Model).  One of the points of separating Model from  
View from Controller is that you can have multiple different views on  
the same model.  Imagine an application which represents a set of  
numbers in one window in a table and in another window in a graph.   
These two windows can (and probably should) be described in separate  
nibs, and the model should live in neither.  It should be instantiated  
in code somewhere else in your application, or managed with Core Data,  
etc.  File's Owner would be needed to connect the views and  
controllers in the nibs to the model.


Perhaps you need to review the "Model-View-Controller Design Pattern"  
conceptual documentation in the Cocoa Fundamentals Guide .



No offense, but your queries to this list remind me of the way  
children can ask "Why?" infinitely.  No matter what explanation is  
provided, they can reflexively ask "Why?" about that new explanation.


So, you've been told by the documentation and by the respondents here  
on this list that File's Owner is useful and important.  And you don't  
yet see how or why.  That's OK.  It just hasn't been important to you  
_yet_.  If it bothers you, you can go about your work (as you appear  
to have) without making much use of File's Owner.  Eventually, you  
will want or need to do something which becomes difficult or  
impossible to do without using File's Owner -- and _then_ you'll know  
how it is useful.


I get the impression that, although you are greatly vexed and  
frustrated by not yet understanding the purpose and usefulness of  
File's Owner, you are not actually putting in much effort into  
figuring that out for yourself.  (This is what puts me in mind of the  
"Why?" game that children sometimes play.  I may be wrong here, and if  
I am I apologize in advance.)


For example, have you exercised your imagination to try to come up  
with scenarios where it might be useful?  From your more recent  
emails, you actually seem to have a good grasp of what File's Owner  
does.  And I must assume you have a general understanding of why it is  
useful for some objects to have references to other objects.  So, why  
is it that you can't see why it might, in some circumstances, be  
useful for objects in a nib to have references to objects outside of  
the nib, and vice versa?  "Why?"  For all the myriad reasons that  
objects need references to other objects.  There's no one answer.   
"None of my nibs have had that requirement."  So?  Does that limited  
empirical result prove, or even imply, that no nibs might, ever?


Have you examined any of the example programs that Apple supplies?  Do  
you realize that the full source for TextEdit comes with the developer  
tools (/Developer/Examples/AppKit/TextEdit)?  Other sample projects  
with multiple nibs include BlastApp, iSpend, and Sketch.  Have you  
examined how those examples use their nibs, and looked to see what  
connections they make to, from and through the owners of those nibs?


When you read Apple design guidelines regarding nibs, do you dismiss  
them or do you consider adopting them?  Of course, you don't always  
have to adopt them -- they're only guidelines after all.  But have you  
considered how adopting them would affect the way you design your  
nibs?  Obviously, the features (such as File's Owner) of the framework  
and the tools are often useful when you do follow the guidelines.  For  
example, see:


http://developer.apple.com/documentation/DeveloperTools/Conceptual/IB_UserGuide/BuildingaNibFile/chapter_4_section_7.html
http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_5.html


I suppose I should step off of my soapbox.  Sorry for the lecture, but  
many people have been trying to help and none of us seem to have  
gotten through.


Regards,
Ken
___

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: Handling keyDown events results in beeping from a NSView subclass...

2008-05-24 Thread Peter Burtis
Add the method -(BOOL)acceptsFirstResponder { return YES; } in the  
custom and it will work as desired.  By default, just clicking on an  
custom NSView *doesn't* make it the first responder, and keyboard  
events are sent to the first responder and then up the responder  
chain, unlike mouse events which are sent to the actual object clicked.


-Pete

On May 24, 2008, at 10:37 PM, Graham Reitz wrote:



1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Name the Custom View class
4) Write the class files and add them to the project
5) Derive a class from NSView and implement the keyDown method.
- (void)keyDown:(NSEvent *)theEvent;
6) Run the program and hitting a key on the keyboard results in a  
beep with no call to the key Down method.


What am I missing?

Mouse events come through without any issue.

thanks,
-graham

___

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/pete 
%40glossysheep.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]


Handling keyDown events results in beeping from a NSView subclass...

2008-05-24 Thread Graham Reitz


1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Name the Custom View class
4) Write the class files and add them to the project
5) Derive a class from NSView and implement the keyDown method.
- (void)keyDown:(NSEvent *)theEvent;
6) Run the program and hitting a key on the keyboard results in a beep  
with no call to the key Down method.


What am I missing?

Mouse events come through without any issue.

thanks,
-graham

___

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: Is there anything pathological with the following NSView simple subclass?

2008-05-24 Thread Erik Buck

Try this search

http://developer.apple.com/cgi-bin/search.pl?q=NSOpenGLView&num=10&site=(samplecode)

Take insight from the samples.  Start with NSOpenGLView unless you  
have some strong reason to poll your own.



___

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]


unwanted tooltip in NSOutlineView (as "outLineTableColumn")

2008-05-24 Thread Nick Rogers

hi,
since I set the second column as outLineTableColumn in IB,
I'm getting this tooltip "outLineTableColumn", anywhere in outline  
view, even when hovering on other columns.
And it goes away when I move the mouse pointer to near the text, then  
the real tooltip occurs.

How can I remove this tooltip "outLineTableColumn"?


WIshes,
Nick

___

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: A documetation suggestion (was Re: Cocoa et al as HCI usability problem)

2008-05-24 Thread Ken Thomases

On May 24, 2008, at 12:36 AM, Gerriet M. Denkmann wrote:


On Fri, May 23, 2008 at 9:19 AM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:


So I
- entered "disc recording" into Xcode -> Help -> Documentation -  
nothing at

all



...answering about Xcode Version 2.4:
I did try both modes (Full-Text / API) and both gave the same empty  
result.

Sorry not to have mentioned this in my post.


Odd.  It works for me with Xcode 2.5.  Full-text searching for "disc  
recording" brings me right to the Disc Recording Framework Reference.   
Maybe Xcode 2.5 has more up-to-date documentation than 2.4 does.


Oh.  What do you have selected in the Search Groups list on the left- 
hand side of the documentation window?  Maybe you have selected a  
particular group under the Reference Library master group, and that's  
limiting the scope of the search.


Cheers,
Ken

___

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: Halting a cocoa application?

2008-05-24 Thread Nathan Kinsinger


On May 24, 2008, at 6:12 PM, Graham Reitz wrote:

What is the preferred method to halt a cocoa application on a  
runtime error occurring in the initWithFrame method?


thanks,
graham


I would normally try to alert the user that something went wrong and  
then terminate if that is the only option (try to give the user a  
chance to fix something, it might be as simple as allowing them to  
open a new document). In which case I would return nil and catch that  
in the controller object (if you have one) which would then display  
the alert (or a sheet).


Once you do want to terminate then [NSApp terminate:nil] will do the  
trick.


--Nathan
___

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: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?

2008-05-24 Thread Nathan Kinsinger


On May 24, 2008, at 6:09 PM, Graham Reitz wrote:


Awesome!  Thanks Nathan.  That makes a lot more sense to me.


Just set the class of the Custom View.


What do you specifically mean by 'set the class'?


In IB select the view then select the Identity Inspector (cmd-6 or the  
icon with the "i" in a circle) and set the Class Identity to the class  
you created in Xcode.


I think this is also what you were referring to in step 4 (unless I  
misunderstood you).



4) Name the Custom View and Object to the same class name


--Nathan
___

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]


Is there anything pathological with the following NSView simple subclass?

2008-05-24 Thread Graham Reitz

I am endeavoring to learn openGL gui development on the Mac.

Any comments on the follow code would be greatly appreciated, i.e.  
what's wrong, pathological and etc...


thanks,
graham

Code---

// simple.h
#import 

@interface simple : NSView
{
@private
NSOpenGLContext *m_context;
NSOpenGLPixelFormat *m_pixel_format;
}
@end

// simple.m
#import "simple.h"

@implementation simple

- (id)initWithFrame:(NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil)
{
NSOpenGLPixelFormatAttribute attributes[] =
{
NSOpenGLPFAWindow,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAMinimumPolicy, 0
};

if (m_pixel_format =
[[NSOpenGLPixelFormat alloc]  
initWithAttributes:attributes])

{
// Create the openGL context
if (m_context = [[NSOpenGLContext alloc]
 initWithFormat:m_pixel_format shareContext:nil])
{
NSLog(@"initWithFrame SUCCESS: OpenGL context  
created");

}
else
{
NSLog(@"initWithFrame FAILURE: Unable to create  
context");

#warning "Handle error condition?"
}
}
else
{
NSLog(@"initWithFrame FAILURE: Unable to match the  
specified pixel format");

#warning "Handle error condition?"
}
}
return self;
}

- (void)lockFocus
{
// ensure we are ready to draw
[ super lockFocus ];
[m_context setView:self];
[m_context makeCurrentContext];
}
@end
___

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]


Halting a cocoa application?

2008-05-24 Thread Graham Reitz
What is the preferred method to halt a cocoa application on a runtime  
error occurring in the initWithFrame method?


thanks,
graham
___

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: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?

2008-05-24 Thread Graham Reitz

Awesome!  Thanks Nathan.  That makes a lot more sense to me.


Just set the class of the Custom View.


What do you specifically mean by 'set the class'?

graham


On May 24, 2008, at 7:01 PM, Nathan Kinsinger wrote:



On May 24, 2008, at 5:43 PM, Graham Reitz wrote:

(fyi) I am coming from the non Mac C++ land and I am trying to grok  
Obj-C and the Cocoa framework.


1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Drag an Object to MainMenu.nib


You don't need to do this, the Custom View is all you need (it is an  
object).



4) Name the Custom View and Object to the same class name


Just set the class of the Custom View.


5) Write the class files and add them to the project
6) Derive the class from NSView and implement the initWithFrame  
method.

7) Run the program in debug mode.

initWithFrame is called twice (self equals something different each  
call).


One is from the Custom View and the other is from the Object.

-Where is the other derived NSView object getting instantiated and  
what is it?


-Is 'self' the same as 'this'?  It doesn't seem like the same since  
super is the parent class.


-How can I tell if the sub-classed NSView instance is from the  
Custom View that was dragged over in IB?  I did notice that one of  
the height/width from the NSRect  object pass has values the size  
of the window and the other is 0,0.


The one created from the Object you dragged in doesn't have a view  
created for it so that is the 0,0.



Any guidance, clarification and etc. will be greatly appreciated.

thanks,
graham


--Nathan


___

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: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?

2008-05-24 Thread Nathan Kinsinger


On May 24, 2008, at 5:43 PM, Graham Reitz wrote:

(fyi) I am coming from the non Mac C++ land and I am trying to grok  
Obj-C and the Cocoa framework.


1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Drag an Object to MainMenu.nib


You don't need to do this, the Custom View is all you need (it is an  
object).



4) Name the Custom View and Object to the same class name


Just set the class of the Custom View.


5) Write the class files and add them to the project
6) Derive the class from NSView and implement the initWithFrame  
method.

7) Run the program in debug mode.

initWithFrame is called twice (self equals something different each  
call).


One is from the Custom View and the other is from the Object.

-Where is the other derived NSView object getting instantiated and  
what is it?


-Is 'self' the same as 'this'?  It doesn't seem like the same since  
super is the parent class.


-How can I tell if the sub-classed NSView instance is from the  
Custom View that was dragged over in IB?  I did notice that one of  
the height/width from the NSRect  object pass has values the size of  
the window and the other is 0,0.


The one created from the Object you dragged in doesn't have a view  
created for it so that is the 0,0.



Any guidance, clarification and etc. will be greatly appreciated.

thanks,
graham


--Nathan
___

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: how to override image cell display in IKImageBroserView?

2008-05-24 Thread Jens Alfke


On 23 May '08, at 2:37 PM, Wayne Shao wrote:

I want to overlay a small icon at the corner of each images in my  
browser
view. The purpose of this is to provide a visual indicator of  
different
properties in my images, which is better than putting some text in  
title/or

subtitle.

Is it possible without creating a new image representation for each  
cell?


Not that I know of. IKImageBrowserView has very limited customization.  
(You can look at /Developer/Examples/PubSub/NewMusic/ to see some  
things I've done with this view.)


I once tried to subclass the view, override -drawRect:, and draw my  
own content on top of the basic content, but this doesn't work  
reliably. I think the problem is that the view uses an OpenGL surface  
for some of its rendering, and this seems to end up on top of other  
drawing calls, even if they were made later.


—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: check if app opens with a document on startup

2008-05-24 Thread Jens Alfke


On 23 May '08, at 9:12 AM, Torsten Curdt wrote:

Hm ...somehow missed that response. But got it working myself. It's  
actually much simpler:


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
   int documentCount = [[[NSDocumentController  
sharedDocumentController] documents] count];


Of course that only works if (a) you're using NSDocument to open all  
files, and (b) all the open-file requests actually succeeded in  
opening documents.


—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: Quit iTunes

2008-05-24 Thread Gregory Weston

Mr. Gecko wrote:


That is slow because it has to compile. but if I can't get this apple
event to work than I might do that


It's not Cocoa, but it is efficient...

To find out if an app with a given bundle ID is running:

#include "ProcessIsRunningWithBundleID.h"
#include 

int ProcessIsRunningWithBundleID(CFStringRef inBundleID,  
ProcessSerialNumber* outPSN)

{
  int theResult = 0;

  ProcessSerialNumber thePSN = {0, kNoProcess};
  OSErr theError = noErr;
  do {
theError = GetNextProcess(&thePSN);
if(theError == noErr)
{
  CFDictionaryRef theInfo = NULL;
  theInfo = ProcessInformationCopyDictionary(&thePSN,
  
kProcessDictionaryIncludeAllInformationMask);

  if(theInfo)
  {
CFStringRef theBundleID = CFDictionaryGetValue(theInfo,  
IOBundleIdentifierKey);

if(theBundleID)
{
  if(CFStringCompare(theBundleID, inBundleID, 0) ==  
kCFCompareEqualTo)

  {
theResult = 1;
  }
}
CFRelease(theInfo);
  }
}
  } while((theError != procNotFound) && (theResult == 0));

  if(theResult && outPSN)
  {
*outPSN = thePSN;
  }

  return theResult;
}

The second argument can be NULL. If you pass the address of a  
ProcessSerialNumber, you can then use this routine to quit it.


OSErr QuitApplicationByPSN(const ProcessSerialNumber* inPSN)
{
  AppleEvent theQuitEvent = {typeNull, NULL};
  AEBuildError theBuildError;
  OSErr theError = AEBuildAppleEvent(kCoreEventClass,  
kAEQuitApplication, typeProcessSerialNumber, inPSN,
sizeof(ProcessSerialNumber), kAutoGenerateReturnID,  
kAnyTransactionID, &theQuitEvent,

&theBuildError,"");
  if(theError == noErr)
  {
AppleEvent theReply = {};
theError = AESend(&theQuitEvent, &theReply, kAENoReply |  
kAENeverInteract,

  kAENormalPriority, kNoTimeOut, NULL, NULL);
(void)AEDisposeDesc(&theQuitEvent);
  }
  return theError;
}

___

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]


How many times will a sub-classed NSView be instantiated in a simple Cocoa App?

2008-05-24 Thread Graham Reitz
(fyi) I am coming from the non Mac C++ land and I am trying to grok  
Obj-C and the Cocoa framework.


1) Create a simple Cocoa application
2) Open IB and drag a Custom View over to the Window
3) Drag an Object to MainMenu.nib
4) Name the Custom View and Object to the same class name
5) Write the class files and add them to the project
6) Derive the class from NSView and implement the initWithFrame method.
7) Run the program in debug mode.

initWithFrame is called twice (self equals something different each  
call).


-Where is the other derived NSView object getting instantiated and  
what is it?


-Is 'self' the same as 'this'?  It doesn't seem like the same since  
super is the parent class.


-How can I tell if the sub-classed NSView instance is from the Custom  
View that was dragged over in IB?  I did notice that one of the height/ 
width from the NSRect  object pass has values the size of the window  
and the other is 0,0.


Any guidance, clarification and etc. will be greatly appreciated.

thanks,
graham



___

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: How to tell if iTunes is running.

2008-05-24 Thread has

Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.


iTunesIsOpen = NO;
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSString* iTunesPath = [workspace  
absolutePathForAppBundleWithIdentifier:@"com.apple.iTunes"];

NSArray* lApplications = [workspace launchedApplications];
int lAppsCount = [lApplications count];
int a;
for (a = 0; a < lAppsCount; a++)
{
NSDictionary* applicationD = [lApplications objectAtIndex:a];
if ([[applicationD objectForKey:@"NSApplicationPath"]  
isEqualToString:iTunesPath])

{
iTunesIsOpen = YES;
break;
}
}


Yeah, bundle IDs are a good habit. Here's a slightly cleaner, case- 
insensitive version of the above:


BOOL IsRunning(NSString *bundleID) {
	NSEnumerator *appsList = [[[NSWorkspace sharedWorkspace]  
launchedApplications] objectEnumerator];

NSDictionary *appInfo;
bundleID = [bundleID lowercaseString];
while (appInfo = [appsList nextObject]) {
		if ([[[appInfo objectForKey: @"NSApplicationBundleIdentifier"]  
lowercaseString] isEqual: bundleID])

return YES;
}
return NO;
}


Or just use one of the ObjC-AppleEvent bridges to do everything. For  
example, using objc-appscript:


#import 
#import "ITGlue/ITGlue.h"

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	ITApplication *itunes = [[ITApplication alloc] initWithBundleID:  
@"com.apple.itunes"];


NSLog(@"Is running: %i", [itunes isRunning]);

[[itunes run] send];

NSLog(@"Is running: %i", [itunes isRunning]);

[[itunes quit] send];

while([itunes isRunning]) {
printf("Waiting while iTunes quits...\n");
sleep(1);
}

NSLog(@"Is running: %i", [itunes isRunning]);

[itunes release];
[pool release];
return 0;
}

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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: How to tell if iTunes is running.

2008-05-24 Thread Mr. Gecko
I agree that the bundle identifier is more reliable thanks for the  
tip. I am going to be using it

On May 24, 2008, at 4:11 PM, Jens Alfke wrote:



On 24 May '08, at 12:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.

...
 if ([[applicationD objectForKey:@"NSApplicationPath"]  
isEqualToString:iTunesPath])


It would be simpler just to use the "NSApplicationBundleIdentifier"  
key, comparing it with "com.apple.iTunes".


—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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: File's Owner

2008-05-24 Thread Johnny Lundy
I dunno. Your book seems to be one of the few, if not the only, that  
is not on my bookshelf.


If you email me your page on File's Owner, I can give feedback.

On May 23, 2008, at 9:59 PM, [EMAIL PROTECTED] wrote:


I despair that I am unable to adequately explain the concept and
utility of File's Owner to you.  This disturbs me greatly because I
have written a book about Cocoa Programming, and I explained File's
Owner in that book.   I fear that I have failed.  If I can't explain
this concept to a very learned programmer, how can I explain it to a
true novice.


___

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: NSURLConnection canHandleRequest: succeeds even with no network

2008-05-24 Thread Jens Alfke


On 23 May '08, at 11:11 PM, Mike wrote:

Why does [ NSURLConnection canHandleRequest: ] return YES even if I  
turn off all my network connections? I thought this method was  
supposed to be used for preflighting connection requests?


No, it just tells you whether there's support for that URL scheme  
(http:, ftp:, etc.)


If you want to tell whether the host is reachable, you need to use the  
System Configuration API — look up the docs for  
SCNetworkCheckReachabilityByName. (I also just noticed  
CFHostGetReachability, which looks like a higher-level interface that  
might be easier to call.)


Even this just checks the system's network interfaces and routing  
tables to decide whether the kernel knows how to route a packet  
towards that address — it does _not_ actually try to contact the  
server, so it can't tell you if there's a broken gateway, or the  
server is down, or it's not listening on the port you want to connect  
to, etc.


—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: How to tell if iTunes is running.

2008-05-24 Thread Steve Christensen

On May 24, 2008, at 2:11 PM, Jens Alfke wrote:


On 24 May '08, at 12:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.

...
  if ([[applicationD objectForKey:@"NSApplicationPath"]  
isEqualToString:iTunesPath])


It would be simpler just to use the "NSApplicationBundleIdentifier"  
key, comparing it with "com.apple.iTunes".


I didn't see that in the headers but it is in the docs. Yes, that'd  
work better.


___

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: How to tell if iTunes is running.

2008-05-24 Thread Steve Christensen
My version wasn't about using the path for something else; it was  
only about providing a method that doesn't care what the iTunes  
application is called. For example, if someone were to rename it  
"iTunes 7.6.2", then your version would stop working.


However, as Thomas Engelmeier pointed out in a separate message,  
Apple doesn't currently localize the names of its iApps so you're  
probably safe.



On May 24, 2008, at 12:17 PM, Mr. Gecko wrote:


because I do not need the path for what I am doing.





On May 24, 2008, at 2:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.


iTunesIsOpen = NO;
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSString* iTunesPath = [workspace  
absolutePathForAppBundleWithIdentifier:@"com.apple.iTunes"];

NSArray* lApplications = [workspace launchedApplications];
int lAppsCount = [lApplications count];
int a;
for (a = 0; a < lAppsCount; a++)
{
  NSDictionary* applicationD = [lApplications objectAtIndex:a];
  if ([[applicationD objectForKey:@"NSApplicationPath"]  
isEqualToString:iTunesPath])

  {
 iTunesIsOpen = YES;
 break;
  }
}

[iTunesLMenu setTitle: NSLocalizedString(iTunesIsOpen ? @"Quit  
iTunes" : @"Launch iTunes",@"")];



On May 24, 2008, at 8:29 AM, Mr. Gecko wrote:


Thanks I am using this
iTunesIsOpen = NO;
[iTunesLMenu setTitle: NSLocalizedString(@"Launch iTunes",@"")];
NSArray *lApplications = [[NSWorkspace sharedWorkspace]  
launchedApplications];

int a;
for (a=0; a<[lApplications count]; a++) {
  NSDictionary *applicationD = [lApplications objectAtIndex:a];
  if ([[applicationD objectForKey:@"NSApplicationName"]  
isEqualToString:@"iTunes"]) {

 iTunesIsOpen = YES;
 [iTunesLMenu setTitle: NSLocalizedString(@"Quit iTunes",@"")];
  }
}
On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote:


On May 23, 2008, at 4:01 PM, Mr. Gecko wrote:


How can I tell if iTunes is running with cocoa.


In this particular case, you should be able to get that  
information using -[NSWorkspace launchedApplications]...


___

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: How to tell if iTunes is running.

2008-05-24 Thread Jens Alfke


On 24 May '08, at 12:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.

...
  if ([[applicationD objectForKey:@"NSApplicationPath"]  
isEqualToString:iTunesPath])


It would be simpler just to use the "NSApplicationBundleIdentifier"  
key, comparing it with "com.apple.iTunes".


—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: Re: Quit iTunes

2008-05-24 Thread Daniel Dickison
NSAppleScript * script = [[[NSAppleScript alloc]  
initWithSource:@"tell application \"iTunes\" \n quit \nend tell"]  
autoRelease];

[script executeAndReturnError: nil];


That is slow because it has to compile. but if I can't get this  
apple event to work than I might do that


I would hope that the frequency with which you tell iTunes to quit is  
low enough that the overhead of compiling the script would be  
negligible :)

___

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: Core Data dynamic attributes and fetching

2008-05-24 Thread Ben Trumbull

At 2:56 AM -0700 5/24/08, [EMAIL PROTECTED] wrote:
I have a core data object graph using an SQLite store where several 
entities have an attribute containing a date (eg, birthDate). This is 
stored as a date type.


I am currently implementing an NSPredicateEditor for building smart 
groups. Each smart group simply saves this predicate to an attribute 
and then fetches using that.


The problem is that I want to offer to filter by ('days since birth' 
== 7), as well as (birthDate == 01/01/01). This is where I have hit a

wall. I can't set a dynamic transient property for daysSinceBirth as
these can't be used in fetch requests, and I can't convert the number
of days to an absolute date as this loses the dynamic-calculation part
of the number.


This is the part I'm not following.  Why don't you transform:

'days since birth' == 7 into 'birthDate == $x' where $x = 
'currentDate - 7 days'


Generally speaking, you always want to work with absolute time 
(seconds since reference date, UTC) in the database.  The only place 
you should use calendar, human legible dates, or time zones is with 
entities like users' Preferences or user's active Session.  Obviously 
your UI layer needs to represent dates in a way your customers will 
appreciate.


Calendar properties are political and historical issues as well as 
geographically relative.  Calendars make the Unicode spec look like 
riding a big wheel.  They are generally not useful to store in the 
database.


Nothing stops you from using the NSPredicateEditor with 'fake' 
properties and then grabbing the predicate it makes and transforming 
it into another one.  Pulling apart an NSPredicate tree is tedious, 
but not hard.

--

-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: How to tell if iTunes is running.

2008-05-24 Thread Thomas Engelmeier


On 24.05.2008, at 21:05, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.



For third party software you'd be right - Apple does not localize the  
names of iTunes / iPhoto / iDVD (browse through the *.jproj/ 
infoPlist.strings)  and AFIAK does not handle renamed or moved  
variants in their updaters, so people renamaing iApps face trouble  
anyway...


Best regards,
Tom_E
___

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: Quit iTunes

2008-05-24 Thread Mr. Gecko

Thank you so much it works.
On May 24, 2008, at 2:38 PM, has wrote:


Mr. Gecko wrote:


How would I quit iTunes. There is a way to launch it with
NSWorkspace but how about quit?




Send a quit AppleEvent


How would I do that?
I have been looking for a while and I found aevtquit but I can't find
out how to send.


Example:

#include 

OSStatus QuitApplication(char *bundleID) {
   AppleEvent evt, res;
   OSStatus err;

   err = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication,
   typeApplicationBundleID,
   bundleID, strlen(bundleID),
   kAutoGenerateReturnID,
   kAnyTransactionID,
   &evt, NULL, "");
   if (err == noErr) {
   err = AESendMessage(&evt, &res, kAENoReply, kAEDefaultTimeout);
   AEDisposeDesc(&evt);
   }
   return err;
}

int main (int argc, const char * argv[]) {
   return QuitApplication("com.apple.itunes");
}


For anything more complex, use a high-level bridge (e.g. see my sig).

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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: Quit iTunes

2008-05-24 Thread Mr. Gecko
That is slow because it has to compile. but if I can't get this apple  
event to work than I might do that

On May 24, 2008, at 2:23 PM, Tommy Nordgren wrote:



On 24 maj 2008, at 18.33, Mr. Gecko wrote:


How would I do that?


	NSAppleScript * script = [[[NSAppleScript alloc]  
initWithSource:@"tell application \"iTunes\" \n quit \nend tell"]  
autoRelease];

[script executeAndReturnError: nil];




I have been looking for a while and I found aevtquit but I can't  
find out how to send.

On May 24, 2008, at 11:13 AM, Tommy Nordgren wrote:



On 24 maj 2008, at 17.49, Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with  
NSWorkspace but how about quit?

___

Send a quit AppleEvent
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[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/tommy.nordgren%40comhem.se

This email sent to [EMAIL PROTECTED]


--
Skinheads are so tired of immigration, that they are going to move  
to a country that don't accept immigrants!

Tommy Nordgren
[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: Quit iTunes

2008-05-24 Thread has

Mr. Gecko wrote:


How would I quit iTunes. There is a way to launch it with
NSWorkspace but how about quit?




Send a quit AppleEvent


How would I do that?
I have been looking for a while and I found aevtquit but I can't find
out how to send.


Example:

#include 

OSStatus QuitApplication(char *bundleID) {
AppleEvent evt, res;
OSStatus err;

err = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication,
typeApplicationBundleID,
bundleID, strlen(bundleID),
kAutoGenerateReturnID,
kAnyTransactionID,
&evt, NULL, "");
if (err == noErr) {
err = AESendMessage(&evt, &res, kAENoReply, kAEDefaultTimeout);
AEDisposeDesc(&evt);
}
return err;
}

int main (int argc, const char * argv[]) {
return QuitApplication("com.apple.itunes");
}


For anything more complex, use a high-level bridge (e.g. see my sig).

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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: Quit iTunes

2008-05-24 Thread Tommy Nordgren


On 24 maj 2008, at 18.33, Mr. Gecko wrote:


How would I do that?


	NSAppleScript * script = [[[NSAppleScript alloc]  
initWithSource:@"tell application \"iTunes\" \n quit \nend tell"]  
autoRelease];

[script executeAndReturnError: nil];




I have been looking for a while and I found aevtquit but I can't  
find out how to send.

On May 24, 2008, at 11:13 AM, Tommy Nordgren wrote:



On 24 maj 2008, at 17.49, Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with  
NSWorkspace but how about quit?

___

Send a quit AppleEvent
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[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/tommy.nordgren%40comhem.se

This email sent to [EMAIL PROTECTED]


--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

Tommy Nordgren
[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]


NSWindow CoreAnimation Delegate not being called

2008-05-24 Thread Milen Dzhumerov

Hi all,

I've been playing with CA and I tried to set up one my objects as the  
delegate for the frame change animation for an NSWindow by using the  
following code:


CABasicAnimation* anim = [window animationForKey:@"frame"];
anim.delegate = self;
[[window animator] setFrame:NSMakeRect(400, 500, 500, 500) display:YES];

Using this, the window correctly animates but the delegate methods  
(namely animationDidStop:finished: and animationDidStart:) for the  
CAAnimation do not get called. When I use the exact same piece of code  
for setting the delegate of view animations, the delegates do get  
called.


Thanks,
M

___

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: How to tell if iTunes is running.

2008-05-24 Thread Steve Christensen
Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.


iTunesIsOpen = NO;
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSString* iTunesPath = [workspace  
absolutePathForAppBundleWithIdentifier:@"com.apple.iTunes"];

NSArray* lApplications = [workspace launchedApplications];
int lAppsCount = [lApplications count];
int a;
for (a = 0; a < lAppsCount; a++)
{
   NSDictionary* applicationD = [lApplications objectAtIndex:a];
   if ([[applicationD objectForKey:@"NSApplicationPath"]  
isEqualToString:iTunesPath])

   {
  iTunesIsOpen = YES;
  break;
   }
}

[iTunesLMenu setTitle: NSLocalizedString(iTunesIsOpen ? @"Quit  
iTunes" : @"Launch iTunes",@"")];



On May 24, 2008, at 8:29 AM, Mr. Gecko wrote:


Thanks I am using this
iTunesIsOpen = NO;
[iTunesLMenu setTitle: NSLocalizedString(@"Launch iTunes",@"")];
NSArray *lApplications = [[NSWorkspace sharedWorkspace]  
launchedApplications];

int a;
for (a=0; a<[lApplications count]; a++) {
   NSDictionary *applicationD = [lApplications objectAtIndex:a];
   if ([[applicationD objectForKey:@"NSApplicationName"]  
isEqualToString:@"iTunes"]) {

  iTunesIsOpen = YES;
  [iTunesLMenu setTitle: NSLocalizedString(@"Quit iTunes",@"")];
   }
}
On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote:


On May 23, 2008, at 4:01 PM, Mr. Gecko wrote:


How can I tell if iTunes is running with cocoa.


In this particular case, you should be able to get that  
information using -[NSWorkspace launchedApplications]...


___

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: Change the Language of just one Application

2008-05-24 Thread Jean-Daniel Dupas

You can pass this argument:

-AppleLanguages '(de)'

AppleLanguages is the UserDefauts key (from the NSGlobalDomain domain)  
that control this behavior.




Le 24 mai 08 à 11:09, Gerriet M. Denkmann a écrit :

Somewhere I have read (if my memory is not faulty) that it is  
possible to lauch an app with some arguments (or environment  
variables?) changing the preference order of languages.


E.g. my preferred language is English, but I want to test the German  
localization of some app.


Xcode allows me to set:
Command-line arguments to pass to the program upon launch
Environment variables to set before launching the program

But what to set where?

Another (related) problem: this works:
> open /Applications/TextEdit.app

But this does not:
> open /Applications/TextEdit.app -NSOpen /tmp/a
although recommended as "more commonly used command-line argument"  
by the "Runtime Configuration Guidelines" in "Using Launch Arguments".



Kind regards,

Gerriet.

___

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: Quit iTunes

2008-05-24 Thread I. Savant

On May 24, 2008, at 12:33 PM, Mr. Gecko wrote:


How would I do that?
I have been looking for a while and I found aevtquit but I can't  
find out how to send.


  Read the documentation:

http://developer.apple.com/documentation/AppleScript/Conceptual/AppleEvents/intro_aepg/chapter_1_section_1.html

  Oddly enough, there's a section called, "Creating & Sending Apple  
Events" that has some code examples ...


--
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: Quit iTunes

2008-05-24 Thread Mr. Gecko

How would I do that?
I have been looking for a while and I found aevtquit but I can't find  
out how to send.

On May 24, 2008, at 11:13 AM, Tommy Nordgren wrote:



On 24 maj 2008, at 17.49, Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with  
NSWorkspace but how about quit?

___

Send a quit AppleEvent
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[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: Quit iTunes

2008-05-24 Thread Tommy Nordgren


On 24 maj 2008, at 17.49, Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with  
NSWorkspace but how about quit?

___

Send a quit AppleEvent
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[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]


Quit iTunes

2008-05-24 Thread Mr. Gecko
How would I quit iTunes. There is a way to launch it with NSWorkspace  
but how about quit?

___

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: How to tell if iTunes is running.

2008-05-24 Thread Mr. Gecko

Thanks I am using this
iTunesIsOpen = NO;
[iTunesLMenu setTitle: NSLocalizedString(@"Launch iTunes",@"")];
NSArray *lApplications = [[NSWorkspace sharedWorkspace]  
launchedApplications];

int a;
for (a=0; a<[lApplications count]; a++) {
   NSDictionary *applicationD = [lApplications objectAtIndex:a];
   if ([[applicationD objectForKey:@"NSApplicationName"]  
isEqualToString:@"iTunes"]) {

  iTunesIsOpen = YES;
  [iTunesLMenu setTitle: NSLocalizedString(@"Quit iTunes",@"")];
   }
}
On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote:



On May 23, 2008, at 4:01 PM, Mr. Gecko wrote:


How can I tell if iTunes is running with cocoa.



In this particular case, you should be able to get that information  
using -[NSWorkspace launchedApplications]...


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: File's Owner

2008-05-24 Thread Hamish Allan
On Sat, May 24, 2008 at 1:21 AM, Johnny Lundy <[EMAIL PROTECTED]> wrote:

> I have used it to set my class as its delegate so that I could implement the
> delegate method applicationWillTerminate:, and that was great. Easy to
> understand, it calls respondsToSelector: and then calls my delegate method.
> Cool. But as far as the "serves as a proxy for the object that owns the
> nib", why does a nib need an owner? Why do I care who the owner is? My
> NSArrayControllers can be bound to model objects without anything going
> through File's Owner.

They can indeed. You can use your nib-instantiated controller object's
awakeFromNib method to set up your model objects, and wire your main
menu's Open and Save items directly to methods in that controller. But
if you ever want to use more than one controller, you'll probably have
to start using methods like applicationDidFinishLaunching: (for
synchronisation). That code path, as well as
applicationWillTerminate:, goes through an object outside your nib
(NSApplication), even though it's subsequently calling a delegate
method inside your nib.

Incidentally, have you ever written a document-based cocoa app?

> Now if what they are trying to say is that I can bind a controller to File's
> Owner and it will "see" all the properties of all the objects in the class
> that File's Owner is set to, that would be cool.

That is exactly what they are saying.

> In that case it is just
> serving as an instance of a class and can be used to reach properties of
> objects of that class.

Well, it's serving as a *proxy* for an *existing* instance of a class.
Whereas instantiating an NSObject in the nib creates an instance and
allows you to make connections to it, you can use File's Owner to make
connections to an object that exists prior to loading of, and outside
of, the nib.

Hamish
___

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: NSURLConnection canHandleRequest: succeeds even with no network

2008-05-24 Thread Sherm Pendley
On Sat, May 24, 2008 at 2:11 AM, Mike <[EMAIL PROTECTED]> wrote:

> Why does [ NSURLConnection canHandleRequest: ] return YES even if I turn
> off all my network connections? I thought this method was supposed to be
> used for preflighting connection requests?


>From what I gather, the "preflight" referred to in the docs is just a check
to see if a protocol class is registered to handle the scheme (http:, file:,
etc.). That is, it tells you if the proper machinery is in place to
*attempt* the connection, not whether the attempt will succeed or not. It
allows you  to distinguish between "I don't grok gopher" and actual
network-layer errors.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.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: Accessing colours in NSColorPanel swatch

2008-05-24 Thread Keith Blount
Just for the archives, I found the solution to this on CocoaDev (which I had 
missed in my original search). Unfortunately it uses private methods, but I 
wrote an NSColorPanel category to access the swatch colours that should fail 
safely if the private methods are changed. I've added the category to the 
CocoaDev page here:

http://www.cocoadev.com/index.pl?NSColorPanel

Thanks anyway,
Keith

-- ORIGINAL MESSAGE --

> I can't seem to find anything on this in the docs for NSColorPanel, 
> NSColorList, or the "working with colors"
> documentation, but is there any way to access the user-defined list of 
> colours in NSColorPanel? I mean the
> custom colours that the user drags into the swatch at the bottom of the 
> colour panel for frequent use. I would 
> like to provide a contextual menu in my application that makes these colours 
> immediately available to the user,
> so that the user doesn't always have to open the colour panel to access the 
> colours he or she has defined.
>
> Maybe I'm missing something obvious, but I would be very grateful for a point 
> in the right direction.
>
> Many thanks in advance and all the best,
> 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: File's Owner

2008-05-24 Thread Sherm Pendley
On Sat, May 24, 2008 at 6:49 AM, Paul Sargent <[EMAIL PROTECTED]> wrote:

>
> On 24 May 2008, at 05:39, Andreas Mayer wrote:
>
>>
>> I thought, maybe a picture would help:
>>
>> http://www.harmless.de/images/other/files_owner.png
>>
>
> Exactly the picture I was about to draw.
>
> Johnny Lundy wrote:
>
>> Saying it connects the nib to an object outside the nib sounds good, but
>> what object is that?
>>
>
> The object that loaded the NIB. What object is that? Whichever is passed
> when the NIB is loaded with [NSBundle loadNibNamed:owner:]
>
> e.g. NSApplication probably has code that looks like
>
> [NSBundle loadNibNamed:@"MainMenu" owner:self]
>
> You might have a piece of code that reads
>
> [NSBundle loadNibNamed:@"InspectorWindows" owner:inspectorController]


If your inspectorController is your own custom subclass of
NSWindowController, it will make itself the nib's owner if you create it
like this:

MyInspectorController* ic = [[MyInspectorController alloc] initWithNibName:@
"inspectorWindows"];

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.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: Properties & GC (was Re: Cocoa et al as HCI usability problem)

2008-05-24 Thread Michael Ash
On Fri, May 23, 2008 at 5:11 PM, Sherm Pendley <[EMAIL PROTECTED]> wrote:
> On Fri, May 23, 2008 at 4:45 AM, Michael Ash <[EMAIL PROTECTED]> wrote:
>>
>> On Fri, May 23, 2008 at 4:30 PM, Sherm Pendley <[EMAIL PROTECTED]>
>> wrote:
>>
>> > Does this sound similar? Objective-C obviously already has access
>> > limiters,
>> > but disassociating the object and property storage would eliminate the
>> > last
>> > remnants of the fragile base class problem. It would also allow
>> > categories
>> > to add ivars, would it not?
>>
>> Categories could only add ivars if they were loaded at the same time
>> as the main class, otherwise they could change the size of already
>> instantiated objects which is Very Bad.
>
> That's just the problem that inside-out objects would solve! With the ivars
> stored separately from the isa pointer, adding an ivar would simply add
> another ivar storage dictionary to the heap. Since inside-out objects are
> nothing more than keys into the ivar storage dictionaries, adding another
> dictionary doesn't change the size of any objects past, present, or future.

It certainly would solve that problem, but the solution isn't free.
Dictionary lookups are significantly more expensive than a direct
memory load, especially when you make the dictionaries thread safe and
then pound on them a lot from multiple threads. Taking a lock every
time I access an ivar doesn't sound very fun to me.

This idea is commonly used explicitly to provide ivar-like things in
categories. And in fact with the addition of garbage collection this
becomes vastly easier to accomplish; your dictionary can simply be an
NSMapTable with weak keys, removing the need to do evil swizzling
tricks so you can know when objects get deallocated.

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: File's Owner

2008-05-24 Thread Paul Sargent


On 24 May 2008, at 05:39, Andreas Mayer wrote:


I thought, maybe a picture would help:

http://www.harmless.de/images/other/files_owner.png


Exactly the picture I was about to draw.

Johnny Lundy wrote:
Saying it connects the nib to an object outside the nib sounds good,  
but what object is that?


The object that loaded the NIB. What object is that? Whichever is  
passed when the NIB is loaded with [NSBundle loadNibNamed:owner:]


e.g. NSApplication probably has code that looks like

[NSBundle loadNibNamed:@"MainMenu" owner:self]

You might have a piece of code that reads

[NSBundle loadNibNamed:@"InspectorWindows" owner:inspectorController]



___

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: NSTextView without word wrap?

2008-05-24 Thread Jonathan Dann

You're welcome, but I'd replace this:


const CGFloat LargeNumberForText = 1.0e7;
   [[textView textContainer]  
setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];


with

[[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX,  
FLT_MAX)];


hey presto 1 less line of code!  FLT_MAX is the largest representable  
floating point number. It *may* insulate you from processor  
differences, but someone would have to confirm to me that this could  
ever be a problem.


Jon

On 24 May 2008, at 02:35, David Carlisle wrote:

Based on your kindly giving me a precise reference I was able to  
remove a few unnecessary statements from my awake from nib.  It now  
reads as follows:


- (void) awakeFromNib {
   const CGFloat LargeNumberForText = 1.0e7;
   [[textView textContainer]  
setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];

   [[textView textContainer] setWidthTracksTextView:NO];
   [textView setHorizontallyResizable:YES];
}

Thanks,
DC

On May 23, 2008, at 4:08 PM, Jonathan Dann wrote:


Its in SMLViewMenuController.m line -(IBAction)lineWrapTextAction:

Jon

On 23 May 2008, at 22:58, David Carlisle wrote:


Looks interesting.  Thanks.

DC

On May 23, 2008, at 3:37 PM, Jonathan Dann wrote:

You may also like to look at the source code to Smultron by Peter  
Borg.  It's in there but I forget exactly.


http://smultron.sourceforge.net/

Jon

On 23 May 2008, at 21:55, David Carlisle wrote:

I made some guesses at which statements to copy from  
BiScrollAspect.m and came up with the following awakeFromNib.   
I'm not sure which statements are the most relevant, and why,  
but it seems to do what I need.


- (void) awakeFromNib {
const CGFloat LargeNumberForText = 1.0e7;
[[textView textContainer]  
setContainerSize:NSMakeSize(LargeNumberForText,  
LargeNumberForText)];

[[textView textContainer] setWidthTracksTextView:NO];
[[textView textContainer] setHeightTracksTextView:NO];
[textView setAutoresizingMask:NSViewNotSizable];
[textView setMaxSize:NSMakeSize(LargeNumberForText,  
LargeNumberForText)];

[textView setHorizontallyResizable:YES];
[textView setVerticallyResizable:YES];
}

On May 23, 2008, at 12:03 PM, Douglas Davidson wrote:



On May 23, 2008, at 10:33 AM, David Carlisle wrote:

I've spent the last few hours trying to create an NSTextView  
without word wrap.  The BiScrollAspect.m file in the  
textSizingExample project file is no help at all.


No help in that it doesn't do what you want, or no help in that  
you can't get it working in your app, or no help in some other  
way?


Douglas Davidson



___

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/j.p.dann%40gmail.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/davidcar1%40mstarmetro.net

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]

Core Data dynamic attributes and fetching

2008-05-24 Thread Ben

Hi all,

I have a core data object graph using an SQLite store where several  
entities have an attribute containing a date (eg, birthDate). This is  
stored as a date type.


I am currently implementing an NSPredicateEditor for building smart  
groups. Each smart group simply saves this predicate to an attribute  
and then fetches using that.


The problem is that I want to offer to filter by ('days since birth'  
== 7), as well as (birthDate == 01/01/01). This is where I have hit a  
wall. I can't set a dynamic transient property for daysSinceBirth as  
these can't be used in fetch requests, and I can't convert the number  
of days to an absolute date as this loses the dynamic-calculation part  
of the number. I did think of using a transformable attribute to  
convert a second date field to an int, but then apparently this can't  
be used in a fetch request either.


I suppose that I could use a placeholder segment of predicate which is  
replaced when used, but this seems a bit awkward and inelegant.


Does anyone have any suggestions on how I could achieve this?

Regards,

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]


Change the Language of just one Application

2008-05-24 Thread Gerriet M. Denkmann
Somewhere I have read (if my memory is not faulty) that it is  
possible to lauch an app with some arguments (or environment  
variables?) changing the preference order of languages.


E.g. my preferred language is English, but I want to test the German  
localization of some app.


Xcode allows me to set:
Command-line arguments to pass to the program upon launch
Environment variables to set before launching the program

But what to set where?

Another (related) problem: this works:
> open /Applications/TextEdit.app

But this does not:
> open /Applications/TextEdit.app -NSOpen /tmp/a
although recommended as "more commonly used command-line argument" by  
the "Runtime Configuration Guidelines" in "Using Launch Arguments".



Kind regards,

Gerriet.

___

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: Cleaning up a singleton

2008-05-24 Thread Sebastian Nowicki


On 24/05/2008, at 3:48 PM, Andreas Mayer wrote:

In case you use the notification, there is no need to expose  
anything. You just register a method of your singleton to receive  
the NSApplicationWillTerminateNotification and do your cleanup there.


On Apple's developer website there are several example projects that  
make use of this. Here's one:


http://developer.apple.com/samplecode/CapabilitiesSample/listing5.html

You need only look at the -init and the -applicationWillTerminate:  
methods.



Andreas


Oh, that is awesome. Thanks for pointing it out.

--
Sebastian Nowicki

___

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: Query about Zip command

2008-05-24 Thread parag vibhute
Sorry for my last email. That comment was incorrect(I was thinking
something else). Sorry again.

I will try with launchAppWithBundleIdentifier API & will let u know the output.

Thanks,
Palav

On 5/24/08, parag vibhute <[EMAIL PROTECTED]> wrote:
> I am launching my app through applet. So passing arguments as command
> line is only current solution for me.
>
> Thanks,
> Palav
>
> On 5/24/08, Andreas Mayer <[EMAIL PROTECTED]> wrote:
>>
>> Am 24.05.2008 um 08:08 Uhr schrieb Andrew Farmer:
>>
>>> GUI applications generally do not take arguments - opened files are
>>> passed using Apple Events. Hence, Launch Services doesn't provide
>>> any way to pass arguments.
>>
>> You can use Apple Events yourself, though. See NSWorkspace's
>> -
>> launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier
>> :
>>
>>
>> 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/parag.vibhute%40gmail.com
>>
>> This email sent to [EMAIL PROTECTED]
>>
>
>
> --
>
> There are many things in your life that will catch your eye but only a
> few will catch your heartpursue those'.
>


-- 

There are many things in your life that will catch your eye but only a
few will catch your heartpursue those'.
___

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: Query about Zip command

2008-05-24 Thread parag vibhute
I am launching my app through applet. So passing arguments as command
line is only current solution for me.

Thanks,
Palav

On 5/24/08, Andreas Mayer <[EMAIL PROTECTED]> wrote:
>
> Am 24.05.2008 um 08:08 Uhr schrieb Andrew Farmer:
>
>> GUI applications generally do not take arguments - opened files are
>> passed using Apple Events. Hence, Launch Services doesn't provide
>> any way to pass arguments.
>
> You can use Apple Events yourself, though. See NSWorkspace's
> -
> launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier
> :
>
>
> 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/parag.vibhute%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>


-- 

There are many things in your life that will catch your eye but only a
few will catch your heartpursue those'.
___

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: Removing the Filename flag in Doc. based Application

2008-05-24 Thread Caleb Strockbine

On May 23, 2008, at 2:51 PM, [EMAIL PROTECTED] wrote:

How do I set my document based application to omit the filename  
reference at

the top of each opened document window?


Kyle Sluder's explanation is quite informative, but it may also be  
more complicated than you need. If you really just want to change the  
name of your document, you can override -[NSDocument displayName]  
like this:


// Adding this method to your document subclass will cause the
// title of every document window to be "Foo".
- (NSString *)displayName
{
return @"Foo";
}


If you want to also remove the file proxy icon (small icon next to  
the window title), you'll likely want to create a custom window  
controller as described by Kyle and implement either the - 
windowDidLoad: or -awakeFromNib methods such that you get a reference  
to the icon button and send it a -setHidden: message, like this:


// Put the following in your custom window controller where it'll
// be executed soon after the window is loaded.
NSButton *fileButton =
[window standardWindowButton:NSWindowDocumentIconButton];
if (fileButton != nil) {
[fileButton setHidden:YES];
}

The reason for putting the code above in a custom window controller  
is that ideally, your document class shouldn't be in the business of  
defining what the window should look like. The window controller is a  
better place for that.


cheers,

Caleb Strockbine
___

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: Cleaning up a singleton

2008-05-24 Thread Andreas Mayer


Am 24.05.2008 um 09:28 Uhr schrieb Sebastian Nowicki:

I can't be certain that the cleanup function won't do other things  
in the future, such as removing files (locks).


If, for some other reason, you need to act when the application  
quits, you can register for the  
NSApplicationWillTerminateNotification notification.



Andreas


On 24/05/2008, at 2:24 PM, Andrew Merenbach wrote:


Hi,

Would the following NSApplication methods, placed into your  
application delegate's code, help at all?


- (void)applicationDidFinishLaunching:(NSNotification  
*)aNotification;

- (void)applicationWillTerminate:(NSNotification *)aNotification;

Of the latter, the docs say that one should "Put any necessary  
cleanup code in this method."


Cheers,
Andrew



I guess that would be the way to go. Although I'd have to either  
expose a method that wraps around the C function, or call the C  
function directly. Neither are really optimal, but the latter is a  
lot better than nothing.


In case you use the notification, there is no need to expose anything.  
You just register a method of your singleton to receive the  
NSApplicationWillTerminateNotification and do your cleanup there.


On Apple's developer website there are several example projects that  
make use of this. Here's one:


http://developer.apple.com/samplecode/CapabilitiesSample/listing5.html

You need only look at the -init and the -applicationWillTerminate:  
methods.



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]


Re: A documetation suggestion (was Re: Cocoa et al as HCI usability problem)

2008-05-24 Thread Gerriet M. Denkmann


On 23 May 2008, at 23:18, Shawn Erickson wrote:


On Fri, May 23, 2008 at 9:19 AM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:


So I
- entered "disc recording" into Xcode -> Help -> Documentation -  
nothing at

all


...talking about Xcode 2.5 in the following...

Try changing Xcode to search documentation by "Full-Text Search" when
you aren't attempting to find the definition of method/function. You
can do that using the little magnify glass in the search field on the
documentation window. If you do that you get many many relevant hits.


...answering about Xcode Version 2.4:
I did try both modes (Full-Text / API) and both gave the same empty  
result.

Sorry not to have mentioned this in my post.

Kind regards,

Gerriet.

___

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: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]

2008-05-24 Thread Gerriet M. Denkmann


On 23 May 2008, at 23:30, [EMAIL PROTECTED] wrote:


From what I have read quickly since Sean McBride sent his comment,  
UTIs are
not yet implemented to the point where I could get the UTI of  
every file on

my computer.


Sure you can.  Use LSCopyItemAttributes() with kLSItemContentType.


How do you know this?

I just read "An Overview of UTI Functions" in the "Uniform Type  
Identifiers Overview" and did find no mention at all of this.
(Actually I had been looking for something like LSCopyItemAttribute 
(), concluded that this did not exist, further concluded that this  
nice technology obviously was only half implemented by Apple and that  
I had to wait another year or two before it was usable).


Kind regards,

Gerriet.

___

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: Cleaning up a singleton

2008-05-24 Thread Sebastian Nowicki


On 24/05/2008, at 2:20 PM, Andreas Mayer wrote:



Am 24.05.2008 um 08:07 Uhr schrieb Sebastian Nowicki:

The library requires me to call a function which allocates memory  
to that global variable, and afterwards call a function which  
deallocates that memory. My singleton class calls the function to  
initialise in the init method, but I don't know how to deallocate  
the memory. [...] How would I handle this?


Um. You don't?

Since all memory is reclaimed when the application quits,  
deallocating a singleton to free memory is not necessary.


I can't be certain that the cleanup function won't do other things in  
the future, such as removing files (locks).


If, for some other reason, you need to act when the application  
quits, you can register for the  
NSApplicationWillTerminateNotification notification.



Andreas


On 24/05/2008, at 2:24 PM, Andrew Merenbach wrote:


Hi,

Would the following NSApplication methods, placed into your  
application delegate's code, help at all?


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
- (void)applicationWillTerminate:(NSNotification *)aNotification;

Of the latter, the docs say that one should "Put any necessary  
cleanup code in this method."


Cheers,
Andrew



I guess that would be the way to go. Although I'd have to either  
expose a method that wraps around the C function, or call the C  
function directly. Neither are really optimal, but the latter is a lot  
better than nothing.


Thanks.

--
Sebastian Nowicki

___

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]