Re: noob q: adding a button to a window programmatically

2008-06-10 Thread Graham Cox
You haven't set the button's frame size. If you use -initWithFrame:  
and pass something sensible that should work. Note - because NSButton  
subclasses NSView, the designated initializer for NSView  
(initWithFrame;) must be used.


hth,

Graham


On 10 Jun 2008, at 3:28 pm, Stuart Malin wrote:

Until now I have created my GUIs using IB.  I want a better  
understanding of what goes on under the hood of instantiating a  
Nib, so decided to try adding a button to a window programmatically.  
I can't get the button to appear, and so presume I am missing some  
fundamental concept.  Here's my code:


NSButton *button = [[NSButton alloc] init];
[button setTitle:@New Button];
[button setHidden:NO];
[button setButtonType:NSPushOnPushOffButton];
NSPoint p = NSMakePoint(0, 0);
[button setFrameOrigin:p];

NSView *theWindowContentView = [theWindow contentView];
[theWindowContentView addSubview:button];
[theWindowContentView setNeedsDisplay:YES];
[button release];

theWindow is an ivar that is set by Nib loading to hold a  
reference to the window (my controller object is instantiated in the  
Nib). Again, I know I must be overlooking something fundamental, so  
would appreciate some guidance on the mechanics of instantiating  
controls programmatically. TIA.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: noob q: adding a button to a window programmatically

2008-06-10 Thread Andrew Farmer

On 09 Jun 08, at 22:28, Stuart Malin wrote:
Until now I have created my GUIs using IB.  I want a better  
understanding of what goes on under the hood of instantiating a  
Nib, so decided to try adding a button to a window programmatically.  
I can't get the button to appear, and so presume I am missing some  
fundamental concept.  Here's my code:


[theWindowContentView setNeedsDisplay:YES];


Not the problem, but as a general note, you should never need to call  
setNeedsDisplay: (or its close relative, display) on anything other  
than self. Views are supposed to manage redrawing themselves. If they  
fail to do so correctly, it's a bug.

___

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]


Detect editing a outline view cell

2008-06-10 Thread Ivan C Myrvold
I have been trying to find a solution to this for a long time: I want  
to have a action method to execute when I doubleclick in an  
NSOutlineView cell to start editing it.
In an ordinary NSTextField delegate method textShouldBeginEditing, but  
that doesn't work for NSTextCell.


Ivan
___

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: Detect editing a outline view cell

2008-06-10 Thread Ivan C Myrvold

To answer my own question:

Use the NSOutlineView delegate method  
outlineView:shouldEditTableColumn:item:


Ivan

Den 10. juni. 2008 kl. 08:11 skrev Ivan C Myrvold:

I have been trying to find a solution to this for a long time: I  
want to have a action method to execute when I doubleclick in an  
NSOutlineView cell to start editing it.
In an ordinary NSTextField delegate method textShouldBeginEditing,  
but that doesn't work for NSTextCell.


Ivan
___

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/ivan%40myrvold.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: JNI trouble

2008-06-10 Thread Andrew Farmer

On 09 Jun 08, at 23:15, brien colwell wrote:

hi all,

I'm having some trouble compiling a JNI lib on Osx. I get the  
following Undefined synbols errors ... does anyone have a pointer?  
Very much appreciated!


void *a_pointer = 0x90A4BCED;

No, but seriously...

cc -bundle -I/System/Library/Frameworks/JavaVM.framework/Headers -o  
libName.jnilib -framework JavaVM JNITabletjnilib.m


If you're compiling a .m file, you'll probably want to add -framework  
AppKit in there.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Updating a progress bar from a code loop

2008-06-10 Thread j o a r


On Jun 9, 2008, at 11:24 PM, Graham Cox wrote:

I have a lengthy routine that I'd like to show a progress bar for.  
The routine runs in a while() loop, and calls a delegate which  
implements the progress update. My progress window opens OK but  
nothing gets updated, though I know that it's getting the correct  
values set.


I'm assuming the problem is that because I'm not running the event  
loop at this point, updates aren't getting processed. Makes sense I  
think.


How do I give some time to the event loop while I'm running my own  
loop? I tried:


	[[NSRunLoop currentRunLoop] runMode:NSRunLoopCommonModes beforeDate: 
[NSDate distantFuture]];


but it didn't fix the problem. Note that I've tried running my  
window both modally and non-modally but it's the same either way.


What should I be doing?



See if you can make your lengthy routine thread safe, and if so, run  
it on a background thread.
You should put a lot of effort into always leaving the main thread  
open for user events.


j o a r


___

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: Updating a progress bar from a code loop

2008-06-10 Thread Hamish Allan
On Tue, Jun 10, 2008 at 7:24 AM, Graham Cox [EMAIL PROTECTED] wrote:

 How do I give some time to the event loop while I'm running my own loop?

See here for a recent discussion:

http://www.cocoabuilder.com/archive/message/cocoa/2008/6/5/209308

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]


Spotlight sources w/o actual files?

2008-06-10 Thread Rasmus Andersson
I would like to create a Spotlight plugin that allows me to search
among a very big set of data, located at a central server (i.e. not
able to store it locally) Thus I need to query this central storage
for matches whenever I search for something in Spotlight. (I/O latency
is not an issue)

What I have understood from reading Spotlight Importer Programming
Guide[1], there is no way to actually hook yourself in to when a user
is performing a query, or even to register a custom data source which
might be backed by for example network resources.

The alternative is of course Quicksilver, but as QS is no longer
maintained and the fact Spotlight is working OK in 10.5 makes me
prefer Spotlight.

Anyone got any clues on how to solve this?


Example scenario:
Typing in generate into Spotlight will query an online dictionary
about the word generate and, like the built-in dictionary, display a
short description and when clicked opening the appropriate URL in a
web browser.

By the way, Hi everyone! (I left this list a few years ago but now I'm back)


[1] http://developer.apple.com/documentation/Carbon/Conceptual/MDImporters/

-- 
Rasmus Andersson
___

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]


extracting output from AMWorkflow when using AMWorkflowController

2008-06-10 Thread Mark Munz
It appears that it is only possible to access the output of an
AMWorkflow if you call runWorkflowAtURL:withInput:error:.

If, as an alternative, I wanted to use AMWorkflowController, there
doesn't appear to be a way to extract the output from the AMWorkflow
after calling run from the controller.

Or am I missing something obvious?

-- 
Mark Munz
unmarked software
http://www.unmarked.com/
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Spotlight sources w/o actual files?

2008-06-10 Thread Ken Ferry
Hi Rasmus,

You do need to have one file per findable item, and you cannot get a
callback at search time.  You may not care about latency at search
time, but Apple does. :-)

If it helps at all, your files don't actually have to contain the data
that you supply to the spotlight indexer.  They can be empty tokens
that just tell you what query to perform against your central server.

-Ken

On Tue, Jun 10, 2008 at 1:07 AM, Rasmus Andersson [EMAIL PROTECTED] wrote:
 I would like to create a Spotlight plugin that allows me to search
 among a very big set of data, located at a central server (i.e. not
 able to store it locally) Thus I need to query this central storage
 for matches whenever I search for something in Spotlight. (I/O latency
 is not an issue)

 What I have understood from reading Spotlight Importer Programming
 Guide[1], there is no way to actually hook yourself in to when a user
 is performing a query, or even to register a custom data source which
 might be backed by for example network resources.

 The alternative is of course Quicksilver, but as QS is no longer
 maintained and the fact Spotlight is working OK in 10.5 makes me
 prefer Spotlight.

 Anyone got any clues on how to solve this?


 Example scenario:
 Typing in generate into Spotlight will query an online dictionary
 about the word generate and, like the built-in dictionary, display a
 short description and when clicked opening the appropriate URL in a
 web browser.

 By the way, Hi everyone! (I left this list a few years ago but now I'm back)


 [1] http://developer.apple.com/documentation/Carbon/Conceptual/MDImporters/

 --
 Rasmus Andersson
 ___

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

This email sent to [EMAIL PROTECTED]


Re: Spotlight sources w/o actual files?

2008-06-10 Thread Rasmus Andersson
Oh, just as I feared. The problem is the metadata itself is probably
hundreds of gigabytes, if not terabytes in size, so it would be
impossible to have mdimporter index fake files.

Thank you anyway! Will probably look into Quicksilver then.

Anyone got any good hints about where to find proper documentation on
how to create such a QSPlugin?

Thanks!

On Tue, Jun 10, 2008 at 10:38 AM, Ken Ferry [EMAIL PROTECTED] wrote:
 Hi Rasmus,

 You do need to have one file per findable item, and you cannot get a
 callback at search time.  You may not care about latency at search
 time, but Apple does. :-)

 If it helps at all, your files don't actually have to contain the data
 that you supply to the spotlight indexer.  They can be empty tokens
 that just tell you what query to perform against your central server.

 -Ken

 On Tue, Jun 10, 2008 at 1:07 AM, Rasmus Andersson [EMAIL PROTECTED] wrote:
 I would like to create a Spotlight plugin that allows me to search
 among a very big set of data, located at a central server (i.e. not
 able to store it locally) Thus I need to query this central storage
 for matches whenever I search for something in Spotlight. (I/O latency
 is not an issue)

 What I have understood from reading Spotlight Importer Programming
 Guide[1], there is no way to actually hook yourself in to when a user
 is performing a query, or even to register a custom data source which
 might be backed by for example network resources.

 The alternative is of course Quicksilver, but as QS is no longer
 maintained and the fact Spotlight is working OK in 10.5 makes me
 prefer Spotlight.

 Anyone got any clues on how to solve this?


 Example scenario:
 Typing in generate into Spotlight will query an online dictionary
 about the word generate and, like the built-in dictionary, display a
 short description and when clicked opening the appropriate URL in a
 web browser.

 By the way, Hi everyone! (I left this list a few years ago but now I'm back)


 [1] http://developer.apple.com/documentation/Carbon/Conceptual/MDImporters/

 --
 Rasmus Andersson
 ___

 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/kenferry%40gmail.com

 This email sent to [EMAIL PROTECTED]





-- 
Rasmus Andersson
___

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]


failure to create NSStatusItem

2008-06-10 Thread Ben Willmore
Under what circumstances can [[NSStatusBar systemStatusBar]
statusItemWithLength:NSSquareStatusItemLength] fail?

The docs say statusItemWithLength: can return nil if it was not
possible to create the NSStatusItem, but what might cause this to
happen?

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: App hangs when displaying any sheet in 10.5 [SOLVED]

2008-06-10 Thread Michael Vannorsdel
Ah ok.  I was bit by something similar a few years ago.  I had  
forgotten to put the prototype in my class interface and believed the  
compiler was using a prototype from an unrelated class which had  
different arg and return types.  But the twist was the missing  
prototype caused the default id return and '...' arg types to be used  
(determined through asm studying).  The presence of the other class's  
prototype was just suppressing the usual 'may not respond to selector'  
warning.


As far as trashing memory it was very likely trashing a floating point  
register your calling code was using and eventually using the trashed  
value for calculations and/or storing it to memory.  For instance on  
i386 it might have had a float the calling code was using in fp0 and  
expecting the return value of your called method to come back on EAX,  
therefore believing fp0 would stay unchanged.  But the called method  
was writing its return in fp0 (destroying the original value) and the  
calling code was casting whatever junk was in EAX to your float.   
Actual register names might differ but the effect is the same.



On Jun 8, 2008, at 6:29 AM, Graham Cox wrote:

No, this is not it. The method definitely did have a prototype - in  
fact it had *two*, differing only in return type. Judging by the  
assembler code, it used the one returning an int (actually an enum)  
not a float. It's still unclear why this generated code that trashed  
memory, but it did. It also did silently cast the result as well,  
which is perhaps why no warning was issued, because in some cases  
that's the desired behaviour.


___

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]


Where are window prefs stored?

2008-06-10 Thread Ken Tozier

Hi

My app opens several palettes and uses the following line to store  
the palette positions


[[self window] setFrameAutosaveName: @palette name here];

I ran into a problem with the stored size and want to flush the old  
prefs and start over. Where are these types of prefs located and is  
it safe to just zap them?


Thanks in advance

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: Where are window prefs stored?

2008-06-10 Thread Matt Gough

 10 Jun 2008, at 11:21, Ken Tozier wrote:


Hi

My app opens several palettes and uses the following line to store  
the palette positions


[[self window] setFrameAutosaveName: @palette name here];

I ran into a problem with the stored size and want to flush the old  
prefs and start over. Where are these types of prefs located and is  
it safe to just zap them?




Your prefs file will be in ~/Library/Preferences/YOUR BUNDLE ID.plist.

The window frame prefs are stored in the NSWindow Frame palette name  
here item.


It should be safe to either delete the entire prefs file or just the  
individual item.


If this is an already released product, it might be nicer to just  
rename your autosaveName to : e.g palette name V2. That way if  
they run your old version, the old pref will still be valid for the  
version of the palette in the original key.


Dont worry about filling up your prefs with obsolete keys, its not a  
major drain on resources.


Mat
___

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]


from CFDataRef to NSString

2008-06-10 Thread Angelo Chen
Hi,

What is the correct way to cast from CFDataRef to NSString, I have this code:

CFDataRef data;
NSString *messageString = [NSString stringWithCString:CFDataGetBytePtr(data)]; 

it always return this warning, any idea?

warning:pointer targets in passing argument 1 of 'stringWithCString:' differ in 
signedness

Thanks




  Yahoo! Mail具備一流的網上安全保護功能,請前往 http://hk.antispam.yahoo.com/ 了解更多相關資訊!
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: from CFDataRef to NSString

2008-06-10 Thread Michael Vannorsdel

Something like:

messageString = [[NSString alloc] initWithData:(NSData*)data  
encoding:NSASCIIStringEncoding];


the encoding type will depend on what encoding you expect the data to  
be in.



On Jun 10, 2008, at 4:08 AM, Angelo Chen wrote:

What is the correct way to cast from CFDataRef to NSString, I have  
this code:


CFDataRef data;
NSString *messageString = [NSString  
stringWithCString:CFDataGetBytePtr(data)];


it always return this warning, any idea?

warning:pointer targets in passing argument 1 of  
'stringWithCString:' differ in signedness


Thanks


___

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]


checking application is document based application or not

2008-06-10 Thread Apparao Mulpuri
Hi List,

  I have applicaton name, path, pid. I want to find out, whether that
application is document based application or not?.

  Is there any way to do this?

Regards,
- Apparao.
___

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]


warning: return makes pointer from integer without cast

2008-06-10 Thread Steven Hamilton

Hi folks, newbie here.

A quickie query on a warning.

Both returns in the following code give a 'warning: return makes  
pointer from integer without cast'


- (id)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem: 
(id)item

{
if (!item) {
return [outlineTree count];
}
return [[outlineTree objectForKey:item] count];

I can't work out why. count returns an integer which I should be  
able to return or does the return only send back a pointer to the  
integer of which I should be casting earlier on?

___

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: warning: return makes pointer from integer without cast

2008-06-10 Thread John Pannell

Hi Steven-

Your method signature says the method returns an object (id), but  
your return values you give back are int.  I think that may be where  
your code is making a pointer from an int without a cast.


I'm guessing you are implementing this as an outlineView datasource...  
in this case, the correct method signature is returning an int.


Hope this helps!

John

John Pannell
http://www.positivespinmedia.com

On Jun 10, 2008, at 6:32 AM, Steven Hamilton wrote:


Hi folks, newbie here.

A quickie query on a warning.

Both returns in the following code give a 'warning: return makes  
pointer from integer without cast'


- (id)outlineView:(NSOutlineView *)outlineView  
numberOfChildrenOfItem:(id)item

{
if (!item) {
return [outlineTree count];
}
return [[outlineTree objectForKey:item] count];

I can't work out why. count returns an integer which I should be  
able to return or does the return only send back a pointer to the  
integer of which I should be casting earlier on?

___

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: warning: return makes pointer from integer without cast

2008-06-10 Thread Jonathan del Strother
On Tue, Jun 10, 2008 at 1:32 PM, Steven Hamilton [EMAIL PROTECTED] wrote:
 Hi folks, newbie here.

 A quickie query on a warning.

 Both returns in the following code give a 'warning: return makes pointer
 from integer without cast'

 - (id)outlineView:(NSOutlineView *)outlineView
 numberOfChildrenOfItem:(id)item
 {
if (!item) {
return [outlineTree count];
}
return [[outlineTree objectForKey:item] count];

 I can't work out why. count returns an integer which I should be able to
 return or does the return only send back a pointer to the integer of which I
 should be casting earlier on?


Your method declaration is wrong - outlineView:numberOfChildrenOfItem:
returns an NSInteger, not an id.
id is a pointer, hence the warning.
___

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: warning: return makes pointer from integer without cast

2008-06-10 Thread Jason Coco

Hey Steve,

In this case, you are returning a regular integer (count returns just  
a regular, scalar type). But you've declared your return value as id,  
which is a typedef for a type of pointer. You either have to return an  
actual integer, or wrap the return of count in an object like NSNumber.


/jason

On Jun 10, 2008, at 08:32 , Steven Hamilton wrote:


Hi folks, newbie here.

A quickie query on a warning.

Both returns in the following code give a 'warning: return makes  
pointer from integer without cast'


- (id)outlineView:(NSOutlineView *)outlineView  
numberOfChildrenOfItem:(id)item

{
if (!item) {
return [outlineTree count];
}
return [[outlineTree objectForKey:item] count];

I can't work out why. count returns an integer which I should be  
able to return or does the return only send back a pointer to the  
integer of which I should be casting earlier on?

___

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

This email sent to [EMAIL PROTECTED]


adding a delegate to a class

2008-06-10 Thread Angelo Chen
Hi,

I have a code like this:

@interface BackgroundObj : NSObject
{
Controller *mc;
}

- (void) sayHi;


@implementation BackgroundObj

- (void) sayHi
{
[mc showText:@Hi];
}
@end

As you can see, the code is hard coded to use class Controller, can not be used 
with any other object, I'd like to add a delegate which will have a showText 
method, sayHi method will just call the delegate instead of hard coded 
Controller, any idea how to add delegates to this object? or, any tutorials for 
this? Thanks,

Angelo




  Yahoo! Mail具備一流的網上安全保護功能,請前往 http://hk.antispam.yahoo.com/ 了解更多相關資訊!
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


RE: adding a delegate to a class

2008-06-10 Thread john darnell
Without knowing what exactly you are trying to achieve, it's hard to advise 
you, Angelo.  Would a simple printf or one of its variants do for you?

R,
John

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On
 Behalf Of Angelo Chen
 Sent: Tuesday, June 10, 2008 8:11 AM
 To: cocoa-dev@lists.apple.com
 Subject: adding a delegate to a class
 
 Hi,
 
 I have a code like this:
 
 @interface BackgroundObj : NSObject
 {
   Controller *mc;
 }
 
 - (void) sayHi;
 
 
 @implementation BackgroundObj
 
 - (void) sayHi
 {
   [mc showText:@Hi];
 }
 @end
 
 As you can see, the code is hard coded to use class Controller, can not be
 used with any other object, I'd like to add a delegate which will have a
 showText method, sayHi method will just call the delegate instead of hard
 coded Controller, any idea how to add delegates to this object? or, any
 tutorials for this? Thanks,
 
 Angelo
 
 
 
 
   Yahoo! Mail具備一流的網上安全保護功能,請前往 http://hk.antispam.yahoo.com/ 了解更多相關資訊!
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-
 dev/john.darnell%40walsworth.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: adding a delegate to a class

2008-06-10 Thread Jesse Armand
Hello Angelo,

I think this code might help you:

@protocol BackgroundObjDelegate NSObject
@optional

- (void)showText:(NSString*)text;

@end

@interface BackgroundObj : NSObject
{
   idBackgroundObjDelegate _delegate;
}

@property(assign) idBackgroundObjDelegate delegate

- (void) sayHi;

@end

@implementation BackgroundObj

@synthesize delegate=_delegate;

- (void) sayHi
{
   if ([_delegate respondsToSelector:@selector(showText:)])
   [_delegate showText:@Hi];
}

@end

Then, you could implement your delegate class, for example:

@interface ForegroundObj : NSObject BackgroundObjDelegate
{
 // Insert your instance variables
}

- (void)showText:(NSString*)text;

@end

@implementation ForegroundObj

- (id)init
{
if (![super init])
 return nil;

BackgroundObj *obj = [[BackgroundObj alloc] init];
obj.delegate = self;// set the background object delegate

return self;
}

- (void)showText:(NSString*)text
{
// Insert your code
}

@end

If you have any questions, just ask, and please read Apple Docs, since
it's already quite complete in explaining these.

Regards,

Jesse
-
barablu (www.barablu.com), iPhone developer (http://jessearm.blogspot.com)

2008/6/10 Angelo Chen [EMAIL PROTECTED]:
 Hi,

 I have a code like this:

 @interface BackgroundObj : NSObject
 {
Controller *mc;
 }

 - (void) sayHi;


 @implementation BackgroundObj

 - (void) sayHi
 {
[mc showText:@Hi];
 }
 @end

 As you can see, the code is hard coded to use class Controller, can not be 
 used with any other object, I'd like to add a delegate which will have a 
 showText method, sayHi method will just call the delegate instead of hard 
 coded Controller, any idea how to add delegates to this object? or, any 
 tutorials for this? Thanks,

 Angelo




  Yahoo! Mail具備一流的網上安全保護功能,請前往 http://hk.antispam.yahoo.com/ 了解更多相關資訊!
 ___

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

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/mnemonic.fx%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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Spotlight sources w/o actual files?

2008-06-10 Thread Stephen J. Butler
On Tue, Jun 10, 2008 at 3:07 AM, Rasmus Andersson [EMAIL PROTECTED] wrote:
 I would like to create a Spotlight plugin that allows me to search
 among a very big set of data, located at a central server (i.e. not
 able to store it locally) Thus I need to query this central storage
 for matches whenever I search for something in Spotlight. (I/O latency
 is not an issue)

 What I have understood from reading Spotlight Importer Programming
 Guide[1], there is no way to actually hook yourself in to when a user
 is performing a query, or even to register a custom data source which
 might be backed by for example network resources.

You could use MacFUSE to write a filesystem that exposes your server
data as files:

http://code.google.com/p/macfuse/

However, it appears people are having some problem getting Spotlight
to index such volumes:

http://groups.google.com/group/macfuse-devel/browse_thread/thread/6a3e71e1f8bb1652
___

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: adding a delegate to a class

2008-06-10 Thread Erik Buck
See 
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-10 Thread Chris Ridd


On 10 Jun 2008, at 05:12, Mark Munz wrote:


Just wishing for the problem to go away or blaming external criteria
will almost guarantee that nothing gets done. Filing bugs is how you,
the developer, communicate your needs to Apple.


Since ICU is open source, the other productive thing to do would be to  
give the ICU folks a hand at writing whatever bits of gunk are  
required by Apple.


Cheers,

Chris
___

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: Spotlight sources w/o actual files?

2008-06-10 Thread Rasmus Andersson
Thanks!

That might work, but would add some awkward dependencies (i.e. the
fusefs kernel module)
Will investigate further.

On Tue, Jun 10, 2008 at 4:00 PM, Stephen J. Butler
[EMAIL PROTECTED] wrote:
 On Tue, Jun 10, 2008 at 3:07 AM, Rasmus Andersson [EMAIL PROTECTED] wrote:
 I would like to create a Spotlight plugin that allows me to search
 among a very big set of data, located at a central server (i.e. not
 able to store it locally) Thus I need to query this central storage
 for matches whenever I search for something in Spotlight. (I/O latency
 is not an issue)

 What I have understood from reading Spotlight Importer Programming
 Guide[1], there is no way to actually hook yourself in to when a user
 is performing a query, or even to register a custom data source which
 might be backed by for example network resources.

 You could use MacFUSE to write a filesystem that exposes your server
 data as files:

 http://code.google.com/p/macfuse/

 However, it appears people are having some problem getting Spotlight
 to index such volumes:

 http://groups.google.com/group/macfuse-devel/browse_thread/thread/6a3e71e1f8bb1652




-- 
Rasmus Andersson
___

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: Spotlight sources w/o actual files?

2008-06-10 Thread matt . gough


On 10 Jun 2008, at 10:57, Rasmus Andersson wrote:


Oh, just as I feared. The problem is the metadata itself is probably
hundreds of gigabytes, if not terabytes in size, so it would be
impossible to have mdimporter index fake files.



One thing you could consider is to just create these fake files for  
items in the database that the user actually visits. At least that way  
they can do a spotlight search for something they remember visiting  
before. Similar in style to what happens with web sites you have  
visited in Safari. There is an index file for each of the items in  
Safari's history.


Matt Gough
___

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]


Building against 10.5 SDK, link error on open

2008-06-10 Thread Dale Jensen
I'm trying to get my project to build against the 10.5 SDK, but when I  
switch it from $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk to 10.5, I get a  
couple of errors:


Undefined symbols:
  _open$UNIX2003, referenced from:
  _CreateEventForPath in editorBridge.o
  _close$UNIX2003, referenced from:
  _SimplePing in SimplePing.o
  _CreateSocketForCommunicationWithHost in SimplePing.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

SimplePing.o is from the Apple provided example.  editorBridge is  
mine, an implementation of kQueue, which uses the open found in  
fcntl.h


I don't know enough about UNIX flavoured C to figure out what settings  
I might need to change to solve the link error.  Suggestions?  Thanks!



dale

___

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: crash on command-W

2008-06-10 Thread Adam R. Maxwell

On Jun 9, 2008, at 11:17 PM, James W. Walker wrote:


On Jun 9, 2008, at 10:44 PM, Joseph Kelly wrote:

Toggle the release when closed setting on the window nib? See the  
docs for -[NSWindow setReleasedWhenClosed:]


Tried that, didn't seem to make any difference to the crash.  (Right  
now I have it off, and with the controller autorelease fix, I  
verified with Instruments that windows aren't leaking.)


I don't think that checkbox has any effect when your window is managed  
by an NSWindowController.  See Window Closing Behavior here


http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Concepts/UsingWindowController.html


On Jun 9, 2008, at 10:30 PM, James W. Walker wrote:



On Jun 9, 2008, at 9:18 PM, Andrew Farmer wrote:


On 09 Jun 08, at 21:03, James W. Walker wrote:



OK, I turned on NSZombieEnabled, and now I get this in the log:

*** -[LogController tableView:objectValueForTableColumn:row:]:  
message sent to deallocated instance


That means that the LogController itself has been deallocated, not  
some member that the method uses, right?  All this tells me is  
that somebody is trying to draw the table after the controller has  
been released and the window has been hidden if not released.  I  
pretty much knew that already.


In your windowWillClose method, set the tableview datasource and  
delegate to nil, so it stops messaging your controller.  This is a  
good habit to get into with datasource/delegate objects.


--
adam
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Binding NSMenuItem state in Document-based app

2008-06-10 Thread Steve Nicholson


On 2008 Jun, 09, at 12:57, Quincey Morris wrote:



Doing this through bindings involves re-inventing a bit of stuff that  
NSResponder normally takes care of, but it need not be too difficult.  
For example, you could


Or something like that.

On Jun 9, 2008, at 3:04 PM, Jerry Krinock wrote:


Well, last year sometime I wanted to bind some menu items to values  
in the current document, as I believe you're trying to do.  You can  
read of my saga in the list archives.


After you've considered Quincy's response, recall that bindings is an  
alternative which is supposed to make things simpler and reduce  
labor.  I concluded that the bindings alternative does not fulfill  
its purpose when it involves menu items.   Target/Action still works.


Thanks, Jerry  Quincey. You've saved me from banging my head against  
the wall for half a day. I used Target/Action and -menuNeedsUpdate:  
and my menus are working perfectly with minimal effort.


-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: Building against 10.5 SDK, link error on open

2008-06-10 Thread Kevin Grant

It's possible the SDK has a problem, but first double-check
everything you're using (and everything it depends on) to be
sure it's built with consistent headers and libraries.  If
it's C++, the compiler version is also important.

You may have to examine the list of environment variables
printed at build time, and the GCC command lines, to see the
problem.  For example, the -isysroot option may not be set
correctly.

Another test would be to disable the SDK temporarily and
build against Leopard itself, just to see if the results are
the same.

Kevin G.


I'm trying to get my project to build against the 10.5 SDK, but when  
I switch it from $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk to 10.5, I get  
a couple of errors:


Undefined symbols:
 _open$UNIX2003, referenced from:
 _CreateEventForPath in editorBridge.o
 _close$UNIX2003, referenced from:
 _SimplePing in SimplePing.o
 _CreateSocketForCommunicationWithHost in SimplePing.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

SimplePing.o is from the Apple provided example.  editorBridge is  
mine, an implementation of kQueue, which uses the open found in  
fcntl.h


I don't know enough about UNIX flavoured C to figure out what  
settings I might need to change to solve the link error.   
Suggestions?  Thanks!



dale

___

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: Spotlight sources w/o actual files?

2008-06-10 Thread Rasmus Andersson
This is actually something I'm thinking of implementing. But still, it
would only be semi-useful, since the service I intend to interface
with is in many parts search-oriented. (Spotify, a music service)

Maybe I will fork this little project into two separate, small projects:
1) Spotlight importer for indexing objects previously seen by the user.
2) Fuse file system, for interfacing with the (Spotify) world.

On Tue, Jun 10, 2008 at 4:33 PM,  [EMAIL PROTECTED] wrote:

 On 10 Jun 2008, at 10:57, Rasmus Andersson wrote:

 Oh, just as I feared. The problem is the metadata itself is probably
 hundreds of gigabytes, if not terabytes in size, so it would be
 impossible to have mdimporter index fake files.


 One thing you could consider is to just create these fake files for items in
 the database that the user actually visits. At least that way they can do a
 spotlight search for something they remember visiting before. Similar in
 style to what happens with web sites you have visited in Safari. There is an
 index file for each of the items in Safari's history.

 Matt Gough




-- 
Rasmus Andersson
___

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]


changing locale

2008-06-10 Thread Alexander Cohen
Is there a way to change the locale from cocoa as if i was to go into  
System Preferences and change the language then the format?


thx

AC
___

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: Garbage collector vs variable lifetime

2008-06-10 Thread Charles Srstka

On Jun 9, 2008, at 1:39 PM, Chris Hanson wrote:

It is perfectly legal to return an NSMutableArray from a  
hypothetical +(NSArray *)array method.


However, all the sender of that +(NSArray *)array message can know  
is that the result can be treated as an NSArray.  It can't know  
whether an NSArray or NSMutableArray is returned (unless it does  
extra work, like using -isKindOfClass:, which also happens to be  
fragile).


Even isKindOfClass: won't work in this case, because NSArray and  
NSMutableArray both usually end up being the same class, NSCFArray.  
This class seems to be a subclass of NSMutableArray, and using  
isKindOfClass: on it will always return YES for NSMutableArray, even  
if it's not actually mutable.


I don't really know of any way to actually test whether an NSArray is  
mutable or not programatically (well, I suppose you could try mutating  
it and see if you catch an exception or not, but that's obviously not  
a very good solution).


Charles
___

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: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-10 Thread Jens Alfke


On 9 Jun '08, at 10:38 PM, Michael Ash wrote:


It's perfectly possible to write safe code that calls C
str functions. My code is no more vulnerable than the next man's. You
can call things like strnstr, pass the length of the NSData you're
working on, and there is exactly zero risk of anything.


Sure, and it's perfectly possible to shave with a blade without  
cutting yourself; that doesn't mean it doesn't happen, though :/ What  
you're saying is if you do everything right, there's zero risk of it  
being wrong, which is a tautology. The point is that people can and  
do make mistakes when working with C string APIs (even the n ones).



No, it's not. A common technique is to use C string APIs to find line
endings, then try the full line as UTF-8. If it fails, then you can
fall back on a more forgiving encoding.


Yes, I do try UTF-8 first. Sorry, I was being brief in the previous  
message, describing only the _fallback_ if UTF-8 parsing fails.


I'm not sure why you would want to use C APIs to look for line endings  
first, though?


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Building against 10.5 SDK, link error on open

2008-06-10 Thread Dale Jensen

On Jun 10, 2008, at 10:04 AM, Kevin Grant wrote:


You may have to examine the list of environment variables
printed at build time, and the GCC command lines, to see the
problem.  For example, the -isysroot option may not be set
correctly.


I've attached the command lines at the end of this.  It looks okay to  
me, but I'm not very familiar with what options should be set.



Another test would be to disable the SDK temporarily and
build against Leopard itself, just to see if the results are
the same.


Nope, same result.

Here's the build strings:

CompileC build/ebrowser.build/Debug/Elements SBM Debug.build/Objects- 
normal/i386/editorBridge.o /Users/dalej/Documents/ebrowser/ 
editorBridge.m normal i386 objective-c com.apple.compilers.gcc.4_0

cd /Users/dalej/Documents/ebrowser
/Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno- 
trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused- 
variable -fmessage-length=0 -mfix-and-continue -gdwarf-2 -I/Users/ 
dalej/Documents/ebrowser/build/ebrowser.build/Debug/Elements SBM  
Debug.build/Elements SBM Debug.hmap -F/Users/dalej/Documents/ebrowser/ 
build/Debug -F/Users/dalej/Documents/ebrowser -F/Users/dalej/Documents/ 
ebrowser -F/Users/dalej/Documents/ebrowser -I/Users/dalej/Documents/ 
ebrowser/build/Debug/include -I/Users/dalej/Documents/ebrowser/build/ 
ebrowser.build/Debug/Elements SBM Debug.build/DerivedSources - 
include /Users/dalej/Documents/ebrowser/ebrowser_debug_Prefix.pch -c / 
Users/dalej/Documents/ebrowser/editorBridge.m -o /Users/dalej/ 
Documents/ebrowser/build/ebrowser.build/Debug/Elements SBM Debug.build/ 
Objects-normal/i386/editorBridge.o


Ld /Users/dalej/Documents/ebrowser/build/Debug/Elements SBM Debug.app/ 
Contents/MacOS/Elements SBM Debug normal i386

cd /Users/dalej/Documents/ebrowser
/Developer/usr/bin/gcc-4.0 -o /Users/dalej/Documents/ebrowser/ 
build/Debug/Elements SBM Debug.app/Contents/MacOS/Elements SBM Debug - 
L/Users/dalej/Documents/ebrowser/build/Debug -L/Developer/SDKs/ 
MacOSX10.4u.sdk/usr/lib -F/Users/dalej/Documents/ebrowser/build/Debug - 
F/Users/dalej/Documents/ebrowser -F/Users/dalej/Documents/ebrowser -F/ 
Users/dalej/Documents/ebrowser -filelist /Users/dalej/Documents/ 
ebrowser/build/ebrowser.build/Debug/Elements SBM Debug.build/Objects- 
normal/i386/Elements SBM Debug.LinkFileList -framework Cocoa - 
framework WebKit -framework Security -framework SecurityFoundation - 
framework SecurityInterface -framework InstantMessage -framework  
AddressBook -framework SyncServices -framework CoreServices -lcrypto - 
framework DotMacKit -framework Quartz -framework Carbon -framework  
CalendarStore -arch i386 -prebind -lz

Undefined symbols:
  _open$UNIX2003, referenced from:
  _CreateEventForPath in editorBridge.o
  _read$UNIX2003, referenced from:
  _CreateEventForPath in editorBridge.o
  _close$UNIX2003, referenced from:
  _SimplePing in SimplePing.o
  _CreateSocketForCommunicationWithHost in SimplePing.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

___

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: checking application is document based application or not

2008-06-10 Thread Jens Alfke


On 10 Jun '08, at 5:07 AM, Apparao Mulpuri wrote:


 I have applicaton name, path, pid. I want to find out, whether that
application is document based application or not?.


There isn't really any distinction. Document based application is  
just the name of a project template in Xcode that sets up certain  
configuration for you.


What is it you really want to know? Whether the app can open a  
particular file? LaunchServices will tell you that.


—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: Garbage collector vs variable lifetime

2008-06-10 Thread Charles Srstka

On Jun 9, 2008, at 5:55 PM, Hamish Allan wrote:


Sure. But it gives you *more* information than if it just returns
id. I agree with you in all other respects of your post, but I don't
agree that +[NSArray array] returns id because if it returned
NSArray * you'd have to have a separate declaration for
+[NSMutableArray array]. Indeed, that line of reasoning leads to
John's way of thinking: that if you return something more specific
than id, it is in some sense indicative that the returned object is
more likely to be of a specific class, rather than a subclass thereof.


I think the problem is that if NSArray has +[NSArray array] returning  
an NSArray, then NSMutableArray has to return an NSArray also, since  
it can't have a different method signature for the same method. As a  
result, if you called +[NSMutableArray array], the compiler would  
think you were getting a regular, non-mutable NSArray, and you'd get a  
warning if you tried to do this, although the code would still work:


NSMutableArray *array = [NSMutableArray array];

The only way to get the compiler warnings to shut up would be to cast  
it. If the methods return id, then the compiler just assumes you're  
doing the right thing (which also means you can do stupid things like  
assign +[NSMutableArray array] to an NSString or something which would  
of course end up blowing up before too long, so it's not perfect  
either, but it's certainly less annoying than having to typecast every  
assignment of a newly-initialized NSMutableArray).


Charles
___

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: Building against 10.5 SDK, link error on open

2008-06-10 Thread Kevin Grant

You do have -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib in there.
Check the list of environment variables (or add a script build phase
that runs env first, if you don't see one) and try to fix the most
generic variable that will affect all the others.

Another thing to look at is the precompiled header (.pch).  If that
wasn't regenerated, it could contain references to older stuff.

Kevin G.



You may have to examine the list of environment variables
printed at build time, and the GCC command lines, to see the
problem.  For example, the -isysroot option may not be set
correctly.


I've attached the command lines at the end of this.  It looks okay  
to me, but I'm not very familiar with what options should be set.



Another test would be to disable the SDK temporarily and
build against Leopard itself, just to see if the results are
the same.


Nope, same result.

Here's the build strings:

CompileC build/ebrowser.build/Debug/Elements SBM Debug.build/ 
Objects-normal/i386/editorBridge.o /Users/dalej/Documents/ebrowser/ 
editorBridge.m normal i386 objective-c com.apple.compilers.gcc.4_0

   cd /Users/dalej/Documents/ebrowser
   /Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno- 
trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused- 
variable -fmessage-length=0 -mfix-and-continue -gdwarf-2 -I/Users/ 
dalej/Documents/ebrowser/build/ebrowser.build/Debug/Elements SBM  
Debug.build/Elements SBM Debug.hmap -F/Users/dalej/Documents/ 
ebrowser/build/Debug -F/Users/dalej/Documents/ebrowser -F/Users/ 
dalej/Documents/ebrowser -F/Users/dalej/Documents/ebrowser -I/Users/ 
dalej/Documents/ebrowser/build/Debug/include -I/Users/dalej/ 
Documents/ebrowser/build/ebrowser.build/Debug/Elements SBM  
Debug.build/DerivedSources -include /Users/dalej/Documents/ebrowser/ 
ebrowser_debug_Prefix.pch -c /Users/dalej/Documents/ebrowser/ 
editorBridge.m -o /Users/dalej/Documents/ebrowser/build/ 
ebrowser.build/Debug/Elements SBM Debug.build/Objects-normal/i386/ 
editorBridge.o


Ld /Users/dalej/Documents/ebrowser/build/Debug/Elements SBM  
Debug.app/Contents/MacOS/Elements SBM Debug normal i386

   cd /Users/dalej/Documents/ebrowser
   /Developer/usr/bin/gcc-4.0 -o /Users/dalej/Documents/ebrowser/ 
build/Debug/Elements SBM Debug.app/Contents/MacOS/Elements SBM  
Debug -L/Users/dalej/Documents/ebrowser/build/Debug -L/Developer/ 
SDKs/MacOSX10.4u.sdk/usr/lib -F/Users/dalej/Documents/ebrowser/build/ 
Debug -F/Users/dalej/Documents/ebrowser -F/Users/dalej/Documents/ 
ebrowser -F/Users/dalej/Documents/ebrowser -filelist /Users/dalej/ 
Documents/ebrowser/build/ebrowser.build/Debug/Elements SBM  
Debug.build/Objects-normal/i386/Elements SBM Debug.LinkFileList - 
framework Cocoa -framework WebKit -framework Security -framework  
SecurityFoundation -framework SecurityInterface -framework  
InstantMessage -framework AddressBook -framework SyncServices - 
framework CoreServices -lcrypto -framework DotMacKit -framework  
Quartz -framework Carbon -framework CalendarStore -arch i386 - 
prebind -lz

Undefined symbols:
 _open$UNIX2003, referenced from:
 _CreateEventForPath in editorBridge.o
 _read$UNIX2003, referenced from:
 _CreateEventForPath in editorBridge.o
 _close$UNIX2003, referenced from:
 _SimplePing in SimplePing.o
 _CreateSocketForCommunicationWithHost in SimplePing.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

___

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

This email sent to [EMAIL PROTECTED]



Kevin G.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Building against 10.5 SDK, link error on open

2008-06-10 Thread Julien Jalon
The basic POSIX functions have changed a bit in Leopard (to achieve POSIX
conformance). This means that POSIX libraries are different in 10.4 SDK vs.
10.5. You can not mix them. Also, if you change the SDK, it's generally a
good idea to clean all your targets.
-- 
Julien

On Tue, Jun 10, 2008 at 7:34 AM, Dale Jensen [EMAIL PROTECTED]
wrote:

 I'm trying to get my project to build against the 10.5 SDK, but when I
 switch it from $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk to 10.5, I get a couple
 of errors:

 Undefined symbols:
  _open$UNIX2003, referenced from:
  _CreateEventForPath in editorBridge.o
  _close$UNIX2003, referenced from:
  _SimplePing in SimplePing.o
  _CreateSocketForCommunicationWithHost in SimplePing.o
 ld: symbol(s) not found
 collect2: ld returned 1 exit status

 SimplePing.o is from the Apple provided example.  editorBridge is mine, an
 implementation of kQueue, which uses the open found in fcntl.h

 I don't know enough about UNIX flavoured C to figure out what settings I
 might need to change to solve the link error.  Suggestions?  Thanks!


 dale

 ___

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

This email sent to [EMAIL PROTECTED]


Re: Building against 10.5 SDK, link error on open

2008-06-10 Thread Dale Jensen

On Jun 10, 2008, at 10:33 AM, Kevin Grant wrote:


You do have -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib in there.
Check the list of environment variables (or add a script build phase
that runs env first, if you don't see one) and try to fix the most
generic variable that will affect all the others.


The only reference that I see is setenv LIBRARY_SEARCH_PATHS  / 
Developer/SDKs/MacOSX10.4u.sdk/usr/lib and I don't know where that's  
coming from, because Library Search Paths is blank for this and the  
other phases of the product.  What else should I be looking for?



Another thing to look at is the precompiled header (.pch).  If that
wasn't regenerated, it could contain references to older stuff.



I did do a Clean All, which is supposed to regenerate those, right?


dale

___

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]


NSSlider responding to superview's drawRect

2008-06-10 Thread Jonathan Dann

Hi All,

This is something that I haven't seen before. I have a custom view  
that inherits from NSView directly and just draws a gradient  
background. In IB I've placed an NSSlider on the view which works  
fine. The problem comes when drawRect in my custom view is invoked, I  
draw the gradient and a 1px line at the top of the view, but the line  
also gets draw just above the NSSlider! logging shows the following


1) resize window - drawRect is called and the line above the slider  
disappears
2) move slider - drawRect is called from my gradient view but with the  
frame of the slider. The line then appears.


Is this a known issue with NSSlider and a custom view or have I missed  
an idiosyncracy of NSControls.


Thanks in adavnce,

Jonathan
___

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: NSSlider responding to superview's drawRect

2008-06-10 Thread Andy Lee
Check the code that draws the 1-pixel line.  It should be calculating  
coordinates of the line based on the view's bounds rectangle, not the  
rectangle that is passed to drawRect:.


--Andy

On Jun 10, 2008, at 11:51 AM, Jonathan Dann wrote:


Hi All,

This is something that I haven't seen before. I have a custom view  
that inherits from NSView directly and just draws a gradient  
background. In IB I've placed an NSSlider on the view which works  
fine. The problem comes when drawRect in my custom view is invoked,  
I draw the gradient and a 1px line at the top of the view, but the  
line also gets draw just above the NSSlider! logging shows the  
following


1) resize window - drawRect is called and the line above the slider  
disappears
2) move slider - drawRect is called from my gradient view but with  
the frame of the slider. The line then appears.


Is this a known issue with NSSlider and a custom view or have I  
missed an idiosyncracy of NSControls.


Thanks in adavnce,

Jonathan

___

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: NSSlider responding to superview's drawRect

2008-06-10 Thread Ken Ferry

You're probably filling your gradient into the rect passed in drawRect.

That rectangle just represents the dirty part of your view. If you had  
a solid color to draw, you could just fill the rect, but with a  
gradient you will get your gradient, top to bottom, within this  
possibly small rect within your view.


Try drawing the gradient into [self bounds] instead.  This describes  
the location of the entire view in its own coordinate system.


-Ken

On Jun 10, 2008, at 8:51 AM, Jonathan Dann [EMAIL PROTECTED] wrote:


Hi All,

This is something that I haven't seen before. I have a custom view  
that inherits from NSView directly and just draws a gradient  
background. In IB I've placed an NSSlider on the view which works  
fine. The problem comes when drawRect in my custom view is invoked,  
I draw the gradient and a 1px line at the top of the view, but the  
line also gets draw just above the NSSlider! logging shows the  
following


1) resize window - drawRect is called and the line above the slider  
disappears
2) move slider - drawRect is called from my gradient view but with  
the frame of the slider. The line then appears.


Is this a known issue with NSSlider and a custom view or have I  
missed an idiosyncracy of NSControls.


Thanks in adavnce,

Jonathan
___

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

This email sent to [EMAIL PROTECTED]


Re: Garbage collector vs variable lifetime

2008-06-10 Thread Adam R. Maxwell
 
On Tuesday, June 10, 2008, at 08:29AM, Charles Srstka [EMAIL PROTECTED] 
wrote:
On Jun 9, 2008, at 5:55 PM, Hamish Allan wrote:

 Sure. But it gives you *more* information than if it just returns
 id. I agree with you in all other respects of your post, but I don't
 agree that +[NSArray array] returns id because if it returned
 NSArray * you'd have to have a separate declaration for
 +[NSMutableArray array]. Indeed, that line of reasoning leads to
 John's way of thinking: that if you return something more specific
 than id, it is in some sense indicative that the returned object is
 more likely to be of a specific class, rather than a subclass thereof.

I think the problem is that if NSArray has +[NSArray array] returning  
an NSArray, then NSMutableArray has to return an NSArray also, since  
it can't have a different method signature for the same method. As a  
result, if you called +[NSMutableArray array], the compiler would  
think you were getting a regular, non-mutable NSArray, and you'd get a  
warning if you tried to do this, although the code would still work:

I'm not sure if I follow you, but the trivial example below compiles with only 
one warning.  NSMutableArray could redeclare the superclass' implementation of 
+array, but that would have to be done for each factory method that presently 
returns an id, which is pretty annoying.  In addition, each successive subclass 
has to redeclare /and/ reimplement all of the factory methods.  Another 
example: if you subclass NSFontManager using setFontManagerFactory:, every time 
you call +sharedFontManager you have to cast to your subclass since it's 
strongly typed.

#import Foundation/Foundation.h

@interface Thing : NSObject
+ (Thing *)thing;
@end

@interface MutableThing : Thing
+ (MutableThing *)thing;
@end

@implementation Thing
+ (Thing *)thing { return [NSAllocateObject(self, 0, NULL) autorelease]; }
@end

@implementation MutableThing
+ (MutableThing *)thing { return [NSAllocateObject(self, 0, NULL) autorelease]; 
}
@end

int main (int argc, char const *argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];

Thing *a = [Thing thing];
a = [MutableThing thing];

MutableThing *b = [MutableThing thing];   

// warning: assignment from distinct Objective-C type
b = [Thing thing];

[pool release];
return 0;
} 

___

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]


Selectable NSTextFieldCell and NSTextField break attributed strings when selected

2008-06-10 Thread Dalzhim Dalzhim
Hello!
this is my first time posting on this mailing list so I hope I do not forget
to provide any necessary details!  I've been searching around for a long
while to fix this problem I am having and I have yet to find a solution or
an explanation.

I have a NSWindow with a few NSTextField instances and a few NSMatrix
instance containing various numbers of NSTextFieldCell instances.  None of
these NSTextField and NSTextFieldCell instances are Editable.  Only a subset
of them are Selectable.  The formatted content of my fields has been
programmaticaly entered using the setAttributedStringValue message and this
formatted content often contain more than one Font Family and Font Size in
the same NSAttributedString.

My problem is that when I select the content of those fields, the Attributed
Strings they contain lose their formating and the Font Family and Font Size
becomes unified.  How can I make sure the formatted content I have prepared
remains unchanged when I select it?


Thanks for your help!


-Dalzhim
___

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: 3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-10 Thread Michael Ash
On Tue, Jun 10, 2008 at 8:20 AM, Jens Alfke [EMAIL PROTECTED] wrote:

 On 9 Jun '08, at 10:38 PM, Michael Ash wrote:

 It's perfectly possible to write safe code that calls C
 str functions. My code is no more vulnerable than the next man's. You
 can call things like strnstr, pass the length of the NSData you're
 working on, and there is exactly zero risk of anything.

 Sure, and it's perfectly possible to shave with a blade without cutting
 yourself; that doesn't mean it doesn't happen, though :/ What you're saying
 is if you do everything right, there's zero risk of it being wrong, which
 is a tautology. The point is that people can and do make mistakes when
 working with C string APIs (even the n ones).

This is true but meaningless. People can and do make mistakes with
*everything*. The C string APIs don't have a particularly special
place as far as security vulnerabilities go.

 No, it's not. A common technique is to use C string APIs to find line
 endings, then try the full line as UTF-8. If it fails, then you can
 fall back on a more forgiving encoding.

 Yes, I do try UTF-8 first. Sorry, I was being brief in the previous message,
 describing only the _fallback_ if UTF-8 parsing fails.

 I'm not sure why you would want to use C APIs to look for line endings
 first, though?

When working with streaming data then you need to find a delimiter to
safely cut the stream before trying UTF-8, because if the end of your
chunk of data ends in the middle of a UTF-8 code word (or whatever
it's called), then the result will be invalid UTF-8 even if the stream
as a whole is valid UTF-8. You could write a UTF-8 parser to find good
cut points, but it's much easier when working with a line-oriented
protocol to just look for CRLF.

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: Updating a progress bar from a code loop

2008-06-10 Thread Michael Ash
On Tue, Jun 10, 2008 at 3:17 AM, Graham Cox [EMAIL PROTECTED] wrote:
 Thanks for the suggestions - basically I have to run my loop on a thread,
 seems to be what you're both saying.

 In this case I can do that... though out of curiosity I wonder if there is a
 way to do this cooperatively on the main thread without having to break up
 the loop doing the actual work. For example, in Carbon one can run the event
 loop for a short period or just for one event on each cycle of the loop -
 and this code can live in the progress dialog controller, so it works
 transparently with respect to the loop that drives the progress indicator.
 I'm not sure that approach is considered good in this day and age though I
 used it a lot on Mac OS 6/7/8/9. Just wondered if such an approach is
 feasible in Cocoa.

Take a look at -[NSApplication beginModalSessionForWindow:] and the
friends described in the docs for that method. This lets you start a
modal window, run it at intervals to keep events processing, then
close it when done. Of course this requires putting your progress bar
in a modal window, but if you're not going to allow the rest of the
program to run then this is a good idea anyway.

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: Updating a progress bar from a code loop

2008-06-10 Thread Quincey Morris


On Jun 10, 2008, at 03:17, Graham Cox wrote:

In this case I can do that... though out of curiosity I wonder if  
there is a way to do this cooperatively on the main thread without  
having to break up the loop doing the actual work. For example, in  
Carbon one can run the event loop for a short period or just for one  
event on each cycle of the loop - and this code can live in the  
progress dialog controller, so it works transparently with respect  
to the loop that drives the progress indicator. I'm not sure that  
approach is considered good in this day and age though I used it a  
lot on Mac OS 6/7/8/9. Just wondered if such an approach is feasible  
in Cocoa.


Well, FWIW, to refresh the display and enable Esc and clicks on a  
cancel button, what I've been using is:


- (BOOL) updateAndCheckIfCancelled {
NSEvent *event;
if (!progressCancelled)
		while (event = [NSApp nextEventMatchingMask:NSAnyEventMask  
untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES])

if (progressCancellable)
[NSApp sendEvent:event];
return progressCancelled;
}

called regularly through the loop, and it seems to work fine.

___

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: crash on command-W

2008-06-10 Thread Vijay Malhan
On Tue, Jun 10, 2008 at 7:54 PM, Adam R. Maxwell [EMAIL PROTECTED] wrote:

 On Jun 9, 2008, at 11:17 PM, James W. Walker wrote:

  On Jun 9, 2008, at 10:44 PM, Joseph Kelly wrote:

  Toggle the release when closed setting on the window nib? See the docs
 for -[NSWindow setReleasedWhenClosed:]


 Tried that, didn't seem to make any difference to the crash.  (Right now I
 have it off, and with the controller autorelease fix, I verified with
 Instruments that windows aren't leaking.)


 I don't think that checkbox has any effect when your window is managed by
 an NSWindowController.  See Window Closing Behavior here


 http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Concepts/UsingWindowController.html

  On Jun 9, 2008, at 10:30 PM, James W. Walker wrote:


 On Jun 9, 2008, at 9:18 PM, Andrew Farmer wrote:

  On 09 Jun 08, at 21:03, James W. Walker wrote:


  OK, I turned on NSZombieEnabled, and now I get this in the log:

 *** -[LogController tableView:objectValueForTableColumn:row:]: message
 sent to deallocated instance

 That means that the LogController itself has been deallocated, not some
 member that the method uses, right?  All this tells me is that somebody is
 trying to draw the table after the controller has been released and the
 window has been hidden if not released.  I pretty much knew that already.


 In your windowWillClose method, set the tableview datasource and delegate
 to nil, so it stops messaging your controller.  This is a good habit to get
 into with datasource/delegate objects.


Also, you can set the content-view of the window to nil [window
setContentView: nil]; It will ensure to release all the views- including
Table-View, before you send release to your window-controller.
- Vijay






 --
 adam

 ___

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

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/vijay.malhan%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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSSlider responding to superview's drawRect

2008-06-10 Thread Jonathan Dann


On 10 Jun 2008, at 17:05, Ken Ferry wrote:

You're probably filling your gradient into the rect passed in  
drawRect.


That rectangle just represents the dirty part of your view. If you  
had a solid color to draw, you could just fill the rect, but with a  
gradient you will get your gradient, top to bottom, within this  
possibly small rect within your view.


Try drawing the gradient into [self bounds] instead.  This describes  
the location of the entire view in its own coordinate system.



On 10 Jun 2008, at 17:03, Andy Lee wrote:
Check the code that draws the 1-pixel line.  It should be  
calculating coordinates of the line based on the view's bounds  
rectangle, not the rectangle that is passed to drawRect:.


--Andy


Thanks to you both, you're absolutely correct!  Works like a charm now.

I'd like to be able to change the fill of my view depending on whether  
the application is active or not.  The only problem is -drawRect isn't  
called when the application becomes inactive, is there a notification  
I can register for?  In all my NSControl subclassing -drawRect is  
called on both become active and deactivating.


Thanks again for your help, that subtlety has never come to light  
until now.


Jonathan

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]

Tooltip and 10.4.11. Bug?

2008-06-10 Thread Stephane Sudre
Is there  a known bug in Mac OS X 10.4.11 when it comes to tooltips  
attached to a NSTableView rows?


I'm seeing tool tips being cut off when the mouse is over a row and a  
medium length string should be displayed in the tool tip.



___

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]


Prevent Asynchronous operation of beginSheetModalForWindow

2008-06-10 Thread John Love
Before I begin, I want to assure you that I have researched entries here on
sheets, as well as those in MacTech.com.  It's reasonably probable that I
have missed some entries and so that is why I am asking for help.

I also realize that this description is very long and I *really* did try to
shorten it.

My app is a Cocoa Document based app.

I have chosen the title Prevent Asynchronous operation of
beginSheetModalForWindow because I use various calls to
beginSheetModalForWindow in many parts of my app code and in one case I need
the calls to didEndSelector to be completed *before* the code that follows
beginSheetModalForWindow is executed (see MyDocument.m below).

With Asynchronous operation, the sheet will show for a very brief moment and
continue as the Apple docs stipulate .. I want the sheet to stay down UNTIL
I click one of the buttons in the sheet.

MacTech names calls to beginSheetModalForWindow DocModalNew.

What have I tried to do, but without success:

*1)* After the call to [calculateSheet beginSheetModalForWindow:docWindow ..
etc]; within showCalculateSheet, I have used:

while (itsReturnCode == -1)  // the initialized value before the call to
beginSheetModalForWindow

What happens is a never-ending loop from which I need to force-quit.

*2)* Within shouldCloseFile I have called:

while ((theReturnCode = [theSheet getReturnCode]) == -1);  // same
never-ending loop results

The app's File's Owner is MyDocument

// inside my nib file I have a NSObject named FileController and
SheetController

// in MyDocument.h
#import Cocoa/Cocoa.h
#import FileController.h

@interface MyDocument:NSDocument {
IBOutlet FileController*theFile;
IBOutlet NSWindow   *documentWindow;  // passed to methods in
FileController.m
}

// signatures of various methods here
@end

// in MyDocument.m

if ([theFile shouldCloseFile]) {

// stuff that canNOT be executed until shouldCloseFile finishes

}

==

// in FileController.h

#import Cocoa/Cocoa.h
#import SheetController.h

@interface FileController:NSObject {
IBOutlet SheetController *theSheet;
NSWindow *itsWindow;
}
- (BOOL) shouldCloseFile;
// plus other signatures
@end

==

// in FileController.m

// itsWindow is quantified elsewhere in this .m listing by anoter call
within MyDocument.m

- (BOOL) shouldCloseFile {
int theReturnCode;
BOOL shouldClose = TRUE;

if (!itsFinishedCalculation) {
[theSheet showCalculateSheet:itsWindow];

// tried this, but had to force-quit
 // while ((theReturnCode = [theSheet getReturnCode]) == -1);
theReturnCode = [theSheet getReturnCode];

if (theReturnCode == NSAlertFirstButtonReturn) { //
Continue
shouldClose = FALSE;
}
else if (theReturnCode == NSAlertSecondButtonReturn) {   // Stop
and save
[self saveFile];
NSLog(@NSAlertSecondButtonReturn);
}
}

return shouldClose;
}

==

// SheetController.h

#import Cocoa/Cocoa.h

@interface SheetController:NSObject {
NSWindow *itsWindow;   // passed to show methods
int  itsReturnCode;
}

- (int) getReturnCode;
- (void) showCalculateSheet:(NSWindow*)docWindow;
- (void) endCalculateSheet:(NSAlert*)theSheet
   returnCode:(int)returnCode
   contextInfo:(void*)contextInfo;
@end

==

// SheetController.m

#import SheetController.h

@implementation SheetController

- (id) init {
if (self = [super init]) {
 itsReturnCode = -1;
}

return self;
}


- (int) getReturnCode {
return itsReturnCode;
}


- (void) showCalculateSheet:(NSWindow*)docWindow {
NSButton *cButton, *sButton, *dButton;

itsWindow = docWindow;   // set instance variable
NSAlert *calculateSheet = [[[NSAlert alloc] init] autorelease];
[itsWindow setDelegate:calculateSheet];

cButton = [calculateSheet addButtonWithTitle:@Continue];
 // [cButton setKeyEquivalent:@\r];   // automatic for default button
sButton = [calculateSheet addButtonWithTitle:@Stop and save];
[sButton setKeyEquivalent:@s];
dButton = [calculateSheet addButtonWithTitle:@Stop and don't save];
[dButton setKeyEquivalent:@d];
[calculateSheet setMessageText:@You have not finished calculating your
Spreadsheet.\n
Do you wish to continue calculating?];
[calculateSheet setAlertStyle:NSWarningAlertStyle];

itsReturnCode = 1;
[calculateSheet beginSheetModalForWindow:docWindow modalDelegate:self
  didEndSelector:@selector
(endCalculateSheet:returnCode:contextInfo:)
  contextInfo:docWindow];
 // while (itsReturnCode == -1);  // tried this, but had to force-quit
}


- (void) endCalculateSheet:(NSAlert*)theSheet
   returnCode:(int)returnCode
   contextInfo:(void*)contextInfo {
if (returnCode == NSAlertFirstButtonReturn)// Continue
{
   

applicationWillTerminate and asynchronous orderly shutdown

2008-06-10 Thread Stuart Malin
I have an app that establishes multiple TCP connections. If the user  
quits the app, I'd like to shut all those connections gracefully  
(i.e., conduct a bit of protocol) rather than just close them  
abruptly. To most properly handle this, I should even wait for the  
servers' responses.  I am currently initiating the graceful shutdown  
in applicationWillTerminate  but... how should I best wait for the  
connections to close: spin in a loop and check them? and set a timer  
for a timeout?  Or, is there another way to more properly handle  
asynchronous activity at application termination?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Mail Rule Actions Control

2008-06-10 Thread Steven Huey
I'm looking to create a control or set of controls like the actions  
portion of a rule in Apple Mail. The new NSRuleEditor control in  
Leopard looks like it might be a good fit, but I can't find any sample  
code. Does anyone have any experiences with NSRuleEditor or code  
they're willing to share. Or other ideas, approaches, etc.. ???


Thanks,
Steve

--
Steven Huey Software - http://www.stevenhuey.com




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Updating a progress bar from a code loop

2008-06-10 Thread Hamish Allan
On Tue, Jun 10, 2008 at 11:17 AM, Graham Cox [EMAIL PROTECTED] wrote:

 In this case I can do that... though out of curiosity I wonder if there is a
 way to do this cooperatively on the main thread without having to break up
 the loop doing the actual work. For example, in Carbon one can run the event
 loop for a short period or just for one event on each cycle of the loop -
 and this code can live in the progress dialog controller, so it works
 transparently with respect to the loop that drives the progress indicator.
 I'm not sure that approach is considered good in this day and age though I
 used it a lot on Mac OS 6/7/8/9. Just wondered if such an approach is
 feasible in Cocoa.

FWIW, I think it's worth getting acquainted with multithreading --
multi-core CPUs are not just the future, they are also the present!

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: applicationWillTerminate and asynchronous orderly shutdown

2008-06-10 Thread Hamish Allan
On Tue, Jun 10, 2008 at 9:12 PM, Stuart Malin [EMAIL PROTECTED] wrote:

 I have an app that establishes multiple TCP connections. If the user quits
 the app, I'd like to shut all those connections gracefully (i.e., conduct a
 bit of protocol) rather than just close them abruptly. To most properly
 handle this, I should even wait for the servers' responses.  I am currently
 initiating the graceful shutdown in applicationWillTerminate  but... how
 should I best wait for the connections to close: spin in a loop and check
 them? and set a timer for a timeout?  Or, is there another way to more
 properly handle asynchronous activity at application termination?

You could override applicationShouldTerminate:, return
NSTerminateLater, and then call replyToApplicationShouldTerminate:
when you've finished shutting down your connections. (You should
probably also give the user the option to Terminate Now.)

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: Prevent Asynchronous operation of beginSheetModalForWindow

2008-06-10 Thread Michael Ash
On Tue, Jun 10, 2008 at 1:10 PM, John Love [EMAIL PROTECTED] wrote:
 I have chosen the title Prevent Asynchronous operation of
 beginSheetModalForWindow because I use various calls to
 beginSheetModalForWindow in many parts of my app code and in one case I need
 the calls to didEndSelector to be completed *before* the code that follows
 beginSheetModalForWindow is executed (see MyDocument.m below).

I'm sorry to have to tell you this, but you are doomed.

Sheets are inherently asynchronous. To understand why, think about
what happens when two sheets are displayed on two different windows.
The user can dismiss them in any order. What happens if sheet A
displays, then sheet B displays, then the user goes back and closes
sheet B? If there were a synchronous API the code would have to
somehow jump down the stack to where you're waiting for A, while
somehow leaving the stuff that's waiting for B live farther up the
stack. This is quite simply impossible in a C-based language.

Is there some reason you can't just put all of the after code in the
endCalculateSheet: method?

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-factoring a category into a class instance

2008-06-10 Thread Paul Archibald

Comrades:

I am working on a file-handling Cocoa app that (at this point) has a  
single window. We are adding a second window (really sort of a non- 
modal dialog) to do some extra processing of the target files. The  
interface for the new window is already built (with IB), but is not  
hooked up yet.


So, the way this started was as a AppController(ExtraCategory) thing,  
with the NIB file having a single controller object. I don't like  
that method, because there is a lot of data and code that would need  
to be replicated in the main AppController to handle the work that  
the ExtraCategory does. What I would like to do is put all the  
ExtraCategory stuff into its own class, but I am not sure how. My  
inclination is toward making the ExtraCategory into a  
NSWindowResponder, but the documentation I have read so far makes it  
look like that is more intended for document-based apps, which this  
is not. Also, I don't quite see (looking at some example code) how an  
extra controller is instantiated by the main app controller.


 A simplified example of the current code 

@interface AppController {
NSString* srcDir;   // the original stuff
NSString destDir;   // original
// there is a bunch more

	NSString* srcDirForExtraCategory;	// needed for new window/dialog/ 
category

NSString destDirForExtraCategory;   // needed for new
// more stuff needed here
}
-(void)setSrc;  // implemented in the .m file, of course
-(void)setDest;
@end

and in AppController(ExtraCtegory)

@interface AppController(ExtraCategory)
-(void)setSrcForExtraCategory;  // special handling
-(void)setDestForExtraCategory; // special handling
@end

It seems funky to me that I can declare extra functions for the  
ExtraCategory, but I can't add member data. I understand there is a  
difference between the class/subclass and the class/category  
paradigms. I guess what I am trying to do is turn this new window  
category into a standalone class, instantiate it (in the NIB, I  
suppose), and control its availability from the original main app  
controller instance.


Any advice?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Mail Rule Actions Control

2008-06-10 Thread Scott Anguish

try searching in Xcode's documentation with full text mode

http://developer.apple.com/samplecode/PredicateEditorSample/index.html

is what I got.


On Jun 10, 2008, at 1:16 PM, Steven Huey wrote:

I'm looking to create a control or set of controls like the  
actions portion of a rule in Apple Mail. The new NSRuleEditor  
control in Leopard looks like it might be a good fit, but I can't  
find any sample code. Does anyone have any experiences with  
NSRuleEditor or code they're willing to share. Or other ideas,  
approaches, etc.. ???


___

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: NSSlider responding to superview's drawRect

2008-06-10 Thread Michael Watson
This is normally what I have to do as well, but is there a more  
optimized way to achieve the goal of drawing only the rect that needs  
redrawing?



--
m-s

On 10 Jun, 2008, at 12:05, Ken Ferry wrote:

You're probably filling your gradient into the rect passed in  
drawRect.


That rectangle just represents the dirty part of your view. If you  
had a solid color to draw, you could just fill the rect, but with a  
gradient you will get your gradient, top to bottom, within this  
possibly small rect within your view.


Try drawing the gradient into [self bounds] instead.  This describes  
the location of the entire view in its own coordinate system.


-Ken

On Jun 10, 2008, at 8:51 AM, Jonathan Dann [EMAIL PROTECTED] wrote:


Hi All,

This is something that I haven't seen before. I have a custom view  
that inherits from NSView directly and just draws a gradient  
background. In IB I've placed an NSSlider on the view which works  
fine. The problem comes when drawRect in my custom view is invoked,  
I draw the gradient and a 1px line at the top of the view, but the  
line also gets draw just above the NSSlider! logging shows the  
following


1) resize window - drawRect is called and the line above the slider  
disappears
2) move slider - drawRect is called from my gradient view but with  
the frame of the slider. The line then appears.


Is this a known issue with NSSlider and a custom view or have I  
missed an idiosyncracy of NSControls.


Thanks in adavnce,

Jonathan
___

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/kenferry%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/mikey-san 
%40bungie.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: re-factoring a category into a class instance

2008-06-10 Thread Brian Stern


On Jun 10, 2008, at 5:05 PM, Paul Archibald wrote:


Comrades:

I am working on a file-handling Cocoa app that (at this point) has a  
single window. We are adding a second window (really sort of a non- 
modal dialog) to do some extra processing of the target files. The  
interface for the new window is already built (with IB), but is not  
hooked up yet.


So, the way this started was as a AppController(ExtraCategory)  
thing, with the NIB file having a single controller object. I don't  
like that method, because there is a lot of data and code that would  
need to be replicated in the main AppController to handle the work  
that the ExtraCategory does. What I would like to do is put all the  
ExtraCategory stuff into its own class, but I am not sure how. My  
inclination is toward making the ExtraCategory into a  
NSWindowResponder, but the documentation I have read so far makes it  
look like that is more intended for document-based apps, which this  
is not. Also, I don't quite see (looking at some example code) how  
an extra controller is instantiated by the main app controller.




Since there's no such thing as NSWindowResponder I assume what you  
meant was NSWindowController.  And that's what you should use.   
There's no limitation of NSWindowController being only available or  
useful in document based apps.


You can instantiate it in the nib with IB or in code.  I usually  
instantiate it in code and have it load the nib and be the file's owner.


@implementation MyWinController

- (id)initWithWhatever:(whatever*)whatever
{
self = [super initWithWindowNibName:kMyWindowNibName];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and  
return nil.

}
return self;
}

// etc.


// instantiate it in your app controller something like this:

- (void)showMyWindow
{
if (! mMyWinController)
{
		mMyWinController = [[MyWinController alloc]  
initWithWhatever:whatever];

}

[mMyWinController showWindow:self];
}



___

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: Prevent Asynchronous operation of beginSheetModalForWindow

2008-06-10 Thread Jens Alfke


On 10 Jun '08, at 1:27 PM, Michael Ash wrote:


If there were a synchronous API the code would have to
somehow jump down the stack to where you're waiting for A, while
somehow leaving the stuff that's waiting for B live farther up the
stack. This is quite simply impossible in a C-based language.


It's not impossible, but it would require either that every window ran  
in a separate thread (as in the BeOS) or that the Cocoa frameworks  
supported coroutines. Coroutines are quite feasible in C, using setjmp/ 
longjmp style trickery; but when I investigated this I saw that using  
them would probably seriously confuse Objective-C's exception  
handling, and possibly NSRunLoop too.


John, you should look at the Cocoa conceptual docs that describe the  
use of sheets. There are probably a bunch of examples of sheet usage  
in the sample code too, if you search for beginSheetModalForWindow:.


—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]

launching standard apps with NSTask

2008-06-10 Thread Memo Akten
Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there is a  
way of writing the launch url  not fully hardcoded but using some  
system variables / methods etc.?


Memo (Mehmet S. Akten)

www.memo.tv

[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: launching standard apps with NSTask

2008-06-10 Thread Nick Zitzmann


On Jun 10, 2008, at 4:55 PM, Memo Akten wrote:

Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there is  
a way of writing the launch url  not fully hardcoded but using some  
system variables / methods etc.?



Take a look at the documentation for Launch Services.

Nick Zitzmann
http://www.chronosnet.com/

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: launching standard apps with NSTask

2008-06-10 Thread Michael Vannorsdel

[[NSWorkspace sharedWorkspace] launchApplication:@Safari];


On Jun 10, 2008, at 4:55 PM, Memo Akten wrote:

Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there is  
a way of writing the launch url  not fully hardcoded but using some  
system variables / methods etc.?


Memo (Mehmet S. Akten)


___

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: Prevent Asynchronous operation of beginSheetModalForWindow

2008-06-10 Thread Graham Cox

Hi John,

While I understand to some extent why you've done it this way, you've  
also managed to tie yourself in knots here. Sheets are slightly more  
complex than running an old-school modal dialog inline but they are  
not as complicated as you seem to have made them!


The basic idea is that you have two pieces of code - one that triggers  
the sheet, and another that responds to it when the user closes it.  
You don't normally need anything more, though it may make sense to  
factor code into a controller object which can ease its re-use (but is  
not essential). You put all your code that runs after the dialog has  
completed in the completion routine.


One important thing to note is that you do not *ever* run a loop like:

while( returnCode == -1 ){ ... }

that's just crazy talk ;-) Don't attempt to somehow stall the main  
event loop until the sheet has finished - that will never work and  
sheets aren't designed to work that way.


Here's what I typically do, this would be code in a window controller  
dedicated to this sheet (warning - typed into Mail):



- (void)startSheetOnParent:(NSWindow*) parentWindow
{
/* set up the initial state of the sheet dialog here */

	[NSApp beginSheet:[self window] modalForWindow:parentWindow  
modalDelegate:self
		didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)  
contextInfo:kSomeContextIdentifier];

}


- (void)	sheetDidEnd:(NSWindow*) sheet returnCode:(int) returnCode  
contextInfo:(void*) contextInfo

{
[sheet orderOut:nil];   // close the sheet

if ( returnCode == NSOKButton )
{
/*  process the result of the sheet here.
			If this method is shared with other sheets, you can use the  
contextInfo to

disambiguate the sheet.

			At this point just run the code that follows the sheet, or trigger  
it using a notification perhaps

*/
}
}


That's all you need. If your sheet has controls that interact with  
each other or external information, the 'modalDelegate' is the object  
that will handle that - again, it will be the sheet's controller.


If your calling code currently is arranged in such a way that it  
appears to you *necessary* to do something like:


- (void) doStuff
{
[mySheetController startSheetOnParent:[self windowForSheet]];

	while( sheetNotDone ){}		// spin hopelessly waiting for the sheet to  
finish - it never will because you've entered an infinite loop


if ( sheetResult == NSOKButton )
{
/* continue doing stuff */
}
}

then you need to refactor your code so that the 'keep doing stuff'  
part can be called directly from the sheet ended callback.


One thing that should be clear but maybe isn't is that the term  
'asynchronous' is a little misleading - the sheet is still being run  
on the same thread as the code that called it, so entering a while()  
loop waiting for the sheet to finish cannot possibly work - that loop  
will block the main thread so the sheet cannot continue to function,  
and there's nothing that could cause the loop to terminate. There is  
already a loop running that accomplishes this - the main event loop.


hth,


Graham





On 11 Jun 2008, at 6:10 am, John Love wrote:

Before I begin, I want to assure you that I have researched entries  
here on
sheets, as well as those in MacTech.com.  It's reasonably probable  
that I

have missed some entries and so that is why I am asking for help.

I also realize that this description is very long and I *really* did  
try to

shorten it.

My app is a Cocoa Document based app.

I have chosen the title Prevent Asynchronous operation of
beginSheetModalForWindow because I use various calls to
beginSheetModalForWindow in many parts of my app code and in one  
case I need
the calls to didEndSelector to be completed *before* the code that  
follows

beginSheetModalForWindow is executed (see MyDocument.m below).

With Asynchronous operation, the sheet will show for a very brief  
moment and
continue as the Apple docs stipulate .. I want the sheet to stay  
down UNTIL

I click one of the buttons in the sheet.

MacTech names calls to beginSheetModalForWindow DocModalNew.

What have I tried to do, but without success:

*1)* After the call to [calculateSheet  
beginSheetModalForWindow:docWindow ..

etc]; within showCalculateSheet, I have used:

   while (itsReturnCode == -1)  // the initialized value before the  
call to

beginSheetModalForWindow

   What happens is a never-ending loop from which I need to force- 
quit.


*2)* Within shouldCloseFile I have called:

   while ((theReturnCode = [theSheet getReturnCode]) == -1);  // same
never-ending loop results

The app's File's Owner is MyDocument

// inside my nib file I have a NSObject named FileController and
SheetController

// in MyDocument.h
#import Cocoa/Cocoa.h
#import FileController.h

@interface MyDocument:NSDocument {
   IBOutlet FileController*theFile;
   

Re: NSSlider responding to superview's drawRect

2008-06-10 Thread Graham Cox
I don't think it's worth attempting. I *think* that gradients are  
cached in some way so trying to recalculate the gradient to span the  
update rect correctly is: a) going to need a fair bit of work to  
calculate and b) not allow caching to work efficiently. In any case,  
pixels that are clipped out shouldn't be being drawn anyway, so the  
performance gain is likely to be miniscule.


G.

On 11 Jun 2008, at 7:22 am, Michael Watson wrote:

This is normally what I have to do as well, but is there a more  
optimized way to achieve the goal of drawing only the rect that  
needs redrawing?



--
m-s

On 10 Jun, 2008, at 12:05, Ken Ferry wrote:

You're probably filling your gradient into the rect passed in  
drawRect.


That rectangle just represents the dirty part of your view. If you  
had a solid color to draw, you could just fill the rect, but with a  
gradient you will get your gradient, top to bottom, within this  
possibly small rect within your view.


Try drawing the gradient into [self bounds] instead.  This  
describes the location of the entire view in its own coordinate  
system.




___

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: launching standard apps with NSTask

2008-06-10 Thread Memo Akten
Hi, that looks great thanks, I've just been looking through the  
documentation, but I don't think it allows control over terminating  
the app, or detecting when its closed. I would like to have that level  
of control (just terminate, and detect if user close it) - which is  
why I was opting for NSTask - but actually I'm not having any luck  
with that either! (if I put the path to the .app I get a permission  
error, if I put the path to the file in contents/macos it doesn't  
work!). is there anything else I can do?


Memo (Mehmet S. Akten)

www.memo.tv

[EMAIL PROTECTED]



On 11 Jun 2008, at 00:02, Michael Vannorsdel wrote:


[[NSWorkspace sharedWorkspace] launchApplication:@Safari];


On Jun 10, 2008, at 4:55 PM, Memo Akten wrote:

Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there  
is a way of writing the launch url  not fully hardcoded but using  
some system variables / methods etc.?


Memo (Mehmet S. Akten)


___

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/memo%40memo.tv

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]


creating and using a View xib

2008-06-10 Thread Jerry Isdale
I'm building up a rather complex UI and would like to design, build,  
test portions of it as stand alone applications (esp so I can pass  
subsections to others to build).  Initially I started building the  
apps by creating new Cocoa apps in Xcode3 and using IB to tweak up the  
MainMenu.xib with Controllers.  That worked really nice - quick easy,  
shows the power of the tools. Now I want to take those boxes, tabs,  
etc from various standalone tools and put them into an integrated app.


I dont see a simple way to move stuff between MainMenus and a cryptic  
comment in the IB guide says its a good idea to have multiple NIBs.   
Digging around a bit I found Xcode Assistant has a New File option for  
Interface Builder-CocoaNIBView XIB.   I create one, copy over what  
was in MainMenu's Window (a Box holding a number of NSButtons and  
NSTextFields), and copy over the controller.  All looks good.  But now  
what?


How do I get that View/Controller to show up in the application window?
Do I have to programatically load the XIB and position the view within  
the app?
Do I have to turn it into an IB library object, then drag from library  
to window?




___

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: changing locale

2008-06-10 Thread Deborah Goldsmith
Not a supported way, no. We don't encourage applications to change  
system-wide settings.


Deborah Goldsmith
Apple Inc.
[EMAIL PROTECTED]

On Jun 10, 2008, at 8:05 AM, Alexander Cohen wrote:

Is there a way to change the locale from cocoa as if i was to go  
into System Preferences and change the language then the format?


thx

AC
___

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

This email sent to [EMAIL PROTECTED]



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Cocoa PDE validation

2008-06-10 Thread David Geering
Hi there,

I'm trying to develop a Cocoa print dialog extension that requires a user to
input a value. For arguments sake, imagine a PDE that requires a passphrase.
I have an alert that pops up if the passphrase is missing, and this alert is
displayed whether or not my PDE is ever selected/shown. On 10.5, this is easy
to implement with the shouldPrint method, but I need to replicate this
behaviour on Tiger as well.

The saveValuesAndReturnError does not help, because this is called when
switching between presets. So if they have not input the passphrase and try
to switch presets the user will get an error alert for doing nothing wrong.

Is there any way to implement the shouldPrint method on Tiger, and ideally
also works in Leopard?

Dave G.

Note:
This message is for the named person's use only. It may contain confidential, 
proprietary
or legally privileged information. No confidentiality or privilege is waived or 
lost by 
any mis-transmission. If you receive this message in error, please immediately 
delete it 
and all copies of it from your system, destroy any hard copies of it and notify 
the sender.  
You must not, directly or indirectly, use, disclose, distribute, print, or copy 
any part 
of this message if you are not the intended recipient. Toshiba Australia 
reserves the 
right to monitor all e-mail communications through its networks.

Thank You.

___

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: creating and using a View xib

2008-06-10 Thread Graham Cox
A .xib file is just a .nib file in a text format, so it is more  
compatible with svn. Xcode compiles the .xib into a .nib. So to edit  
one, use Interface Builder as usual.


because a .xib *is* a .nib, you load it as you do a nib - 
loadNibNamed:owner: You don't have to do anything different from what  
you would normally.



G.

On 11 Jun 2008, at 10:00 am, Jerry Isdale wrote:

I'm building up a rather complex UI and would like to design, build,  
test portions of it as stand alone applications (esp so I can pass  
subsections to others to build).  Initially I started building the  
apps by creating new Cocoa apps in Xcode3 and using IB to tweak up  
the MainMenu.xib with Controllers.  That worked really nice - quick  
easy, shows the power of the tools. Now I want to take those boxes,  
tabs, etc from various standalone tools and put them into an  
integrated app.


I dont see a simple way to move stuff between MainMenus and a  
cryptic comment in the IB guide says its a good idea to have  
multiple NIBs.  Digging around a bit I found Xcode Assistant has a  
New File option for Interface Builder-CocoaNIBView XIB.   I  
create one, copy over what was in MainMenu's Window (a Box holding a  
number of NSButtons and NSTextFields), and copy over the  
controller.  All looks good.  But now what?


How do I get that View/Controller to show up in the application  
window?
Do I have to programatically load the XIB and position the view  
within the app?
Do I have to turn it into an IB library object, then drag from  
library to window?




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: launching standard apps with NSTask

2008-06-10 Thread Adam Leonard
LaunchServices or NSWorkspace (which uses LS) is still probably your  
best option, as NSTask is not really designed to deal with GUI apps.


To terminate the app, you can send a quit apple event or use  
applescript. This has come up recently, so search the list archives.


To detect when the user terminates the application, you can also use  
NSWorkspace. See the documentation for  
NSWorkspaceDidTerminateApplicationNotification



Adam Leonard


On Jun 10, 2008, at 4:22 PM, Memo Akten wrote:

Hi, that looks great thanks, I've just been looking through the  
documentation, but I don't think it allows control over terminating  
the app, or detecting when its closed. I would like to have that  
level of control (just terminate, and detect if user close it) -  
which is why I was opting for NSTask - but actually I'm not having  
any luck with that either! (if I put the path to the .app I get a  
permission error, if I put the path to the file in contents/macos it  
doesn't work!). is there anything else I can do?


Memo (Mehmet S. Akten)

www.memo.tv

[EMAIL PROTECTED]



On 11 Jun 2008, at 00:02, Michael Vannorsdel wrote:


[[NSWorkspace sharedWorkspace] launchApplication:@Safari];


On Jun 10, 2008, at 4:55 PM, Memo Akten wrote:

Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there  
is a way of writing the launch url  not fully hardcoded but using  
some system variables / methods etc.?


Memo (Mehmet S. Akten)


___

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/memo%40memo.tv

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/adam%40caffeinatedcocoa.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: A simple doubt about array

2008-06-10 Thread Adam Leonard
If you do want to make use of some of the nice features of NSArray  
that C arrays don't have, it is trivial to add a category to NSArray  
that makes object retrieval easier. See http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_1.html


An example implementation might look something like this (not tested,  
and no type checking which you should probably do):


@implementation NSArray (PuzzleBoardAdditions)

- (id)objectAtRow:(NSUInteger)row column:(NSUInteger)column
{
return [(NSArray *)[self objectAtIndex:row] objectAtIndex:column];
}

@end


and (after importing the category interface), you can call it with one  
clean line like [array objectAtRow:0 column:0]


Adam Leonard

On Jun 10, 2008, at 12:22 PM, Sidnei Vladisauskis wrote:


Hi,

I'm making in a simple puzzle...It´s working perfect, but I'm with  
doubt about bidimensional array.


My code is:

NSMutableArray *array = [[NSMutableArray alloc] init];

for(int i = 0; i5; i++){

   NSMutableArray *arrayLine = [[NSMutableArray alloc] init];

   for(int ii = 0; ii5; ii++){
[arrayLine addObject:@str];
   }

   [array addObject:arrayLine];
}

It's right, ok?

For acces my object in my array I'm using this:

NSArray *tempArray = [array objcetAtIndex:0];
NSString *myStrig = [tempArray objectAtIndex:0];

This code return me the first object of the bidimensional array, but  
there other way for return my object?

In other linguages the more simples is using:

myObject = array[0][0];

And for replace is:

array[0][0] = newObject;

And in objective-C I use the method replaceObjectAtIndex ok?

Thanks... ___
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list  ([EMAIL PROTECTED])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/objc-language/adam%40caffeinatedcocoa.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: launching standard apps with NSTask

2008-06-10 Thread Memo Akten

Ok Thanks, will check it out...


Memo (Mehmet S. Akten)

www.memo.tv

[EMAIL PROTECTED]

On 11 Jun 2008, at 01:20, Adam Leonard wrote:

LaunchServices or NSWorkspace (which uses LS) is still probably your  
best option, as NSTask is not really designed to deal with GUI apps.


To terminate the app, you can send a quit apple event or use  
applescript. This has come up recently, so search the list archives.


To detect when the user terminates the application, you can also use  
NSWorkspace. See the documentation for  
NSWorkspaceDidTerminateApplicationNotification



Adam Leonard


On Jun 10, 2008, at 4:22 PM, Memo Akten wrote:

Hi, that looks great thanks, I've just been looking through the  
documentation, but I don't think it allows control over terminating  
the app, or detecting when its closed. I would like to have that  
level of control (just terminate, and detect if user close it) -  
which is why I was opting for NSTask - but actually I'm not having  
any luck with that either! (if I put the path to the .app I get a  
permission error, if I put the path to the file in contents/macos  
it doesn't work!). is there anything else I can do?


Memo (Mehmet S. Akten)

www.memo.tv

[EMAIL PROTECTED]



On 11 Jun 2008, at 00:02, Michael Vannorsdel wrote:


[[NSWorkspace sharedWorkspace] launchApplication:@Safari];


On Jun 10, 2008, at 4:55 PM, Memo Akten wrote:

Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there  
is a way of writing the launch url  not fully hardcoded but using  
some system variables / methods etc.?


Memo (Mehmet S. Akten)


___

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/memo%40memo.tv

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/adam%40caffeinatedcocoa.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/memo%40memo.tv

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: changing locale

2008-06-10 Thread Douglas Davidson


On Jun 10, 2008, at 5:42 PM, Alexander Cohen wrote:

Thats what i though but here is my problem, and i'm sure im not the  
only who has it. I am currently working on localizing apps for  
mulitple languages. I would like to have an easy way to set the  
locale without going into the system prefs and trying once again to  
guess which settings i need to change to get my locale to zh_CN, or  
zh_TW, KO or anything else.


Locale is not the same as localization.  It sounds like what you are  
interested in is localization.  If you want to launch a specific  
application instance in a specific localization, you can do so by  
specifying command-line arguments.  For example,


/Applications/TextEdit.app/Contents/MacOS/TextEdit -AppleLanguages  
(de)


will launch TextEdit in German.  You should also be able to set  
command-line arguments in Xcode.  The first argument here is - 
AppleLanguages, the name of the default.  The second is an array of  
strings, so that you could (for example) use (de,en) to specify a  
preference order of German first, English second.  The quotes are for  
the shell.


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

This email sent to [EMAIL PROTECTED]


Re: changing locale

2008-06-10 Thread Alexander Cohen


On Jun 10, 2008, at 8:50 PM, Douglas Davidson wrote:



On Jun 10, 2008, at 5:42 PM, Alexander Cohen wrote:

Thats what i though but here is my problem, and i'm sure im not the  
only who has it. I am currently working on localizing apps for  
mulitple languages. I would like to have an easy way to set the  
locale without going into the system prefs and trying once again to  
guess which settings i need to change to get my locale to zh_CN, or  
zh_TW, KO or anything else.


Locale is not the same as localization.  It sounds like what you are  
interested in is localization.  If you want to launch a specific  
application instance in a specific localization, you can do so by  
specifying command-line arguments.  For example,


/Applications/TextEdit.app/Contents/MacOS/TextEdit -AppleLanguages  
(de)


will launch TextEdit in German.  You should also be able to set  
command-line arguments in Xcode.  The first argument here is - 
AppleLanguages, the name of the default.  The second is an array of  
strings, so that you could (for example) use (de,en) to specify a  
preference order of German first, English second.  The quotes are  
for the shell.


Nice, i didnt know that. Im not sure this completely fullfills my  
needs, but it will do for now.


thx

AC
___

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: Spotlight sources w/o actual files?

2008-06-10 Thread Ken Thomases

On Jun 10, 2008, at 3:57 AM, Rasmus Andersson wrote:


Oh, just as I feared. The problem is the metadata itself is probably
hundreds of gigabytes, if not terabytes in size, so it would be
impossible to have mdimporter index fake files.


If the _meta_data is really that large, then this is sort of an insane  
thing to try to do.  It means that at least that much data will have  
to be accessed by Spotlight on the initial indexing pass, and  
similarly that much data will need to be stored in Spotlight's  
indexes.  How much network traffic will this involve?  How much CPU to  
run your importer on all of this data?  How much disk space to store  
the metadata into Spotlight's index?  This is just plain abuse of  
Spotlight.


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: re-factoring a category into a class instance

2008-06-10 Thread Paul Archibald
Ooops, saw that go by and spaced out fixing it. I am just beginning  
with Cocoa, and the framework names are not that familiar yet.


Thanks for the advice, Brian, especially the part about instantiating  
my controller in code. I figured it couldn't be too hard, but a  
little nudge in the right direction is welcome.



On Jun 10, 2008, at 4:04 PM, [EMAIL PROTECTED] wrote:


Since there's no such thing as NSWindowResponder I assume what you
meant was NSWindowController.


___

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: Updating a progress bar from a code loop

2008-06-10 Thread j o a r


On Jun 10, 2008, at 3:17 AM, Graham Cox wrote:

though out of curiosity I wonder if there is a way to do this  
cooperatively on the main thread without having to break up the  
loop doing the actual work. For example, in Carbon one can run the  
event loop for a short period or just for one event on each cycle of  
the loop - and this code can live in the progress dialog controller,  
so it works transparently with respect to the loop that drives the  
progress indicator. I'm not sure that approach is considered good  
in this day and age though I used it a lot on Mac OS 6/7/8/9. Just  
wondered if such an approach is feasible in Cocoa.



Yes, you can do that. You would typically use a NSTimer to repeatedly  
schedule small pieces of work to be performed on the main thread. You  
wouldn't have to use a modal session to do this - It is certainly not  
a requirement to lock out the user while processing data.


That said - No, it is not considered to be a good approach. It's  
almost impossible to implement it in such a way that it doesn't affect  
the user experience. It's typically much better, and more future  
safe, to invest your time in a multi-threaded implementation.


j o a r


___

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: crash on command-W

2008-06-10 Thread James W. Walker


On Jun 10, 2008, at 7:24 AM, Adam R. Maxwell wrote:


On Jun 9, 2008, at 10:30 PM, James W. Walker wrote:



On Jun 9, 2008, at 9:18 PM, Andrew Farmer wrote:


On 09 Jun 08, at 21:03, James W. Walker wrote:



OK, I turned on NSZombieEnabled, and now I get this in the log:

*** -[LogController tableView:objectValueForTableColumn:row:]:  
message sent to deallocated instance


That means that the LogController itself has been deallocated,  
not some member that the method uses, right?  All this tells me  
is that somebody is trying to draw the table after the controller  
has been released and the window has been hidden if not  
released.  I pretty much knew that already.


In your windowWillClose method, set the tableview datasource and  
delegate to nil, so it stops messaging your controller.  This is a  
good habit to get into with datasource/delegate objects.


Thanks for the advice, that sounds reasonable.
___

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]


Issue with displaying URI prefixes on child elements using NSXML

2008-06-10 Thread Lawrence Johnston

Hey everybody, I've got an issue that I can't figure out.

If I'm using this code:

NSString *XMLForDisplay {

  NSXMLElement *root = [NSXMLNode elementWithName:@root];
  [root addNamespace:[NSXMLNode namespaceWithName:@a stringValue:@http://www.tempurl.com 
]];


  NSXMLElement *child = [NSXMLNode elementWithName:@child URI:@http://www.tempurl.com 
];

  [child addChild:[NSXMLNode textWithStringValue:@myText]];

  [root addChild:child];

  return [root XMLStringWithOptions:NSXMLNodePrettyPrint];
}


I believe it should be outputting this text:

root xmlns:a=http://www.tempurl.com;
  a:childmyText/a:child
/root

However, instead it outputs this text (note the lack of prefix on the  
child):


root xmlns:a=http://www.tempurl.com;
  childmyText/child
/root

This is an issue, because I need that a: prefix.

The documentation for elementWithName:URI: states it's equivalent to  
URI:name/URI:name, which is exactly what I want, except that I  
can't get it to display that way.


Thanks for your time.
___

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: Updating a progress bar from a code loop

2008-06-10 Thread Graham Cox


On 11 Jun 2008, at 2:40 pm, j o a r wrote:



On Jun 10, 2008, at 3:17 AM, Graham Cox wrote:

though out of curiosity I wonder if there is a way to do this  
cooperatively on the main thread without having to break up the  
loop doing the actual work. For example, in Carbon one can run the  
event loop for a short period or just for one event on each cycle  
of the loop - and this code can live in the progress dialog  
controller, so it works transparently with respect to the loop that  
drives the progress indicator. I'm not sure that approach is  
considered good in this day and age though I used it a lot on Mac  
OS 6/7/8/9. Just wondered if such an approach is feasible in Cocoa.



Yes, you can do that. You would typically use a NSTimer to  
repeatedly schedule small pieces of work to be performed on the main  
thread. You wouldn't have to use a modal session to do this - It is  
certainly not a requirement to lock out the user while processing  
data.


Sure, I can easily implement piecemeal work using a timer. That's not  
quite the same as I was asking. I was wondering if I could do  
something like:



while( notFinished )
{
/* do some work */

letTheEventLoopRunABit();
}


This was a pretty common idiom in the pre-OS X days, though of course  
one must bear in mind what the stack looks like when the event loop is  
allowed to run. It ain't pretty ;-)


That said - No, it is not considered to be a good approach. It's  
almost impossible to implement it in such a way that it doesn't  
affect the user experience. It's typically much better, and more  
future safe, to invest your time in a multi-threaded implementation.



Yep, seems to be the way to go. In this case it was an easy change to  
allow the work to run on a separate thread. I guess the only thing  
that scares me about threads are the sheer number of classes that are  
not considered thread-safe, and so calling one accidentally from  
another thread.



cheers, 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]