NSOutlineView setDoubleAction: working on 10.5, but not on 10.4.11

2008-11-15 Thread Nick Rogers

Hi,
when double clicking on an item the action method is not being called  
in 10.4.11.

While the Apple docs say it is "Available in Mac OS X v10.0 and later."
Is there something I may be missing.
Its working fine on Leopard.


Thanks,
Nick

___

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

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

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

This email sent to [EMAIL PROTECTED]


Layer-backed NSOpenGLView not showing up

2008-11-15 Thread Albert Martin

Hello,

I am trying to programmatically create an NSOpenGLView and have it  
layer-backed.  I would use CAOpenGLLayer except that I am using a  
subclass of NSOpenGLView and I don't have the time to rewrite it.   
Now, for some reason I can not get the NSOpenGLView to show up.  If I  
use the same subclassed NSOpenGLView in Interface Builder everything  
shows up fine and I can communicate with it how I need to, but if I  
create it programmatically it simply never shows up.


The weird thing is that I think it is getting created correctly but is  
just not becoming visible.  The NSOpenGLView plays a QTMovie and even  
though it doesn't show up I can still hear the audio from the QTMovie  
playing back.  Also, I've added a bunch of NSLog's in the subclass and  
they all get triggered when I try to communicate with the version that  
was created programmatically even though it never shows up.


Here's my code ... what am I doing wrong?

videoLayer = [[CALayer layer] retain];

NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFANoRecovery,

NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 16,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
0};

presentationVideoLayer = [[[IWVideoView alloc] initWithFrame:  
NSMakeRect(0, 0, frameRect.size.width, frameRect.size.height)  
pixelFormat: [[NSOpenGLPixelFormat alloc]  
initWithAttributes:attributes]] retain];

[presentationVideoLayer setLayer: videoLayer];
[presentationVideoLayer setWantsLayer: YES];

[[self layer] addSublayer: videoLayer];

[presentationVideoLayer setNeedsDisplay: YES];
[[presentationVideoLayer openGLContext] update];
___

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

Please do not post admin requests or moderator comments to the list.
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: NSOutlineView setDoubleAction: working on 10.5, but not on 10.4.11

2008-11-15 Thread Jerry Krinock


On 2008 Nov, 15, at 2:54, Nick Rogers wrote:

when double clicking on an item the action method is not being  
called in 10.4.11.

Its working fine on Leopard.


The behavior was indeed changed in Leopard:

http://developer.apple.com/releasenotes/Cocoa/AppKit.html

"NSTableView/NSOutlineView - Single click to editNSTableView and  
NSOutlineView now behave like Finder and allow a single click to put  
it into edit mode. This is done by calling - 
hitTestForEvent:inRect:ofView: and checking if the cell returns  
NSCellHitEditableTextArea. This allows you to set a doubleAction and  
perform some different task when the doubleAction is invoked (for  
instance, Finder opens files on a double click, and edits via a single  
click). If the doubleAction is not set, editing is still allowed via a  
double click."


The converse of this statement would be that, in 10.4.11,  
doubleclicking will always edit.


Personally, I believe this should be explained in the current  
documentation, but I've seen other cases in which Apple documents  
version-specific behavior changes in Release Notes only.  I don't know  
if that is intentional Apple policy or 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]


Re: Calling a script with parameters failing with error -1708

2008-11-15 Thread has

Ken Tozier wrote:


I've been trying off and on for a couple of days to run a script that
requires parameters. [...]

My code is running as a Quark XTension so I may be setting up the
"targetAddress" incorrectly.


If you're constructing Apple events to pass to - 
executeAppleEvent:error:, the address isn't important and a null  
descriptor will do.




Could someone take a look at the
following snippet and point out where I'm messing up?


The event class and id for invoking a script handler whose name is a  
user-defined identifier should be kASAppleScriptSuite and  
kASSubroutineEvent. (e.g. There's an example project,  
CallAppleScriptHandler, in the objc-appscript repositorythat shows how  
to do this.) Though as you're using OSAKit and your subroutine takes  
positional parameters, you could just use -[OSAScript  
executeHandlerWithName:arguments:error:] instead.


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Layer-backed NSOpenGLView not showing up

2008-11-15 Thread Matt Long
I'll find a reference when I get a chance, but I recall reading  
somewhere that what you're trying to do won't work. You will need to  
use CAOpenGLLayer if you want to add sub-layers to it.


Just to test it, don't add the sub-layer and see if it shows up then.  
If it doesn't then you may have other issues in your init code. You  
might try hooking up an NSOpenGLView in Interface Builder instead. I  
am pretty sure, though that you'll need a CAOpenGLLayer.


Here is a blog post I wrote that shows how to display a QuickTime  
movie using a CAOpenGLLayer: http://www.cimgf.com/2008/09/10/core-animation-tutorial-rendering-quicktime-movies-in-a-caopengllayer/


HTH,

-Matt



On Oct 3, 2008, at 10:46 AM, Albert Martin wrote:


Hello,

I am trying to programmatically create an NSOpenGLView and have it  
layer-backed.  I would use CAOpenGLLayer except that I am using a  
subclass of NSOpenGLView and I don't have the time to rewrite it.   
Now, for some reason I can not get the NSOpenGLView to show up.  If  
I use the same subclassed NSOpenGLView in Interface Builder  
everything shows up fine and I can communicate with it how I need  
to, but if I create it programmatically it simply never shows up.


The weird thing is that I think it is getting created correctly but  
is just not becoming visible.  The NSOpenGLView plays a QTMovie and  
even though it doesn't show up I can still hear the audio from the  
QTMovie playing back.  Also, I've added a bunch of NSLog's in the  
subclass and they all get triggered when I try to communicate with  
the version that was created programmatically even though it never  
shows up.


Here's my code ... what am I doing wrong?

videoLayer = [[CALayer layer] retain];

NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFANoRecovery,

   NSOpenGLPFAColorSize, 24,
   NSOpenGLPFAAlphaSize, 8,
   NSOpenGLPFADepthSize, 16,
   NSOpenGLPFADoubleBuffer,
   NSOpenGLPFAAccelerated,
0};

presentationVideoLayer = [[[IWVideoView alloc] initWithFrame:  
NSMakeRect(0, 0, frameRect.size.width, frameRect.size.height)  
pixelFormat: [[NSOpenGLPixelFormat alloc]  
initWithAttributes:attributes]] retain];

[presentationVideoLayer setLayer: videoLayer];
[presentationVideoLayer setWantsLayer: YES];

[[self layer] addSublayer: videoLayer];

[presentationVideoLayer setNeedsDisplay: YES];
[[presentationVideoLayer openGLContext] update];

___

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

Please do not post admin requests or moderator comments to the list.
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: Calling a script with parameters failing with error -1708

2008-11-15 Thread Ken Tozier
Thanks for the reply. I just tried it, but no luck. Still getting a  
"event not handled" error. The script runs fine from the Script editor  
so all I can think of is that the subroutine option is broken in both  
NSAppleScript and OSAScript. Is this a known bug in Apple's script  
frameworks? I've tried using both "ReplaceFolioDates" and  
"replacefoliodates" but both give me the exact same error.


The script itself is extremely simple

on ReplaceFolioDates(inDate)
tell application "QuarkXPress"
tell master document 1
			set every text of text boxes of spreads where it is "FOLIO_DAY,  
FOLIO_MONTH, FOLIO_DATE, FOLIO_YEAR" to inDate

end tell
end tell
end ReplaceFolioDates

It seems to me that there must be some arcane detail I'm missing  
because I can't imagine that Apple wouldn't allow applications to run  
scripts with parameters and yet nothing I've tried ever works.



On Nov 15, 2008, at 10:21 AM, has wrote:

The event class and id for invoking a script handler whose name is a  
user-defined identifier should be kASAppleScriptSuite and  
kASSubroutineEvent. (e.g. There's an example project,  
CallAppleScriptHandler, in the objc-appscript repositorythat shows  
how to do this.) Though as you're using OSAKit and your subroutine  
takes positional parameters, you could just use -[OSAScript  
executeHandlerWithName:arguments:error:] instead.



___

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

Please do not post admin requests or moderator comments to the list.
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: Tabbing PDF Annotation Editor between annotations in "edit mode"?

2008-11-15 Thread Joel Norvell
On Nov 14, 2008, at 12:18 PM, Joel Norvell wrote:

> > > I want to modify the PDF Annotation Editor so that it will tab from  
> > > annotation-to-annotation in "edit mode," just like it does in "test  
> > > mode."
> > > 
> > > And since PDFAnnotation isn't an NSView subclass, I'll have to  
> > > create a mechanism that "hears" tab events and then updates the  
> > > current annotation "by hand."

On Nov 14, 2008, at 12:28 PM, John Calhoun wrote:

> > My first thought would be to go a different route ... grab keyDown's  
> > in your PDFView subclass and keep track of the current annotation with  
> > "focus".  Manually advance the focus by going round-robin threough the  
> > annotaions on the page.  If you can do something more sophisticated  
> > though, go for it. :-)

On Nov 15, 2008, at 01:05 AM, Joel Norvell wrote:

> John,
> 
> I'd wrongly convinced myself that your approach was problematic; 
> but it is exactly the right one!

I've posted the code for this recipé in a blog entry: "Tabbing In PDF 
Annotation Editor."

http://tinyurl.com/6rbpy5

Yours in Cocoa,
Joel

http://frameworker.wordpress.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]


Finder's sidebar background color

2008-11-15 Thread Knut Lorenzen


Hi list,

is there a way to obtain the background color of Finder's sidebar  
programmatically? In active (i.e. frontmost) and inactive state? I've  
searched the documentation and looked up NSColorList to no avail.


Of course it it rather easy to "steal" the colors from Finder and set  
them to
[NSColor colorWithDeviceRed: 214/256.0 green: 221/256.0 blue:  
229/256.0 alpha: 1.0 ] and
[NSColor colorWithDeviceRed: 232/256.0 green: 232/256.0 blue:  
232/256.0 alpha: 1.0 ] respectively,

but I'd rather not hard-wire this.

Cheers,

Knut

___

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

Please do not post admin requests or moderator comments to the list.
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: Finder's sidebar background color

2008-11-15 Thread Kyle Sluder
On Sat, Nov 15, 2008 at 3:58 PM, Knut Lorenzen <[EMAIL PROTECTED]> wrote:
> is there a way to obtain the background color of Finder's sidebar
> programmatically?

If you're trying to create a sidebar, set its selection highlight
style to NSTableViewSelectionHighlightStyleSourceList.  If you're not
trying to create a sidebar, why do you need this color?  If you try to
extract it from an appropriately-configured NSTableView (or
NSOutlineView) is some sort of weird, funky NSColor subclass that
changes when the application gains/loses active status.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Finder's sidebar background color

2008-11-15 Thread Markus Spoettl

On Nov 15, 2008, at 12:58 PM, Knut Lorenzen wrote:
is there a way to obtain the background color of Finder's sidebar  
programmatically?


Yes, if you have an NSOutlineView instance in SourceList display mode  
you can just use its -backgroundColor is to get the correct color.  
Refreshing whatever you draw whenever your window receives a  
NSWindowDidBecomeMainNotification or NSWindowDidResignMainNotification  
notification will keep it in sync with the outline view background  
when the window becomes active and inactive.


Regards
Markus
--
__
Markus Spoettl



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: Finder's sidebar background color

2008-11-15 Thread Knut Lorenzen


Am 15.11.2008 um 22:04 schrieb Kyle Sluder:

On Sat, Nov 15, 2008 at 3:58 PM, Knut Lorenzen <[EMAIL PROTECTED]>  
wrote:

is there a way to obtain the background color of Finder's sidebar
programmatically?


If you're trying to create a sidebar, set its selection highlight
style to NSTableViewSelectionHighlightStyleSourceList.


Kyle,

thanks for the quick reply, but I am not trying to do so.


If you're not trying to create a sidebar, why do you need this color?


My App (OMCEdit, see ) mimics the look of Finder (and Mail, iTunes,...), hence I need  
these colors in order to display an active/inactive state.


Cheers,

Knut



___

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

Please do not post admin requests or moderator comments to the list.
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: Finder's sidebar background color

2008-11-15 Thread Knut Lorenzen


Am 15.11.2008 um 22:10 schrieb Markus Spoettl:


On Nov 15, 2008, at 12:58 PM, Knut Lorenzen wrote:

is there a way to obtain the background color of Finder's sidebar
programmatically?


Yes, if you have an NSOutlineView instance in SourceList display mode
you can just use its -backgroundColor is to get the correct color.
Refreshing whatever you draw whenever your window receives a
NSWindowDidBecomeMainNotification or NSWindowDidResignMainNotification
notification will keep it in sync with the outline view background
when the window becomes active and inactive.


Markus,

thanks, that looks promising.

There is no NSOutlineView in my App right now, but it sounds as it  
might be possible to use an invisible NSOutlineView-dummy just in  
order to get the colors from it.


Cheers,

Knut





___

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

Please do not post admin requests or moderator comments to the list.
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: Finder's sidebar background color

2008-11-15 Thread Andrew Merenbach

On Nov 15, 2008, at 1:41 PM, Knut Lorenzen wrote:



Am 15.11.2008 um 22:10 schrieb Markus Spoettl:


On Nov 15, 2008, at 12:58 PM, Knut Lorenzen wrote:

is there a way to obtain the background color of Finder's sidebar
programmatically?


Yes, if you have an NSOutlineView instance in SourceList display mode
you can just use its -backgroundColor is to get the correct color.
Refreshing whatever you draw whenever your window receives a
NSWindowDidBecomeMainNotification or  
NSWindowDidResignMainNotification

notification will keep it in sync with the outline view background
when the window becomes active and inactive.


Markus,

thanks, that looks promising.

There is no NSOutlineView in my App right now, but it sounds as it  
might be possible to use an invisible NSOutlineView-dummy just in  
order to get the colors from it.


Cheers,

Knut


Hi, Knut,

Just out of curiosity: if you're trying to mimic the Finder, iTunes,  
etc., what would you be using besides an outline view?  A normal table  
view wouldn't allow you to have groupings of subitems that are  
viewable with disclosure triangles.


Best,
Andrew


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: Finder's sidebar background color

2008-11-15 Thread Knut Lorenzen


Am 15.11.2008 um 22:45 schrieb Andrew Merenbach:


Just out of curiosity: if you're trying to mimic the Finder, iTunes,
etc., what would you be using besides an outline view?  A normal table
view wouldn't allow you to have groupings of subitems that are
viewable with disclosure triangles.



Hello again, Andrew!

I am afraid I was unclear, mimicing Finder (and it's ilk) only color- 
wise.


If you are really curious, check out OnMyCommand (). It is free and a very nifty piece of software for the Mac.


Cheers,

Knut






___

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

Please do not post admin requests or moderator comments to the list.
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: Finder's sidebar background color

2008-11-15 Thread Kyle Sluder
On Sat, Nov 15, 2008 at 5:06 PM, Knut Lorenzen <[EMAIL PROTECTED]> wrote:
> I am afraid I was unclear, mimicing Finder (and it's ilk) only color-wise.

I'm still a bit confused... where will you be using this color?  This
is the color for source lists.  You should have a *very* good reason
for using it anywhere else (and thus cause your app to function
counter to user expectations).

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Detecting in/activity

2008-11-15 Thread Jacob Bandes-Storch

Hi all,

I'd like to have an app/daemon/something detect when the computer  
becomes active after a period of inactivity, much like iChat does when  
it says "Welcome back! Would you like to change your status from ...".  
Does anyone have any insight as to the best way to do that?


Thanks in advance.

___

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

Please do not post admin requests or moderator comments to the list.
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: Finder's sidebar background color

2008-11-15 Thread Knut Lorenzen


Am 15.11.2008 um 23:30 schrieb Kyle Sluder:

On Sat, Nov 15, 2008 at 5:06 PM, Knut Lorenzen <[EMAIL PROTECTED]>  
wrote:
I am afraid I was unclear, mimicing Finder (and it's ilk) only  
color-wise.


I'm still a bit confused... where will you be using this color?  This
is the color for source lists.  You should have a *very* good reason
for using it anywhere else (and thus cause your app to function
counter to user expectations).



Well, it is kind of a source list (a list of command descriptions). It  
is hard to explain in words, please take a look at the link to  
OnMyCommand I've posted earlier.


However, I do think it really fits its purpose :D

Cheers,

Knut



___

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

Please do not post admin requests or moderator comments to the list.
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 newbie question

2008-11-15 Thread Ken Thomases
So far, nobody that I've seen has pointed out the specific error in  
the code:


On Nov 10, 2008, at 9:00 PM, Michael wrote:


Fraction *myFraction;
myFraction= [Fraction alloc];
myFraction= [Fraction init];  /*  ???  */


You are calling init on the class Fraction, not on the instance that  
you've allocated.  The last line should have been written as:


myFraction = [myFraction init];

although, as mentioned, it's customary to always initialize the  
allocated instance within the same expression where it was allocated,  
with this pattern:


myFraction = [[Fraction alloc] init];

Cheers,
Ken

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Detecting in/activity

2008-11-15 Thread Michael Ash
On Sat, Nov 15, 2008 at 5:43 PM, Jacob Bandes-Storch <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'd like to have an app/daemon/something detect when the computer becomes
> active after a period of inactivity, much like iChat does when it says
> "Welcome back! Would you like to change your status from ...". Does anyone
> have any insight as to the best way to do that?

This mailing list post has code which illustrates how to get the
current system idle time from IOKit:

http://www.cocoabuilder.com/archive/message/cocoa/2004/10/27/120354

And the bottom of this page outlines how you could then use that
information to build a timer which will trigger after a set amount of
idle time has occurred:

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

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: Distributed Objects invocation dispatch not thread safe??

2008-11-15 Thread Dave Cox

I have since written and tested a 'peer' program in addition to the 
client/server pair I previously described.  I run serveral instances of this 
peer program.  Each peer is a server in the sense that it vends an object as 
the root of an NSConnection and runs several threads to accept remote calls on 
the connection.  Each peer is also a client of all the other peers: it runs a 
loop in which it tries to connect to any peer it is not yet connected to, and 
to invoke methods on the proxies of those it is connected to.  Thus, the peers 
end up connected many-to-many.  All peers invoke all the others, in random 
order, and each can receive invocations from several others concurrently.  
Also, when one peer calls another, the latter calls back to the first before it 
returns from the method invocation originating from the first.  (It calls a 
different method of the peer protocol so this doesn't end up recursing.)

Testing these peers has uncovered new console log warnings and crash patterns that don't 
seem related to over-releasing memory or using memory after it's released.  Instead, 
these seem related to managing "conversation" objects in a collection 
(CFDictionary).  These problems seem to occur specifically when some peers have been 
running for some time and another starts up and tries to join the group; that is, the 
crash occurs around the time the processes are establishing NSConnections to each other, 
and before the new peer receives (m)any invocations from the other peers.

I've only tested these on OSX 10.5.5.

Here's code, and following that some representative output and crash dumps.



// peer.mm

#import 
#import 
#import 
#import 
#import 
#import 
#import 
#import 
#import 
#import 

#import 
#import 
#import 

#import 

#import "log.h"


using namespace std;


#define PEER_NAME_BASE "TestPeer"


// peer interface
@protocol IPeer 
   - (unsigned) call: (id) cb;
   - (void) callBack;
@end

typedef id TPeer;


// peer class
@interface CPeer : NSObject  {}
@end


static int32_t nCalls = 0;
static int32_t nCallsBack = 0;


@implementation CPeer

- (unsigned) call: (id) cb {
   //log("call:\n");
   OSAtomicIncrement32(&nCalls);
   [cb callBack];
   return 1;
}

- (void) callBack {
   //log("callBack\n");
   OSAtomicIncrement32(&nCallsBack);
}

@end


bool quit = false;

void onSignal(int s) {
   log("onSignal\n");
   quit = true;
}


int main (int argc, char * const argv[]) {

   bool extraRelease = false;

   if (argc < 3) {
   log("not enough args\n");
   return 1;
   }

   char* sPeerId = argv[1];
   int peerId = atoi(sPeerId);
   if (peerId < 1) {
   log("invalid arg %s\n", argv[1]);
   return 1;
   }

   char* sNumPeers = argv[2];
   int numPeers = atoi(sNumPeers);
   if (numPeers < 2) {
   log("invalid arg %s\n", argv[2]);
   return 1;
   }

   log("peer %d of %d...\n", peerId, numPeers);

   if (argc > 3 && argv[3][0] == 'x') {
   extraRelease = true;
   }

   signal(SIGTERM, onSignal);
   signal(SIGINT, onSignal);

   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

   CPeer* me = nil;

   do {
   // vend peer object...

   NSPort* port = [[NSMachPort alloc] init];
   if (port == nil) {
   log("error: port is nil\n");
   break;
   }
   [port autorelease];

   NSConnection* connection
   = [NSConnection connectionWithReceivePort:port sendPort:nil];
   if (connection == nil) {
   log("error: connection is nil\n");
   break;
   }

   [connection enableMultipleThreads];

   // create peer object to vend
   me = [[CPeer alloc] init];
   if (me == nil) {
   log("error: peer to vend is nil\n");
   }
   [me autorelease];

   // vend object
   [connection setRootObject: me];

   // publish name (@PEER_NAME_BASE + peerId)
   NSString* localName = [NSString stringWithFormat: @"[EMAIL PROTECTED]",
 @PEER_NAME_BASE,
 peerId ];
   NSMachBootstrapServer* namesrv = [NSMachBootstrapServer sharedInstance];
   if ([namesrv registerPort: port name: localName] == NO) {
   log("error: port not registered\n");
   break;
   }

   // detach new threads to run runloops for the connection
   for (unsigned n = 0; n < 4; n++) {
   [connection runInNewThread];
   }

   vector peers(numPeers);

   srandomdev();

   // loop: call another peer...

   NSAutoreleasePool* innerPool = nil;

   while (!quit) {
   // choose a peer at random
   int nPeer = (int)(random() % numPeers) + 1;
   if (nPeer == peerId) {
   // that's me; try again
   continue;
   }

   if (innerPool != nil) {
   log("previous autorelease pool not relea

Remove '\n' char from NSString

2008-11-15 Thread Jordon Hirshon
Is there an NSString function that would remove all of the '\n' chars from an 
NSString?

I'm trying to concatenate all of the lines in a string into one gigantic line  
(about 5 unicode chars).

Jordon




  
___

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

Please do not post admin requests or moderator comments to the list.
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]


Configure a button added in IB

2008-11-15 Thread Mikael Wämundson

Am a quite a newbie to Cocoa programming.
Adding and configuring a button in IB is straightforward. I understand  
the process of setting action and target in IB and the connection to  
Xcode (IBOutlet and IBAction).
But what is the approach when creating a button in IB that I then want  
to configure (set title, image, enabled, etc.) in Xcode? How do I  
reach the button from Xcode?


wamund
___

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

Please do not post admin requests or moderator comments to the list.
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: Remove '\n' char from NSString

2008-11-15 Thread Steven Riggs
Something like [string stringByReplacingOccurrencesOfString:@"\n"  
withString:@" "] should do the trick


Adios!
Steven Riggs


On Nov 14, 2008, at 6:18 PM, Jordon Hirshon wrote:

Is there an NSString function that would remove all of the '\n'  
chars from an NSString?


I'm trying to concatenate all of the lines in a string into one  
gigantic line

(about 5 unicode chars).

Jordon





___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/steven.riggs%40me.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: Configure a button added in IB

2008-11-15 Thread Steven Riggs

To do it from code, add something like..
IBOutlet NSButton *theButton;
...to your .h

Instanitate your class in interface builder and then connect theButton  
to your button my control dragging from your class to the button.


and then use the documentation here: 
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSButton_Class/Reference/Reference.html

...to learn what kind of messages you can send to it.

ex.  [theButton setTitle:@"send steve money"];

:-)

Good luck,
 Steven Riggs

On Nov 15, 2008, at 7:04 PM, Mikael Wämundson wrote:


Am a quite a newbie to Cocoa programming.
Adding and configuring a button in IB is straightforward. I  
understand the process of setting action and target in IB and the  
connection to Xcode (IBOutlet and IBAction).
But what is the approach when creating a button in IB that I then  
want to configure (set title, image, enabled, etc.) in Xcode? How do  
I reach the button from Xcode?


wamund
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/steven.riggs%40me.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]


Playing around with BWToolKit

2008-11-15 Thread Dave DeLong

Hey everyone,

I've been playing around with Brandon's new BWToolKit, and I was  
wondering if there's any way to hook the ToolbarItems up through  
code.  I've got a window with four different sections, and I want to  
have some NSMenuItems that, when selected, will open the window to the  
appropriate section.


The closest I've come is to grab all the item identifiers and select  
them that way, but I was wondering if anyone's found a more robust way  
to do that.


Thanks,

Dave
___

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

Please do not post admin requests or moderator comments to the list.
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]


using copy in nested NSMutableArrays gives immutable objects?

2008-11-15 Thread Randy
In my program I have nested NSMutableArrays, i.e., each element in a  
root NSMutableArray is a NSMutableArray.


When I try to grab one of the element NSMutableArrays ..
NSMutableArray *copyOfCurrent = (NSMutableArray *) [[walkerArray  
objectAtIndex:lastNodeInCurrent] copy];//walkerArray is another  
NSMutableArray


As soon as I try to alter (insert an element for example)  
copyOfCurrent I get a "NSInternalInconsistencyException" with the  
message "mutating method sent to immutable object".  It looks like  
either the objectAtIndex or the copy method is providing something  
immutable, not an NSMutableArray.


Any idea why that might be happening?

I was able to get around the problem by creating a new NSMutableArray  
and loading into it the contents of the immutable one like ..


NSMutableArray *copyOfCurrent = (NSMutableArray *) [[walkerArray  
objectAtIndex:lastNodeInCurrent] copy];

NSMutableArray *fixError = [[NSMutableArray alloc] init];
int k;
for (k = 0; k < [copyOfCurrent count]; k++)
{
fixError[k] = copyOfCurrent[k];
}

But that seems hokey and I would like to understand the cause of the  
original issue.


Thanks;

Randy
___

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

Please do not post admin requests or moderator comments to the list.
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: using copy in nested NSMutableArrays gives immutable objects?

2008-11-15 Thread Nathan Kinsinger

On Nov 15, 2008, at 10:56 PM, Randy wrote:

In my program I have nested NSMutableArrays, i.e., each element in a  
root NSMutableArray is a NSMutableArray.


When I try to grab one of the element NSMutableArrays ..
NSMutableArray *copyOfCurrent = (NSMutableArray *) [[walkerArray  
objectAtIndex:lastNodeInCurrent] copy];//walkerArray is another  
NSMutableArray


As soon as I try to alter (insert an element for example)  
copyOfCurrent I get a "NSInternalInconsistencyException" with the  
message "mutating method sent to immutable object".  It looks like  
either the objectAtIndex or the copy method is providing something  
immutable, not an NSMutableArray.


Any idea why that might be happening?

I was able to get around the problem by creating a new  
NSMutableArray and loading into it the contents of the immutable one  
like ..


NSMutableArray *copyOfCurrent = (NSMutableArray *) [[walkerArray  
objectAtIndex:lastNodeInCurrent] copy];

NSMutableArray *fixError = [[NSMutableArray alloc] init];
int k;
for (k = 0; k < [copyOfCurrent count]; k++)
{
fixError[k] = copyOfCurrent[k];
}

But that seems hokey and I would like to understand the cause of the  
original issue.


Thanks;

Randy


-copy returns an immutable object (as you found out), -mutableCopy is  
what you want.


--Nathan
___

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

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

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

This email sent to [EMAIL PROTECTED]