Re: Create command from string

2008-12-01 Thread Bill Bumgarner

On Dec 1, 2008, at 8:52 PM, Luke the Hiesterman wrote:

parse string into commandString and argumentString then do:

SEL command = NSSelectorFromString(commandString);
[anObject performSelector:command withObject:argumentString];

If you're trying to execute a C function, then you could create  
class methods to wrap them.


Except, of course, that the above won't work if the functionality that  
John wants to access is not accessible as a method taking a single  
NSObject type (or subclass) argument on anObject.


Accessing straight C based API dynamically (like NSLog() -- as in the  
OP's example code) -- from an interpreted environment -- is, quite  
frankly, a pain in the butt.   At the least, you need to look up the  
symbol.   More complex, if the function requires arguments, you need  
to determine their types and how to encode them appropriately to  
create a call to said function.


Mac OS X offers two facilities to assist in this;  libffi and  
BridgeSupport.


Libffi is an open source bit of code that allows one to create  
something akin to a C function call site on the fly.


BridgeSupport offers a bunch of metadata as to the arguments and  
return types for most of the APIs on the system and is specifically  
targeted to providing metadata for API that is not fully described by  
the metadata found within the ObjC runtime.


The two are most oft used to providing bridging technologies like  
MacRuby, PyObjC, RubyCocoa, and Scripting Bridge.


But they aren't terribly easy to use.  Unless the goal is an open  
ended interface, one is generally better off providing a hardwired  
interface to a given API.


b.bum
___

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

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

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

This email sent to [EMAIL PROTECTED]


Xcode messes up my Log Files

2008-12-01 Thread Gerriet M. Denkmann

Whenever Xcode is running, I get hundreds of lines like:
02/12/2008 14:02:37 Xcode[451] Xcode(451,0xb0103000) malloc:  
free_garbage: garbage ptr = 0x3af12c0, has non-zero refcount = 1

in my Log Files (Console Messages).

I am ready to believe that this is something quite innocent and not to  
be worried about.


I might even be persuaded that logging these innocent messages is  
vitally important and that they really must be shown to every user.  
(Might take some persuading though).


Ok. So I did Console.app -> File -> New Log Database Query... and  
intended to do something like

"Show all messages where Sender is *not* equal to Xcode".
Somehow I could not do this.

But there is "Sender matches regex". As there are a lot of different  
regex syntaxes I turned to Help to teach me which rules are used by  
Console.app.

But, as I almost expected: "No Results Found".

So: can someone tell me how to get rid of these "malloc: free_garbage"  
lines?
It really makes it difficult to see the important console messages  
among all this garbage.



Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Viewing Documentation in Safari

2008-12-01 Thread Gerriet M. Denkmann


When I try to open the "String Programming Guide for Cocoa" in Safari,  
it tells me that:


“index.html” is a web application which was downloaded from the  
Internet. Are you sure you want to open it?


Xcode downloaded this file on 26 November 2008 from developer.apple.com.

First of all, I strongly doubt that this innocent html page is really  
a web application.
And secondly, I really get tired of seeing this panel over and over  
again, whenever I try to open any documentation on my computer.


Is there a way to get rid of this message?
Owner of these pages is _devdocs and others (like me) have not write  
rights; so if I open this page, the quarantine entry (in extended  
attributes) can not be cleared.
02/12/2008 14:00:14 kernel CoreServicesUIAg[] Unable to clear  
quarantine `index.html': 13



Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Time measurement

2008-12-01 Thread Rob Keniger


On 02/12/2008, at 5:08 PM, Daniel Luis dos Santos wrote:


Hello,

Not sure I should ask this here.

How do I get time measurements in milliseconds? What is the accuracy  
of the mac's C library implementation ?


I am using the clock() function from time.h and measuring  
differences in seconds between the trigering of a NSTimer.


The NSTimer fires every 0.1 secs, and in the event code I measure  
the difference between the current clock() call and the previous. I  
then divide it by the CLOCKS_PER_SEC constant and get two orders of  
magnitude difference than the interval in the timer. I get 0.001  
secs instead of the 0.1 of the NSTimer.


Any ideias ?


You can use the Microseconds() call to get microsecond-accurate  
timing. It's declared in CoreServices/Timer.h.


This page has some handy info on making use of it:

http://www.meandmark.com/timingpart2.html

--
Rob Keniger



___

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

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

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

This email sent to [EMAIL PROTECTED]


Time measurement

2008-12-01 Thread Daniel Luis dos Santos

Hello,

Not sure I should ask this here.

How do I get time measurements in milliseconds? What is the accuracy  
of the mac's C library implementation ?


I am using the clock() function from time.h and measuring differences  
in seconds between the trigering of a NSTimer.


The NSTimer fires every 0.1 secs, and in the event code I measure the  
difference between the current clock() call and the previous. I then  
divide it by the CLOCKS_PER_SEC constant and get two orders of  
magnitude difference than the interval in the timer. I get 0.001 secs  
instead of the 0.1 of the NSTimer.


Any ideias ?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: ???& ??? in ICARegisterForEventNotification Apple Code Sample

2008-12-01 Thread Andrew Farmer

On 01 Dec 08, at 21:54, Ron Fleckner wrote:

They are almost certainly un-rendered plain '&' tokens which Safari  
has failed to render properly or perhaps the html was incorrectly  
written.  The clue is that each of them have a semi-colon after  
them.  Have a look at the page's source code to check, but I think  
you could just remove the the word 'amp' and the semi-colon and it  
should compile.



There actually appear to be a number of errors in this page - the next  
example contains the line:


pb.deviceObject = <#ICAObject deviceObject#>;

which looks like an incomplete XCode template, and the example after  
that has:


pb.object = 1815C00; //device object ID

(Hexidecimal constants must begin with a 0x or 0X prefix, so this  
won't compile.)


File a bug on this one! It looks like it needs a bit of extra love.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Andre Masse
Thanks for the clarification Michael. One thing I'm discovering as I'm  
learning Cocoa is that it's easy to forget basic things. You set  
connections, bindings, data sources or delegates graphically between  
your objects in IB and when you run your application, all seems to  
work like "magic". You're left with the impression that if you set  
things, they will be "unset" somehow, somewhere using the same  
"magic". As you go further, you discover that the magic is no magic at  
all and the "magician" can't do it all by himself. You have to do some  
work to keep the illusion alive.


Cheers to all the people on this list! You're all helping me becoming  
a better Cocoa programmer...


Thanks,

Andre Masse


On Dec 1, 2008, at 23:59, Michael Ash wrote:


On Mon, Dec 1, 2008 at 2:54 PM, Jerry Krinock <[EMAIL PROTECTED]> wrote:


On 2008 Dec, 01, at 6:12, Jean-Daniel Dupas wrote:


- (void)dealloc {
  [_tableView setDataSource:nil];
  [_otherIVar setDelegate:nil];


According to [1], you need one more line of code here:
[tableView reloadData];


That document describes the scenario where you destroy your data
objects, not where you destroy the data source yourself. The call to
setDataSource: is sufficient, as it can no longer query you after that
point.

In general, you always need to clear any weak references to your
objects when they are deallocated. This is most well known for the
weak references you get from NSNotificationCenter, but it applies to
other weak references such as delegate and data source references as
well. For those you can often get away with not clearing them if they
end up getting deallocated at the same time, but as people are
discovering here, in some situations you can't count on that.

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: ???& ??? in ICARegisterForEventNotification Apple Code Sample

2008-12-01 Thread Ron Fleckner


On 02/12/2008, at 4:34 PM, M Pulis wrote:


Folks,

In the code below, from

http://developer.apple.com/documentation/Carbon/Conceptual/ImageCaptureServicesProgrammingGuide/03HowtoWriteanImageCaptureApplication/chapter_3_section_1.html#/ 
/apple_ref/doc/uid/TP40005196-CH4-SW1



In the calls CFArrayCreate and ICARegisterForEventNotification, the  
code uses a variable called "amp". What is "amp"? As it sits, the  
snippet does not compile, stumbling as I have, on "amp".


Thanks,

Gary


snip

/* Sample code snippet to illustrate the use of  
ICARegisterForEventNotification() */

 };

   CFMutableArrayRef  array = CFArrayCreate( kCFAllocatorDefault,  
(const void**)¬ificationsOfInterest, 12,  
&kCFTypeArrayCallBacks );


snip

   err = ICARegisterForEventNotification( &pb,  
registerForEventNotificationCallback );


   CFRelease( array );

   return err;

}


They are almost certainly un-rendered plain '&' tokens which Safari  
has failed to render properly or perhaps the html was incorrectly  
written.  The clue is that each of them have a semi-colon after them.   
Have a look at the page's source code to check, but I think you could  
just remove the the word 'amp' and the semi-colon and it should compile.


Ron
___

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

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

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

This email sent to [EMAIL PROTECTED]


???& ??? in ICARegisterForEventNotification Apple Code Sample

2008-12-01 Thread M Pulis

Folks,

In the code below, from

http://developer.apple.com/documentation/Carbon/Conceptual/ 
ImageCaptureServicesProgrammingGuide/ 
03HowtoWriteanImageCaptureApplication/chapter_3_section_1.html#// 
apple_ref/doc/uid/TP40005196-CH4-SW1



In the calls CFArrayCreate and ICARegisterForEventNotification, the  
code uses a variable called "amp". What is "amp"? As it sits, the  
snippet does not compile, stumbling as I have, on "amp".


Thanks,

Gary





/* Sample code snippet to illustrate the use of  
ICARegisterForEventNotification() */


OSErr registerForNotifications()

{

OSErr  err = noErr;

ICARegisterForEventNotificationPB  pb = {};

CFStringRefnotificationsOfInterest[]  = {

  k 
ICANotificationTypeDeviceRemoved,


  k 
ICANotificationTypeDeviceInfoChanged,


  k 
ICANotificationTypeDeviceWasReset,


  k 
ICANotificationTypeCaptureComplete,


  k 
ICANotificationTypeTransactionCanceled,


  k 
ICANotificationTypeStoreAdded,


  k 
ICANotificationTypeStoreRemoved,


  k 
ICANotificationTypeStoreFull,


  k 
ICANotificationTypeStoreInfoChanged,


  k 
ICANotificationTypeObjectAdded,


  k 
ICANotificationTypeObjectRemoved,


  k 
ICANotificationTypeObjectInfoChanged


};

CFMutableArrayRef  array = CFArrayCreate( kCFAllocatorDefault,  
(const void**)¬ificationsOfInterest, 12,  
&kCFTypeArrayCallBacks );


pb.header.refcon= (long)self;

pb.objectOfInterest = <#ICAObject object#>

/* valid values are 0, device list object, or device object. 0 gets  
notifications related to any object. */


pb.eventsOfInterest = (CFArrayRef)array;

pb.notificationProc = notificationCallback;

pb.options  = NULL;

err = ICARegisterForEventNotification( &pb,  
registerForEventNotificationCallback );


CFRelease( array );

return err;

}
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Textual representation of an NSData?

2008-12-01 Thread Stephen J. Butler
On Mon, Dec 1, 2008 at 11:02 PM, Michael Ash <[EMAIL PROTECTED]> wrote:
> On Mon, Dec 1, 2008 at 11:04 PM, Stephen J. Butler
> <[EMAIL PROTECTED]> wrote:
>> Really, don't encode it in your binary. Especially bad idea on an
>> embedded platform like the iPhone because they you're carrying around
>> the image data in memory whether you're currently using the image or
>> not. It's dead weight.
>
> I would have thought that the iPhone would memory map application
> binaries just like its big brother does, which will end up using zero
> memory if the data isn't being actively used. Is that not the case?

Grumble, grumble... all right, you caught me.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Create command from string

2008-12-01 Thread Jay Reynolds Freeman

If the command you seek can be accomplished by a Unix shell, you
can always create a string and then call the Unix "system"
function to perform it.  This approach has perils, however.

--  Jay Reynolds Freeman
-
[EMAIL PROTECTED]
http://web.mac.com/jay_reynolds_freeman (personal web site)


On Dec 1, 2008, at 8:40 PM, John Murphy wrote:

How do I do execute a command expression from a string?
e.g.,
NSString *string = [NSString stringWithFormat:@"NSLog(@\"hello\");"];

Now what?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Textual representation of an NSData?

2008-12-01 Thread Michael Ash
On Mon, Dec 1, 2008 at 11:04 PM, Stephen J. Butler
<[EMAIL PROTECTED]> wrote:
> Really, don't encode it in your binary. Especially bad idea on an
> embedded platform like the iPhone because they you're carrying around
> the image data in memory whether you're currently using the image or
> not. It's dead weight.

I would have thought that the iPhone would memory map application
binaries just like its big brother does, which will end up using zero
memory if the data isn't being actively used. Is that not the case?

For embedding data in a binary, the 'xxd -i' command will spit out a
nice C header file declaring a bytes and length variable. It's trivial
to incorporate that command as part of your Xcode build process using
a shell script build phase, so that you can keep the file separate in
your project but build it directly into the binary at compile time.

Most of the time I'd agree that you should just keep the data in a
separate file, but sometimes it can be useful to bake the stuff right
into the code.

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: Crash when closing window from the menu

2008-12-01 Thread Michael Ash
On Mon, Dec 1, 2008 at 2:54 PM, Jerry Krinock <[EMAIL PROTECTED]> wrote:
>
> On 2008 Dec, 01, at 6:12, Jean-Daniel Dupas wrote:
>
>> - (void)dealloc {
>>[_tableView setDataSource:nil];
>>[_otherIVar setDelegate:nil];
>
> According to [1], you need one more line of code here:
>  [tableView reloadData];

That document describes the scenario where you destroy your data
objects, not where you destroy the data source yourself. The call to
setDataSource: is sufficient, as it can no longer query you after that
point.

In general, you always need to clear any weak references to your
objects when they are deallocated. This is most well known for the
weak references you get from NSNotificationCenter, but it applies to
other weak references such as delegate and data source references as
well. For those you can often get away with not clearing them if they
end up getting deallocated at the same time, but as people are
discovering here, in some situations you can't count on that.

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: Create command from string

2008-12-01 Thread Luke the Hiesterman

parse string into commandString and argumentString then do:

SEL command = NSSelectorFromString(commandString);
[anObject performSelector:command withObject:argumentString];

If you're trying to execute a C function, then you could create class  
methods to wrap them.


Luke


On Dec 1, 2008, at 8:40 PM, John Murphy wrote:


How do I do execute a command expression from a string?
e.g.,
NSString *string = [NSString stringWithFormat:@"NSLog(@\"hello\");"];

Now what?




___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Create command from string

2008-12-01 Thread Bill Bumgarner

On Dec 1, 2008, at 8:40 PM, John Murphy wrote:

How do I do execute a command expression from a string?
e.g.,
NSString *string = [NSString stringWithFormat:@"NSLog(@\"hello\");"];

Now what?


Generally, you don't.

At least, not on a user system.

On a system with developer tools, you could fire up the C compiler and  
linker, compile the code, dynamically link, it then call into it  
(discounting about a bazillion details along that route).


What problem are you trying to solve, exactly?

b.bum
___

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

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

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

This email sent to [EMAIL PROTECTED]


Create command from string

2008-12-01 Thread John Murphy
How do I do execute a command expression from a string?
e.g., 
NSString *string = [NSString stringWithFormat:@"NSLog(@\"hello\");"]; 

Now what?


  

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Textual representation of an NSData?

2008-12-01 Thread Stephen J. Butler
On Mon, Dec 1, 2008 at 9:46 PM, Dave DeLong <[EMAIL PROTECTED]> wrote:
> I've got some NSData objects that I'd like to hard code into a file (they're
> encoded images for some example factory methods).  The reason I need to hard
> code them is that I need to be able to reconstruct these images on both the
> Mac and the iPhone, and I thought that getting the TIFFRepresentation of the
> 32x32 version and then some how hard coding it into my factory class would
> be "simplest".
>
> If possible, I'd like to avoid compiling in image files, because in the
> future I'm planning on being able to accept any image encoded into an NSData
> (ones that won't be hard coded), and I'd like to have the built-in presets
> follow the same format.
>
> I've written a little app to take the bytes of an NSData and convert them
> into a hexadecimal string, using the code found here:
> http://www.cocoabuilder.com/archive/message/cocoa/2007/11/29/194188 , but
> I'm at a bit of a loss on how to reconstruct the NSData from the hex string.

Hey, that's me!

If you really, truly, honestly have your heart set on this method of
image storage (which I think is a bad idea) you want something like
this (file)global variable:

char imageBytes[] = { 0x00, 0x01, 0xA0, 0x10, ... };
NSUInteger imageBytesLength = 12345;

Then you would make it into an NSData again as such:

NSData *imageData = [NSData dataWithBytesNoCopy:imageBytes
length:imageBytesLength freeWhenDone:NO];

But at that point, it doesn't look much different than the proper,
accepted way of doing things (stealing from Jim Correia):

NSString *imagePath = [[NSBundle mainBundle] pathForResource:
@"MyImage" ofType: @"tiff"];
NSData *imageData = [NSData dataWithContentsOfFile:imagePath];

Really, don't encode it in your binary. Especially bad idea on an
embedded platform like the iPhone because they you're carrying around
the image data in memory whether you're currently using the image or
not. It's dead weight.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Textual representation of an NSData?

2008-12-01 Thread Jim Correia

On Dec 1, 2008, at 10:46 PM, Dave DeLong wrote:

I've got some NSData objects that I'd like to hard code into a file  
(they're encoded images for some example factory methods).  The  
reason I need to hard code them is that I need to be able to  
reconstruct these images on both the Mac and the iPhone, and I  
thought that getting the TIFFRepresentation of the 32x32 version and  
then some how hard coding it into my factory class would be  
"simplest".


If possible, I'd like to avoid compiling in image files, because in  
the future I'm planning on being able to accept any image encoded  
into an NSData (ones that won't be hard coded), and I'd like to have  
the built-in presets follow the same format.


Trying to represent a large binary object as a constant string in your  
source code strikes me as a bad idea. It strikes me as a really bad  
idea when there are better alternatives.


If you want NSData to be the lingua franca in your class design, I'd  
still go with a bundle resource and use something such as (written in  
mail, caveat emptor):


+ (NSData *)factoryImageData
{
	NSString *path = [[NSBundle mainBundle] pathForResource: @"MyImage"  
ofType: @"tiff"];

return [NSData dataWithContentsOfFile: path];
}

Jim

___

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

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

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

This email sent to [EMAIL PROTECTED]


Textual representation of an NSData?

2008-12-01 Thread Dave DeLong

Hey everyone,

I've got some NSData objects that I'd like to hard code into a file  
(they're encoded images for some example factory methods).  The reason  
I need to hard code them is that I need to be able to reconstruct  
these images on both the Mac and the iPhone, and I thought that  
getting the TIFFRepresentation of the 32x32 version and then some how  
hard coding it into my factory class would be "simplest".


If possible, I'd like to avoid compiling in image files, because in  
the future I'm planning on being able to accept any image encoded into  
an NSData (ones that won't be hard coded), and I'd like to have the  
built-in presets follow the same format.


I've written a little app to take the bytes of an NSData and convert  
them into a hexadecimal string, using the code found here: http://www.cocoabuilder.com/archive/message/cocoa/2007/11/29/194188 
 , but I'm at a bit of a loss on how to reconstruct the NSData from  
the hex string.


Any thoughts?

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]


Re: best way to add transitions

2008-12-01 Thread M Pulis

Thanks, Matt,

The pointers are appreciated.

Gary


On Dec 1, 2008, at 7:57 PM, Matt Long wrote:


Gary,

I haven't used IKImageView, however, it does implement the  
NSAnimatablePropertyContainer protocol:


http://developer.apple.com/documentation/Cocoa/Reference/ 
NSAnimatablePropertyContainer_protocol/Introduction/ 
Introduction.html#//apple_ref/occ/intf/NSAnimatablePropertyContainer


This means that you can set its transition animation for a key you  
specify. Most notably, the key you want is 'subviews' (I believe).  
Try something like this:


[imageView setAnimations: [NSDictionary  
dictionaryWithObjectsAndKeys:transition, @"subviews", nil]];


Where 'transition' is a CATransition animation. Something like this:

CATransition *transition=[CATransition animation];
[transition setType:kCATransitionFade];
[transition setSubtype:kCATransitionFromTop];
[transition setDuration:1.0f];

If you don't need to do it in code, you can also select a  
transition using Interface Builder. Just click on your IKImageView  
view in IB and select the "Effects" tab in the inspector. At the  
bottom you'll see a segment called "Transitions". Select "Custom"  
and in the Subview drop down, then select "Fade" for the Type.


HTH,

-Matt


On Dec 1, 2008, at 7:54 AM, M Pulis wrote:


Hello Cocoa folk,

My app uses an IKImageView in its main window. Until the user  
engages some function, the IK view sequentially displays slides  
prompting the user to become involved, a typical attract mode.


What is now requested is a transition such as fade (or any of the  
variety of transitions) instead. From reading about views, layers  
and transitions (oh my!), I am seeing more trees than forest


What is the best approach to add transitions to an IKImageView? An  
outline should do, I ought to be able to figure out the calls by now.


Thanks!

Gary


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Custom NSSlider?

2008-12-01 Thread Jean-Nicolas Jolivet

huh, nevermind, it was actually a stupid mistake on my end...

I connected the slider to the sliderEnded action instead of  
sliderMoved (it's weird Im sure I double-checked...) anyway  It's  
working now! thanks a lot


J-N

On 1-Dec-08, at 10:06 PM, Jean-Nicolas Jolivet wrote:

Yup, still getting them, I also tried to move the 3 lines at the  
beginning of the sliderMoved method, still no luck...apparently it's  
not the binding thats keeping it from working I guess?


J-N

On 1-Dec-08, at 10:00 PM, James Walker wrote:


Jean-Nicolas Jolivet wrote:
Thanks for the info, I found the piece of code you were referring  
to, but somehow I can't get it to work... here's my code:

- (IBAction)sliderMoved:(id)sender {
  SEL trackingEndedSelector = @selector(sliderEnded:);
  [NSObject cancelPreviousPerformRequestsWithTarget:self

selector:trackingEndedSelector object:sender];

  [self performSelector:trackingEndedSelector withObject:sender
 afterDelay:0.0];
  // do whatever you want to do during tracking here
  [self willChangeValueForKey:@"imageContrast"];
  imageContrast = [sender doubleValue];
  [self didChangeValueForKey:@"imageContrast"];
}
- (void)sliderEnded:(id)sender {
  // do whatever you want to do when tracking ends here
  NSLog(@"Done tracking");
  }
My label is bound to imageContrast so that it is updated live  
right now I'm only trying to log a message when the tracking is  
done... my slider is connected to the sliderMoved action... did I  
do anything wrong? Right now when I move the slider I get a ton of  
"Done tracking" messages in the console, and my label is never  
updated.. which is... well, almost the opposite of what should  
happen


This trick works for me, but I have not combined it with bindings.   
What happens if you comment out the 3 lines that are updating  
imageContrast, do you still get "Done tracking" messages during  
tracking?

--
James W. Walker, Innoventive Software LLC



Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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/silvertab%40videotron.ca

This email sent to [EMAIL PROTECTED]


Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Custom NSSlider?

2008-12-01 Thread Jean-Nicolas Jolivet
Yup, still getting them, I also tried to move the 3 lines at the  
beginning of the sliderMoved method, still no luck...apparently it's  
not the binding thats keeping it from working I guess?


J-N

On 1-Dec-08, at 10:00 PM, James Walker wrote:


Jean-Nicolas Jolivet wrote:
Thanks for the info, I found the piece of code you were referring  
to, but somehow I can't get it to work... here's my code:

- (IBAction)sliderMoved:(id)sender {
   SEL trackingEndedSelector = @selector(sliderEnded:);
   [NSObject cancelPreviousPerformRequestsWithTarget:self
 
selector:trackingEndedSelector object:sender];

   [self performSelector:trackingEndedSelector withObject:sender
  afterDelay:0.0];
   // do whatever you want to do during tracking here
   [self willChangeValueForKey:@"imageContrast"];
   imageContrast = [sender doubleValue];
   [self didChangeValueForKey:@"imageContrast"];
}
- (void)sliderEnded:(id)sender {
   // do whatever you want to do when tracking ends here
   NSLog(@"Done tracking");
   }
My label is bound to imageContrast so that it is updated live  
right now I'm only trying to log a message when the tracking is  
done... my slider is connected to the sliderMoved action... did I  
do anything wrong? Right now when I move the slider I get a ton of  
"Done tracking" messages in the console, and my label is never  
updated.. which is... well, almost the opposite of what should  
happen


This trick works for me, but I have not combined it with bindings.   
What happens if you comment out the 3 lines that are updating  
imageContrast, do you still get "Done tracking" messages during  
tracking?

--
 James W. Walker, Innoventive Software LLC
 


Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Custom NSSlider?

2008-12-01 Thread James Walker

Jean-Nicolas Jolivet wrote:
Thanks for the info, I found the piece of code you were referring to, 
but somehow I can't get it to work... here's my code:


- (IBAction)sliderMoved:(id)sender {
SEL trackingEndedSelector = @selector(sliderEnded:);
[NSObject cancelPreviousPerformRequestsWithTarget:self
 
selector:trackingEndedSelector object:sender];

[self performSelector:trackingEndedSelector withObject:sender

   afterDelay:0.0];

// do whatever you want to do during tracking here

[self willChangeValueForKey:@"imageContrast"];
imageContrast = [sender doubleValue];
[self didChangeValueForKey:@"imageContrast"];
}

- (void)sliderEnded:(id)sender {
// do whatever you want to do when tracking ends here
NSLog(@"Done tracking");

}



My label is bound to imageContrast so that it is updated live right 
now I'm only trying to log a message when the tracking is done... my 
slider is connected to the sliderMoved action... did I do anything 
wrong? Right now when I move the slider I get a ton of "Done tracking" 
messages in the console, and my label is never updated.. which is... 
well, almost the opposite of what should happen


This trick works for me, but I have not combined it with bindings.  What 
happens if you comment out the 3 lines that are updating imageContrast, 
do you still get "Done tracking" messages during tracking?

--
  James W. Walker, Innoventive Software LLC
  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: best way to add transitions

2008-12-01 Thread Matt Long

Gary,

I haven't used IKImageView, however, it does implement the  
NSAnimatablePropertyContainer protocol:


http://developer.apple.com/documentation/Cocoa/Reference/NSAnimatablePropertyContainer_protocol/Introduction/Introduction.html#/ 
/apple_ref/occ/intf/NSAnimatablePropertyContainer


This means that you can set its transition animation for a key you  
specify. Most notably, the key you want is 'subviews' (I believe). Try  
something like this:


[imageView setAnimations: [NSDictionary  
dictionaryWithObjectsAndKeys:transition, @"subviews", nil]];


Where 'transition' is a CATransition animation. Something like this:

CATransition *transition=[CATransition animation];
[transition setType:kCATransitionFade];
[transition setSubtype:kCATransitionFromTop];
[transition setDuration:1.0f];

If you don't need to do it in code, you can also select a transition  
using Interface Builder. Just click on your IKImageView view in IB and  
select the "Effects" tab in the inspector. At the bottom you'll see a  
segment called "Transitions". Select "Custom" and in the Subview drop  
down, then select "Fade" for the Type.


HTH,

-Matt


On Dec 1, 2008, at 7:54 AM, M Pulis wrote:


Hello Cocoa folk,

My app uses an IKImageView in its main window. Until the user  
engages some function, the IK view sequentially displays slides  
prompting the user to become involved, a typical attract mode.


What is now requested is a transition such as fade (or any of the  
variety of transitions) instead. From reading about views, layers  
and transitions (oh my!), I am seeing more trees than forest


What is the best approach to add transitions to an IKImageView? An  
outline should do, I ought to be able to figure out the calls by now.


Thanks!

Gary

___

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

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

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

This email sent to [EMAIL PROTECTED]


UIImageView drawRect not called

2008-12-01 Thread DKJ
I have a subclass of UIImageView, MySubView, which is instantiated and  
added as a subview in the viewDidLoad method of a UIViewController.  
MySubView displays a picture without difficulty when its image  
property is set in its initWithFrame method. But its drawRect method  
is never called. (I put an NSLog call inside it to check.) I've tried  
sending MySubView setNeedsDisplay messages from all kinds of places,  
to no avail.


I suspect I'm missing something very simple. Any advice would be  
appreciated.


dkj
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Custom NSSlider?

2008-12-01 Thread Jean-Nicolas Jolivet
Thanks for the info, I found the piece of code you were referring to,  
but somehow I can't get it to work... here's my code:


- (IBAction)sliderMoved:(id)sender {
SEL trackingEndedSelector = @selector(sliderEnded:);
[NSObject cancelPreviousPerformRequestsWithTarget:self

 selector:trackingEndedSelector object:sender];

[self performSelector:trackingEndedSelector withObject:sender
   afterDelay:0.0];

// do whatever you want to do during tracking here
[self willChangeValueForKey:@"imageContrast"];
imageContrast = [sender doubleValue];
[self didChangeValueForKey:@"imageContrast"];
}

- (void)sliderEnded:(id)sender {
// do whatever you want to do when tracking ends here
NSLog(@"Done tracking");

}


My label is bound to imageContrast so that it is updated live  
right now I'm only trying to log a message when the tracking is  
done... my slider is connected to the sliderMoved action... did I do  
anything wrong? Right now when I move the slider I get a ton of "Done  
tracking" messages in the console, and my label is never updated..  
which is... well, almost the opposite of what should happen


J-N

On 1-Dec-08, at 7:50 PM, James Walker wrote:


Jean-Nicolas Jolivet wrote:
I was wondering if its possible to have an NSSlider send an action  
after the user finished dragging, while still providing continuous  
updates?


Look in the archives for the October thread named "notification of  
NSSlider end of tracking".


--
 James W. Walker, Innoventive Software LLC
 


Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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]


Shouldn't NSOpenPanel media browser aliases be resolved before type check?

2008-12-01 Thread Nathan Vander Wilt
My Leopard-only application needs to be able to import any image  
supported by CGImageSource, so I create an NSOpenPanel and pass the  
array obtained from CGImageSourceCopyTypeIdentifiers() to  
runModalForTypes. This makes the "Media > Photos" sidebar to show up  
automatically in the Open panel, which is great.


However, seemingly random pictures in the iPhoto section of this Media  
Browser are greyed out. I tracked it down, and the problem is that  
when iPhoto creates an alias to an original file, this is not  
automatically resolved. (My OpenPanel does leave -resolvesAliases set  
to YES.) So the type of these random pictures is com.apple.alias-file  
instead of public.jpeg or any other image format, and the media panel  
doesn't let me choose these original files even though their aliases  
would resolve to supported types.


Shouldn't these aliases be resolved before type checking, so that the  
CGImageSource type identifiers can be used in an open panel without  
needing custom delegate filtering?


thanks,
-natevw

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread Peter Ammon


On Dec 1, 2008, at 2:17 PM, Keith Blount wrote:


Hi,

Many thanks for the reply.



If you implement menuHasKeyEquivalent:, then the menu does
not get populated for matching key equivalents; NSMenu
assumes that your code does not need it to be populated.
This puts the onus of supporting user key equivalents on the
app itself, and since there's no easy way for an app to
implement this, implementing menuHasKeyEquivalent: is not a
good idea unless the menu has custom KE handling or should
never have a KE.


I haven't found this a problem with anything except the dynamically- 
created items. Everything else works fine with keyboard shortcuts  
that are defined in the System Preferences.


Yes, NSMenu is a little schizophrenic about this.  If you implement  
menuHasKeyEquivalent:, then we will not populate the menu for key  
equivalent matching; however, if you insert menu items into the menu  
(either in menuNeedsUpdate: triggered by opening, or at another time)  
then KEs that you assign to the menu item may still be respected.



There's no reason why this should be slow.  Have you
tried profiling it with Shark?  Where is its spending its
time?

Perhaps you are completely rebuilding the menu every call
to menuNeedsUpdate:.  The menu state is not disturbed
between calls to menuNeedsUpdate:, so you can detect if the
user has added or deleted a style since the last update, and
if not, you do not need to do anything in menuNeedsUpdate:.


The trouble is that the styles were just an example. The application  
is quite a big one, and there are a good number of menus that get  
dynamically created - several of which are very likely to have  
changed between calls to -menuNeedsUpdate:. For instance, my  
application has a "Create Link to Document" submenu, which provides  
a list of documents in the application's source list so that the  
user can create links between documents. Given that the onus of the  
app is on structuring and moving documents around, the order and  
structure of this submenu is likely to change a lot. If I checked  
for every instance of a change in state to these menus, I'd have an  
awful lot of state-checking going on. And even with this state- 
change checking, it would still be slower. From my understanding and  
tests it seems that if -menuHasKeyEquivalent... isn't implemented,  
then every time a key combo is hit, the app populates all the menus  
and looks through them for the command
matching the key equivalent. This gets incredibly slow when menus  
are being built dynamically - and so in my app, even with state- 
change checking, there would be many occasions when certain menus  
need rebuilding and thus key presses would become slower.


Sorry, that was a bit long-winded. I hope that makes sense.

The problem seems to be when the dynamic menus get built, preventing  
system shortcuts from affecting them...



It's not quite as bad as "all the menus are populated for every key  
combo."  What is supposed to happen is, the first time a key combo is  
hit, menus are populated starting from the right until a match is  
found.  But it also remembers the KEs for each menu, and when a  
remembered KE is hit, it first populates the menu that it was last  
found in.  The only time it will routinely populate every menu is if a  
key equivalent is not found, and users normally don't care about the  
performance of unmatched key equivalents.  If you're seeing different  
behavior, it would be worthwhile to investigate why.


In any case, your description makes sense, but now I'm not sure what  
behavior you want.  In order to know if a menu has a user key  
equivalent, we need to construct the menu, which means populating it;  
if the menu is slow to construct then determining user key equivalents  
is necessarily slow as well.  Absent more information, I have two  
suggestions, both of which depend on speeding up menuNeedsUpdate:


1) When you construct the menu, you can ask each item for its user key  
equivalent, and cache that keyed by title.  When populating a menu for  
key equivalent matching, you can elide items that you previously found  
to have no user key equivalent.
2) Depending on the reason for the slow menu construction, you may be  
able to do less work for calls to menuNeedsUpdate: triggered for user  
key equivalents, such as avoiding loading icons.  I think checking to  
see if the call occurs between NSMenuDidBeginTracking and  
NSMenuDidEndTracking notifications should help there.


-Peter

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Custom NSSlider?

2008-12-01 Thread James Walker

Jean-Nicolas Jolivet wrote:
I was wondering if its possible to have an NSSlider send an action after 
the user finished dragging, while still providing continuous updates?


Look in the archives for the October thread named "notification of 
NSSlider end of tracking".


--
  James W. Walker, Innoventive Software LLC
  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Custom NSSlider?

2008-12-01 Thread Kevin Gessner
What if you handle the label via bindings, but your long process via  
the target/action? Then you could use -[NSSlider sendActionOn:]  
(inherited from NSControl) with NSLeftMouseUpMask to only send the  
action on drag end. It seems like this would work for a slider, though  
I'm not sure if the bindings update would be affected by this setting.


HTH,
-- Kevin

Kevin Gessner
http://kevingessner.com
[EMAIL PROTECTED]





On Dec 1, 2008, at 7:34 PM, Jean-Nicolas Jolivet wrote:

I was wondering if its possible to have an NSSlider send an action  
after the user finished dragging, while still providing continuous  
updates?


The thing is, when the slider value changes, there's a considerably  
long process that will take place so I can't set my slider to  
continuous, but I would like to provide a continuous update of the  
UI (i.e. the label that displays the slider value)...


I'm guessing I will probably have to subclass but even then I'm not  
really sure where to start??


Any info would be appreciated...

Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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/kevin%40kevingessner.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]


Custom NSSlider?

2008-12-01 Thread Jean-Nicolas Jolivet
I was wondering if its possible to have an NSSlider send an action  
after the user finished dragging, while still providing continuous  
updates?


The thing is, when the slider value changes, there's a considerably  
long process that will take place so I can't set my slider to  
continuous, but I would like to provide a continuous update of the UI  
(i.e. the label that displays the slider value)...


I'm guessing I will probably have to subclass but even then I'm not  
really sure where to start??


Any info would be appreciated...

Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Crash when closing window from the menu

2008-12-01 Thread Andre Masse

Many thanks for the links! Very valuable reads!

So far so good, no more crashes :-)

Thanks again,

Andre Masse


On Dec 1, 2008, at 14:54, Jerry Krinock wrote:


According to [1], you need one more line of code here:
 [tableView reloadData];


// other dealloc stuff
[super dealloc];
}



Also, note that the behavior causing the crash was changed in  
Leopard and is explained some in the Leopard AppKit Release Notes [2].


Let us know if you learn anything interesting, because by following  
these recommendations I've got my app to not crash 99% of the time.


Jerry

1.  http://developer.apple.com/documentation/Cocoa/Conceptual/OutlineView/Articles/UsingOutlineDataSource.html#/ 
/apple_ref/doc/uid/2725.  See section "The Data Source and  
Memory Management".


2.  http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSTableView 
.  See section "New Behavior in NSWindowController at Window Closing  
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: Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread Keith Blount
Many thanks for your reply. I'm actually rebuilding them anew each time, so 
this doesn't solve it, though I did try your suggestion of resetting the key 
equivalent just in case it would help... But no joy.

Thanks and all the best,
Keith


--- On Mon, 12/1/08, I. Savant <[EMAIL PROTECTED]> wrote:

> From: I. Savant <[EMAIL PROTECTED]>
> Subject: Re: Rebuilding menus (menuNeedsUpdate:) and System Preferences 
> keyboard shortcuts.
> To: [EMAIL PROTECTED]
> Cc: cocoa-dev@lists.apple.com
> Date: Monday, December 1, 2008, 9:37 PM
> On Mon, Dec 1, 2008 at 4:36 PM, I. Savant
> <[EMAIL PROTECTED]> wrote:
> 
> >  I've noticed a bug where calling -[NSMenuItem
> setKeyEquivalent:]
> > does not update unless you first set it to
> @"" then to the target. I
> > don't believe I remembered to file this with Apple
> ...
> 
>   I say this like it is most definitely your problem, but I
> should
> mention that *if* you're merely changing existing
> items, this is a
> problem. If you're entirely rebuilding things, it
> probably isn't. :-)
> 
> --
> I.S.


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread Keith Blount
Hi,

Many thanks for the reply.

> 
> If you implement menuHasKeyEquivalent:, then the menu does
> not get populated for matching key equivalents; NSMenu
> assumes that your code does not need it to be populated. 
> This puts the onus of supporting user key equivalents on the
> app itself, and since there's no easy way for an app to
> implement this, implementing menuHasKeyEquivalent: is not a
> good idea unless the menu has custom KE handling or should
> never have a KE.

I haven't found this a problem with anything except the dynamically-created 
items. Everything else works fine with keyboard shortcuts that are defined in 
the System Preferences.

> There's no reason why this should be slow.  Have you
> tried profiling it with Shark?  Where is its spending its
> time?
> 
> Perhaps you are completely rebuilding the menu every call
> to menuNeedsUpdate:.  The menu state is not disturbed
> between calls to menuNeedsUpdate:, so you can detect if the
> user has added or deleted a style since the last update, and
> if not, you do not need to do anything in menuNeedsUpdate:.

The trouble is that the styles were just an example. The application is quite a 
big one, and there are a good number of menus that get dynamically created - 
several of which are very likely to have changed between calls to 
-menuNeedsUpdate:. For instance, my application has a "Create Link to Document" 
submenu, which provides a list of documents in the application's source list so 
that the user can create links between documents. Given that the onus of the 
app is on structuring and moving documents around, the order and structure of 
this submenu is likely to change a lot. If I checked for every instance of a 
change in state to these menus, I'd have an awful lot of state-checking going 
on. And even with this state-change checking, it would still be slower. From my 
understanding and tests it seems that if -menuHasKeyEquivalent... isn't 
implemented, then every time a key combo is hit, the app populates all the 
menus and looks through them for the command
 matching the key equivalent. This gets incredibly slow when menus are being 
built dynamically - and so in my app, even with state-change checking, there 
would be many occasions when certain menus need rebuilding and thus key presses 
would become slower.

Sorry, that was a bit long-winded. I hope that makes sense.

The problem seems to be when the dynamic menus get built, preventing system 
shortcuts from affecting them...

Thanks again and all the best,
Keith


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread Peter Ammon


On Dec 1, 2008, at 12:49 PM, Keith Blount wrote:


Hi,

My application has several menus that get built dynamically,  
depending on user settings. For instance, there is a "Styles" menu,  
which lists styles the user has defined, and a "Script Elements"  
menu, which again, provides a list of user-defined options that  
apply a certain format to a range of text.


However, it seems that dynamically-built menus have a problem when  
it comes to keyboard shortcuts defined via the System Preferences -  
as in, the keyboard shortcuts don't always work.


At first I thought the solution was obvious: I was building these  
menus as needed, in the NSMenu delegate method, -menuNeedsUpdate:  
This method only gets called when the user goes to look at the menu.  
So, if these dynamic menus were only built in -menuNeedsUpdate:,  
then clearly the keyboard shortcuts defined in System Preferences  
for any items in such menus would note work until after the user had  
opened the menu at least once (thus populating it in - 
menuNeedsUpdate: and allowing the defined shortcut actually to apply  
to something, because before this the menu wouldn't have existed).




If you implement menuHasKeyEquivalent:, then the menu does not get  
populated for matching key equivalents; NSMenu assumes that your code  
does not need it to be populated.  This puts the onus of supporting  
user key equivalents on the app itself, and since there's no easy way  
for an app to implement this, implementing menuHasKeyEquivalent: is  
not a good idea unless the menu has custom KE handling or should never  
have a KE.


My solution was to build these menus whenever the user settings  
changed. So, if the user added or deleted a style, the menu would  
get rebuilt, as well as rebuilding it in -menuNeedsUpdate:. However,  
this still doesn't seem reliable. When opening another window, the  
keyboard shortcuts defined via System Preferences still don't  
operate in the new window until after the menu has been opened - and  
yet NSLogging shows that the menu is getting built before this and  
even seems to have a keyboard shortcut attached... Very strange.


So, my question: what is the best way of building menus dynamically  
whilst ensuring that any keyboard shortcuts defined in System  
Preferences will catch them and apply to them?


I am implementing -menuHasKeyEquivalent:... and returning NO. It  
seems that if I don't implement this method, then keyboard shortcuts  
work for dynamically built methods... But not implementing this  
method makes all the keyboard shortcuts in my app work very, very  
slowly, so leaving it out isn't an option...


There's no reason why this should be slow.  Have you tried profiling  
it with Shark?  Where is its spending its time?


Perhaps you are completely rebuilding the menu every call to  
menuNeedsUpdate:.  The menu state is not disturbed between calls to  
menuNeedsUpdate:, so you can detect if the user has added or deleted a  
style since the last update, and if not, you do not need to do  
anything in menuNeedsUpdate:.


-Peter

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread I. Savant
On Mon, Dec 1, 2008 at 4:36 PM, I. Savant <[EMAIL PROTECTED]> wrote:

>  I've noticed a bug where calling -[NSMenuItem setKeyEquivalent:]
> does not update unless you first set it to @"" then to the target. I
> don't believe I remembered to file this with Apple ...

  I say this like it is most definitely your problem, but I should
mention that *if* you're merely changing existing items, this is a
problem. If you're entirely rebuilding things, it probably isn't. :-)

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread I. Savant
> At first I thought the solution was obvious: I was building these menus as 
> needed, in the NSMenu delegate method, -menuNeedsUpdate: This method only 
> gets called when the user goes to look at the menu. So, if these dynamic 
> menus were only built in -menuNeedsUpdate:, then clearly the keyboard 
> shortcuts defined in System Preferences for any items in such menus would 
> note work until after the user had opened the menu at least once (thus 
> populating it in -menuNeedsUpdate: and allowing the defined shortcut actually 
> to apply to something, because before this the menu wouldn't have existed).

  I've noticed a bug where calling -[NSMenuItem setKeyEquivalent:]
does not update unless you first set it to @"" then to the target. I
don't believe I remembered to file this with Apple ...

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Rebuilding menus (menuNeedsUpdate:) and System Preferences keyboard shortcuts.

2008-12-01 Thread Keith Blount
Hi,

My application has several menus that get built dynamically, depending on user 
settings. For instance, there is a "Styles" menu, which lists styles the user 
has defined, and a "Script Elements" menu, which again, provides a list of 
user-defined options that apply a certain format to a range of text.

However, it seems that dynamically-built menus have a problem when it comes to 
keyboard shortcuts defined via the System Preferences - as in, the keyboard 
shortcuts don't always work.

At first I thought the solution was obvious: I was building these menus as 
needed, in the NSMenu delegate method, -menuNeedsUpdate: This method only gets 
called when the user goes to look at the menu. So, if these dynamic menus were 
only built in -menuNeedsUpdate:, then clearly the keyboard shortcuts defined in 
System Preferences for any items in such menus would note work until after the 
user had opened the menu at least once (thus populating it in -menuNeedsUpdate: 
and allowing the defined shortcut actually to apply to something, because 
before this the menu wouldn't have existed).

My solution was to build these menus whenever the user settings changed. So, if 
the user added or deleted a style, the menu would get rebuilt, as well as 
rebuilding it in -menuNeedsUpdate:. However, this still doesn't seem reliable. 
When opening another window, the keyboard shortcuts defined via System 
Preferences still don't operate in the new window until after the menu has been 
opened - and yet NSLogging shows that the menu is getting built before this and 
even seems to have a keyboard shortcut attached... Very strange.

So, my question: what is the best way of building menus dynamically whilst 
ensuring that any keyboard shortcuts defined in System Preferences will catch 
them and apply to them?

I am implementing -menuHasKeyEquivalent:... and returning NO. It seems that if 
I don't implement this method, then keyboard shortcuts work for dynamically 
built methods... But not implementing this method makes all the keyboard 
shortcuts in my app work very, very slowly, so leaving it out isn't an option...

Thanks in advance for any help or pointers.
All the best,
Keith


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Textured Window Responder Issue

2008-12-01 Thread Richard Somers


On Dec 1, 2008, at 12:34PM, Benjamin Stiglitz wrote:


Presumably you have a custom view; you need to return the right value
from -[NSView mouseDownCanMoveWindow]:


That worked. Thank you so much.

Richard

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 SMB servers on the network

2008-12-01 Thread Sandro Noel

Greetings.

i am looking for a way to detect the presence or advertisement of  
samba servers on my network in cocoa
kind of the same thing Bonjour does, the finder seems able to detect  
them and i would like to do the
same thing, and i have been researching the documentation but found  
nothing that was helpful


can anyone point me in the right direction ?

thank you !!
Sandro Noel.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Jerry Krinock


On 2008 Dec, 01, at 6:12, Jean-Daniel Dupas wrote:


- (void)dealloc {
[_tableView setDataSource:nil];
[_otherIVar setDelegate:nil];


According to [1], you need one more line of code here:
  [tableView reloadData];


// other dealloc stuff
[super dealloc];
}



Also, note that the behavior causing the crash was changed in Leopard  
and is explained some in the Leopard AppKit Release Notes [2].


Let us know if you learn anything interesting, because by following  
these recommendations I've got my app to not crash 99% of the time.


Jerry

1.  http://developer.apple.com/documentation/Cocoa/Conceptual/OutlineView/Articles/UsingOutlineDataSource.html#/ 
/apple_ref/doc/uid/2725.  See section "The Data Source and Memory  
Management".


2.  http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSTableView 
.  See section "New Behavior in NSWindowController at Window Closing  
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: Textured Window Responder Issue

2008-12-01 Thread Benjamin Stiglitz
> When the view uses NSOpenGLView a mouse drag in the view will send  
> events to the view. It works properly.
>
> When the view uses CAOpenGLLayer a mouse drag in the view will move the 
> window! The mouse events are being sent to the view but are apparently 
> being picked up and acted upon by the window as well.

Presumably you have a custom view; you need to return the right value
from -[NSView mouseDownCanMoveWindow]:



-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: displaying huge log files

2008-12-01 Thread Benjamin Stiglitz
On Sun, Nov 30, 2008 at 12:48:26AM -0800, Andrew Farmer wrote:
> On 29 Nov 08, at 14:23, Nick Zitzmann wrote:
>> On Nov 29, 2008, at 5:39 AM, Mudi Dandan wrote:
>>> Is it possible to to display a memory mapped file in an NSTextView
>>
>> Of course.
>
> With one caveat: When creating a memory mapping (by using mmap), you  
> have to specify the length of the region you want to map - so, if the  
> file grows, you have to remap the file. Detecting this is up to you;  
> kqueue may be useful in doing so. Also, if the file gets really large*, 
> it may fail to map at all on 32-bit systems, as there's a limited amount 
> of address space available.
>
> Unless you're absolutely sure that memory-mapping files is crucial to  
> your application's performance, try just using standard file descriptors 
> first. The performance difference isn't that huge, and there are a lot 
> fewer caveats** involved.

If you want an example of how this mapping is done, check out the
sources for HexFiend:



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


Textured Window Responder Issue

2008-12-01 Thread Richard Somers

I have a textured window with a custom view.

When the view uses NSOpenGLView a mouse drag in the view will send  
events to the view. It works properly.


When the view uses CAOpenGLLayer a mouse drag in the view will move  
the window! The mouse events are being sent to the view but are  
apparently being picked up and acted upon by the window as well.


If the window is not textured then everything works normally in both  
cases.


Any ideas?

Richard

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: NSTextField as a CALayer

2008-12-01 Thread Michel Schinz

Le 1 déc. 08 à 07:45, Scott Anguish a écrit :


No, you can't do this.

Core Animation is designed for easy animation, but not so you can  
freely mix views and layers like this.


you could probably do what you want by doing your current CALayer  
drawing into an NSView, and then add the textfield as a subview of  
that view.. then turn on layer backing for the parent NSView.



Indeed, that's what I personally do in my application, and it works  
well with some minor gotchas, one of which was explained to me by the  
always-helpful David Duncan in the following thread (which the OP  
might find worth reading):


http://www.cocoabuilder.com/archive/message/cocoa/2008/11/14/222642

Michel.___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Command-clicking table column -- radar://6407526

2008-12-01 Thread Corbin Dunn


Le Nov 30, 2008 à 2:45 PM, Kirk Kerekes a écrit :


Done: 

Now that I have done that I eagerly anticipate the post that shows  
me my bonehead error.


Unfortunately, I think this is just an oversight on the  
implementation. There is no work around, shy of implementing the  
selected header stuff yourself (which probably isn't worth the trouble).


corbin___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Multiple NSTableViews in one NSScrollView

2008-12-01 Thread Corbin Dunn

Hi Tom,

Le Nov 26, 2008 à 1:09 AM, Thomas Engelmeier a écrit :


Hi,

I have an UI where a bunch of NSTableViews plus extra title views  
are stacked in one NSScrollView.
Currently each table is loaded from a subview NIB, populated,  
resized-to-fit and placed in a master documentview.


That is working fine except IB generated TableViews reside already  
in a IB generated NSScrollView (unused, scrollview frame = table 
+header frame) which leads to a bunch of scrolling related artifacts  
(ScrollWheel etc..). How much is a NSTableView interacting with the  
enclosing scroll view?


Quite a bit -- it tries to set the content size to the table's size.


Can I get rid of the scrollview by programmatically creating the  
table view?


Yes, you can, but, it really depends on what you want. If you have X  
tableviews stacked on top of each other, it is probably easiest to  
enclose all of them in a parent scrollview, and make sure that you  
can't (or don't need to) scroll the contents of the child ones.


-corbin



Ar attach the shared parent scroll view to all tableviews?

TIA,
Tom_E



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Power code unplug and plug

2008-12-01 Thread Jean-Daniel Dupas


Le 1 déc. 08 à 18:46, sheen mac a écrit :


Hi All,

My app want to get power code plug and unplug notification for
MacBook. How can I get that info. Could suggest some info
or link about this?.

Thanks In Advance,
Sheen



I think you are looking for the IOPowerSources API, especially  
IOPSNotificationCreateRunLoopSource



http://developer.apple.com/documentation/Darwin/Reference/IOKit/IOPowerSources/




___

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

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

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

This email sent to [EMAIL PROTECTED]


Power code unplug and plug

2008-12-01 Thread sheen mac
Hi All,

My app want to get power code plug and unplug notification for
MacBook. How can I get that info. Could suggest some info
or link about this?.

Thanks In Advance,
Sheen


  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: CFMessagePort and GC

2008-12-01 Thread Michael Ash
On Mon, Dec 1, 2008 at 12:19 AM, Ryan Brown <[EMAIL PROTECTED]> wrote:
> Also, forgot to mention: calling either objc_collect_if_needed() or
> [[NSGarbageCollector defaultCollector] collectExhaustively] after releasing
> the run loop source and message port doesn't force an immediate
> deallocation. Not sure why.

Most likely because the object is still referenced on the stack, and
so is still considered live. If you're sure that you've eliminated all
stack references to it (returned from any functions that may have used
it), then you can clear the stack using the objc_clear_stack()
function. Check the docs or list archives for more information on
that.

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: [ANN]CocoaOniguruma Released

2008-12-01 Thread Ulai Beekam

That is nice. Thanks.

Can you paste some simple code examples that do some matching against an 
NSStrings?

For example, to determine whether myString matches against "$s.+"

And another example that matches myString against "foo(.*)bar" and if it 
matches puts the stuff in the parantheses in a new string.




> Date: Tue, 2 Dec 2008 00:49:08 +0900
> From: [EMAIL PROTECTED]
> To: cocoa-dev@lists.apple.com
> Subject: [ANN]CocoaOniguruma Released
> 
> I have released CocoaOniguruma.
> 
>   http://limechat.net/cocoaoniguruma/
> 
> CocoaOniguruma is an Objective-C binding of Oniguruma regular expression 
> engine.
> It's simple and tiny compared to the other bindings. It works well on
> Mac OS X and iPhone.
> 
> You can download the source code from github.
> 
>   http://github.com/psychs/cocoaoniguruma/tree/master
> 
> --
> Satoshi Nakagawa
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/ulaibeekam%40hotmail.com
> 
> This email sent to [EMAIL PROTECTED]

_
Invite your mail contacts to join your friends list with Windows Live Spaces. 
It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us___

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

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

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

This email sent to [EMAIL PROTECTED]


[ANN]CocoaOniguruma Released

2008-12-01 Thread Satoshi Nakagawa
I have released CocoaOniguruma.

  http://limechat.net/cocoaoniguruma/

CocoaOniguruma is an Objective-C binding of Oniguruma regular expression engine.
It's simple and tiny compared to the other bindings. It works well on
Mac OS X and iPhone.

You can download the source code from github.

  http://github.com/psychs/cocoaoniguruma/tree/master

--
Satoshi Nakagawa
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Andre Masse

That would explain the different behaviours.

Thanks a lot,

Andre Masse


On Dec 1, 2008, at 10:26, Jean-Daniel Dupas wrote:

What I don't understand is why I don't crash if the window is  
closed from its close box...




The order in which the window go offscreen, the window content is  
released, etc. is probably not the same if you click on the close  
button and if you use the close menu. The windows does not use the  
same code path,  It is maybe autoreleased in one case and not in the  
other, or something else.





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data vector modeling query

2008-12-01 Thread Paul Tomlin

Thanks Erik,

On 01 Dec 2008, at 4:59 PM, Erik Buck wrote:

Vector3DReference is abstract.  I have derived Vector3DReference for  
all of the cases where I have other entities with relationships to  
Vector3DReference.  For example, I have a Billboard entity that has  
a "to one" relationship to BillboardAnchorVector3DReference which  
has a reciprocal "to one" relationship back to Billboard.


As I understand it, your model is equivalent to the example I gave of  
using distinct entity types for each 'endpoint' (as I described it).  
I'm still pondering if that's going to work for me, I suspect I should  
just try it and see what becomes a problem.


That old adage "every problem in computer science can be solved with  
another layer of indirection" comes to mind.



It is common in 3D systems to have a large collection or database of  
points/vectors and then reference the points/vectors for index or  
ID.  E.g. consider multiple triangles that all share a vertex. When  
the vertex changes, all of the triangles that share the vertex are  
updated.  Sharing vertex data also reduces the storage required vs.  
lots of copies of the vertex.


Thomas Davie wrote:

It's most common for 3D apps to pack the vertecies into arrays, and  
then create index arrays that index into the vertex/normal/tex coord  
arrays to get at the data.  These can then be uploaded so that all  
the lookups etc happen on the graphics card, and no data need be  
fetched from system memory when you try to draw.


You should look at glVertexArray and related functions.


I seem to have completely made a muck up of using an analogy. I'm not  
dealing with 3D data at all, though I can see the similarities between  
that and my domain. Vector may have been then wrong term to use, I'm  
really dealing with a directional, anchored-at-both-ends, link between  
two entities.


Thanks for the help guys.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Jean-Daniel Dupas


Le 1 déc. 08 à 15:15, Andre Masse a écrit :


Thanks for your reply Keary,

What I don't understand is why I don't crash if the window is closed  
from its close box...


Andre Masse




The order in which the window go offscreen, the window content is  
released, etc. is probably not the same if you click on the close  
button and if you use the close menu. The windows does not use the  
same code path,  It is maybe autoreleased in one case and not in the  
other, or something else.





On Dec 1, 2008, at 09:08, Keary Suska wrote:



On Dec 1, 2008, at 6:47 AM, Andre Masse wrote:

I've a strange bug that happens if the window is closed by  
choosing the "Close" menu and not by clicking in the window's  
close box. The window contains  master/detail views. I can prevent  
the crash if I set the master's table view datasource to nil in  
dealloc but I don't understand why this is happening...


Any idea?

Andre Masse

backtrace here:

#0  0x922d5907 in ___forwarding___ ()
#1  0x922d5a12 in __forwarding_prep_0___ ()
#2  0x94ee1cae in -[NSTableView _dataSourceValueForColumn:row:] ()



I would assume that the data source object is being deallocated  
before the table view is done with it, especially if the crash  
error is Exec Bad Access. This would explain why setting the data  
source to nil in dealloc avoids the error. There can be a number of  
causes, but there isn't sufficient info to suggest anything further  
(IMHO).


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data vector modeling query

2008-12-01 Thread Thomas Davie


On 1 Dec 2008, at 15:59, Erik Buck wrote:

I use Core Data to store large amounts of 3D vector data.  I solved  
your problem in the following way:


I have a "Vector3D" entity that you can think of as an "end point"  
in your model.  My Vector3D entity has x,y,z attributes.


I have a "Vector3DReference" entity.

Vector3D has a "to many" relationship to Vector3DReference which has  
a "to one" relationship to Vector3D.  I can ask any Vector3D for all  
of its references, and I can as a reference for its Vector3D.


Vector3DReference is abstract.  I have derived Vector3DReference for  
all of the cases where I have other entities with relationships to  
Vector3DReference.  For example, I have a Billboard entity that has  
a "to one" relationship to BillboardAnchorVector3DReference which  
has a reciprocal "to one" relationship back to Billboard.


It is common in 3D systems to have a large collection or database of  
points/vectors and then reference the points/vectors for index or  
ID.  E.g. consider multiple triangles that all share a vertex. When  
the vertex changes, all of the triangles that share the vertex are  
updated.  Sharing vertex data also reduces the storage required vs.  
lots of copies of the vertex.


It's most common for 3D apps to pack the vertecies into arrays, and  
then create index arrays that index into the vertex/normal/tex coord  
arrays to get at the data.  These can then be uploaded so that all the  
lookups etc happen on the graphics card, and no data need be fetched  
from system memory when you try to draw.


You should look at glVertexArray and related functions.

Bob
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data vector modeling query

2008-12-01 Thread Erik Buck
As another refinement, store all of your end points as an array of float.  
Store the array in NSData.  Have an entity called EndPointStorage that has an 
NSData attribute, endpoints.
 
The Vector3DReference entity can then have an integer attribute called 
endPointIndex.  Use endPointIndex to lookup the end point in the 
EndPointStorage.endpoints.
 
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data vector modeling query

2008-12-01 Thread Erik Buck
I use Core Data to store large amounts of 3D vector data.  I solved your 
problem in the following way:
 
I have a "Vector3D" entity that you can think of as an "end point" in your 
model.  My Vector3D entity has x,y,z attributes.
 
I have a "Vector3DReference" entity.
 
Vector3D has a "to many" relationship to Vector3DReference which has a "to one" 
relationship to Vector3D.  I can ask any Vector3D for all of its references, 
and I can as a reference for its Vector3D.
 
Vector3DReference is abstract.  I have derived Vector3DReference for all of the 
cases where I have other entities with relationships to Vector3DReference.  For 
example, I have a Billboard entity that has a "to one" relationship to 
BillboardAnchorVector3DReference which has a reciprocal "to one" relationship 
back to Billboard.
 
It is common in 3D systems to have a large collection or database of 
points/vectors and then reference the points/vectors for index or ID.  E.g. 
consider multiple triangles that all share a vertex. When the vertex changes, 
all of the triangles that share the vertex are updated.  Sharing vertex data 
also reduces the storage required vs. lots of copies of the vertex.
 
___

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

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

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

This email sent to [EMAIL PROTECTED]


best way to add transitions

2008-12-01 Thread M Pulis

Hello Cocoa folk,

My app uses an IKImageView in its main window. Until the user engages  
some function, the IK view sequentially displays slides prompting the  
user to become involved, a typical attract mode.


What is now requested is a transition such as fade (or any of the  
variety of transitions) instead. From reading about views, layers and  
transitions (oh my!), I am seeing more trees than forest


What is the best approach to add transitions to an IKImageView? An  
outline should do, I ought to be able to figure out the calls by now.


Thanks!

Gary
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Andre Masse

Thanks for the info Thomas.

I should have said that I'm not using GC.

Andre Masse


On Dec 1, 2008, at 09:22, Thomas Davie wrote:



This is a shot in the dark, but I was looking at a very similar  
error recently.  It turned out to be caused by having forgotten to  
turn on garbage collection in my release build, that may be the  
place you want to look.


Bob


___

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

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

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

This email sent to [EMAIL PROTECTED]


ASLExpireTime Format?

2008-12-01 Thread Karl Moskowski
I'm using ASL for logging, and I'm trying to make the messages persist  
in the main database for at least 30 days. In Peter Hosey's excellent  
blog series on ASL, there's a description of an undocumented key  
"ASLExpireTime" to accomplish this.


I'm doing something like this:
	NSCalendarDate *ttl = [[NSCalendarDate date] dateByAddingYears:0  
months:0 days:30 hours:0 minutes:0 seconds:0];

aslmsg msg = asl_new(ASL_TYPE_MSG);
	asl_set(msg, "ASLExpireTime", [[NSString stringWithFormat:@"%.0f",  
[ttl timeIntervalSince1970]] UTF8String]);

asl_log(NULL, msg, level, "%s", [logMessage UTF8String]);

However, it doesn't seem to work. The log messages still get archived  
every Monday.


Looking over the blog again, there's an implication that  
"ASLExpireTime" isn't the Unix time (seconds since 1970, like  
ASL_KEY_TIME), but rather a duration from now. Is that true?


BTW, here's the blog, if anyone's interested:



Karl Moskowski <[EMAIL PROTECTED]>
Voodoo Ergonomics Inc. 



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: Crash when closing window from the menu

2008-12-01 Thread Thomas Davie


On 1 Dec 2008, at 14:47, Andre Masse wrote:


Hi,

I've a strange bug that happens if the window is closed by choosing  
the "Close" menu and not by clicking in the window's close box. The  
window contains  master/detail views. I can prevent the crash if I  
set the master's table view datasource to nil in dealloc but I don't  
understand why this is happening...


Any idea?


This is a shot in the dark, but I was looking at a very similar error  
recently.  It turned out to be caused by having forgotten to turn on  
garbage collection in my release build, that may be the place you want  
to look.


Bob
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Andre Masse

Ah! Didn't know that.

Thanks a lot,

Andre Masse


On Dec 1, 2008, at 09:12, Jean-Daniel Dupas wrote:

When you dealloc a datasource, a delegate or any other object that  
is not retained by class that uses it, you have to unregister it.
For example, if you have an object that is datasource for its  
_tableView ivar and delegate for _otherIVar ivar, you should do  
something like this :


- (void)dealloc {
[_tableView setDataSource:nil];
[_otherIVar setDelegate:nil];
// other dealloc stuff
[super dealloc];
}

You should also remove it from notification center if it is  
registered as observer, etc.


Not that all this stuff is useless in Garbage collected app, and  
should not be duplicate in finalize.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Andre Masse

Thanks for your reply Keary,

What I don't understand is why I don't crash if the window is closed  
from its close box...


Andre Masse


On Dec 1, 2008, at 09:08, Keary Suska wrote:



On Dec 1, 2008, at 6:47 AM, Andre Masse wrote:

I've a strange bug that happens if the window is closed by choosing  
the "Close" menu and not by clicking in the window's close box. The  
window contains  master/detail views. I can prevent the crash if I  
set the master's table view datasource to nil in dealloc but I  
don't understand why this is happening...


Any idea?

Andre Masse

backtrace here:

#0  0x922d5907 in ___forwarding___ ()
#1  0x922d5a12 in __forwarding_prep_0___ ()
#2  0x94ee1cae in -[NSTableView _dataSourceValueForColumn:row:] ()



I would assume that the data source object is being deallocated  
before the table view is done with it, especially if the crash error  
is Exec Bad Access. This would explain why setting the data source  
to nil in dealloc avoids the error. There can be a number of causes,  
but there isn't sufficient info to suggest anything further (IMHO).


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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 when closing window from the menu

2008-12-01 Thread Jean-Daniel Dupas
When you dealloc a datasource, a delegate or any other object that is  
not retained by class that uses it, you have to unregister it.
For example, if you have an object that is datasource for its  
_tableView ivar and delegate for _otherIVar ivar, you should do  
something like this :


- (void)dealloc {
[_tableView setDataSource:nil];
[_otherIVar setDelegate:nil];
// other dealloc stuff
[super dealloc];
}

You should also remove it from notification center if it is registered  
as observer, etc.


Not that all this stuff is useless in Garbage collected app, and  
should not be duplicate in finalize.



Le 1 déc. 08 à 14:47, Andre Masse a écrit :


Hi,

I've a strange bug that happens if the window is closed by choosing  
the "Close" menu and not by clicking in the window's close box. The  
window contains  master/detail views. I can prevent the crash if I  
set the master's table view datasource to nil in dealloc but I don't  
understand why this is happening...


Any idea?

Andre Masse

backtrace here:

#0  0x922d5907 in ___forwarding___ ()
#1  0x922d5a12 in __forwarding_prep_0___ ()
#2  0x94ee1cae in -[NSTableView _dataSourceValueForColumn:row:] ()
#3  0x94e63fe0 in -[NSTableView preparedCellAtColumn:row:] ()
#4  0x94e63e44 in -[NSTableView  
_drawContentsAtRow:column:withCellFrame:] ()

#5  0x94e6337a in -[NSTableView drawRow:clipRect:] ()
#6  0x94e087f4 in -[NSTableView drawRowIndexes:clipRect:] ()
#7  0x94e072d8 in -[NSTableView drawRect:] ()
#8  0x94e97864 in -[NSView _drawRect:clip:] ()
#9  0x94e9635b in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#10 0x94e966f2 in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#11 0x94e94cb1 in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#12 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#13 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#14 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#15 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#16 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#17 0x94e945f3 in -[NSThemeFrame  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#18 0x94e91117 in -[NSView  
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]  
()

#19 0x94dd1b77 in -[NSView displayIfNeeded] ()
#20 0x94dd1725 in -[NSWindow displayIfNeeded] ()
#21 0x94dd1548 in _handleWindowNeedsDisplay ()
#22 0x922549c2 in __CFRunLoopDoObservers ()
#23 0x92255d1c in CFRunLoopRunSpecific ()
#24 0x92256cf8 in CFRunLoopRunInMode ()
#25 0x93bce480 in RunCurrentEventLoopInMode ()
#26 0x93bce1d2 in ReceiveNextEventCommon ()
#27 0x93bce10d in BlockUntilNextEventMatchingListInMode ()
#28 0x94dcf3ed in _DPSNextEvent ()
#29 0x94dceca0 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#30 0x94f7aac3 in -[NSButtonCell performClick:] ()
#31 0x94ea0b03 in -[NSApplication sendAction:to:from:] ()
#32 0x94f4f540 in -[NSMenu performActionForItemAtIndex:] ()
#33 0x94f4f245 in -[NSCarbonMenuImpl  
performActionWithHighlightingForItemAtIndex:] ()

#34 0x94f4eecb in -[NSMenu performKeyEquivalent:] ()
#35 0x94f4d770 in -[NSApplication _handleKeyEquivalent:] ()
#36 0x94e6a733 in -[NSApplication sendEvent:] ()
#37 0x94dc7d0f in -[NSApplication run] ()
#38 0x94d94f14 in NSApplicationMain ()
#39 0x2480 in main (argc=1, argv=0xb618) at /Users/andre/ 
development/CocoaTDH/version_courante/main.m:13

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Crash when closing window from the menu

2008-12-01 Thread Keary Suska


On Dec 1, 2008, at 6:47 AM, Andre Masse wrote:

I've a strange bug that happens if the window is closed by choosing  
the "Close" menu and not by clicking in the window's close box. The  
window contains  master/detail views. I can prevent the crash if I  
set the master's table view datasource to nil in dealloc but I don't  
understand why this is happening...


Any idea?

Andre Masse

backtrace here:

#0  0x922d5907 in ___forwarding___ ()
#1  0x922d5a12 in __forwarding_prep_0___ ()
#2  0x94ee1cae in -[NSTableView _dataSourceValueForColumn:row:] ()



I would assume that the data source object is being deallocated before  
the table view is done with it, especially if the crash error is Exec  
Bad Access. This would explain why setting the data source to nil in  
dealloc avoids the error. There can be a number of causes, but there  
isn't sufficient info to suggest anything further (IMHO).


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

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

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

This email sent to [EMAIL PROTECTED]


Crash when closing window from the menu

2008-12-01 Thread Andre Masse

Hi,

I've a strange bug that happens if the window is closed by choosing  
the "Close" menu and not by clicking in the window's close box. The  
window contains  master/detail views. I can prevent the crash if I set  
the master's table view datasource to nil in dealloc but I don't  
understand why this is happening...


Any idea?

Andre Masse

backtrace here:

#0  0x922d5907 in ___forwarding___ ()
#1  0x922d5a12 in __forwarding_prep_0___ ()
#2  0x94ee1cae in -[NSTableView _dataSourceValueForColumn:row:] ()
#3  0x94e63fe0 in -[NSTableView preparedCellAtColumn:row:] ()
#4  0x94e63e44 in -[NSTableView  
_drawContentsAtRow:column:withCellFrame:] ()

#5  0x94e6337a in -[NSTableView drawRow:clipRect:] ()
#6  0x94e087f4 in -[NSTableView drawRowIndexes:clipRect:] ()
#7  0x94e072d8 in -[NSTableView drawRect:] ()
#8  0x94e97864 in -[NSView _drawRect:clip:] ()
#9  0x94e9635b in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#10 0x94e966f2 in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#11 0x94e94cb1 in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#12 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#13 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#14 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#15 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#16 0x94e95b0b in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#17 0x94e945f3 in -[NSThemeFrame  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#18 0x94e91117 in -[NSView  
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()

#19 0x94dd1b77 in -[NSView displayIfNeeded] ()
#20 0x94dd1725 in -[NSWindow displayIfNeeded] ()
#21 0x94dd1548 in _handleWindowNeedsDisplay ()
#22 0x922549c2 in __CFRunLoopDoObservers ()
#23 0x92255d1c in CFRunLoopRunSpecific ()
#24 0x92256cf8 in CFRunLoopRunInMode ()
#25 0x93bce480 in RunCurrentEventLoopInMode ()
#26 0x93bce1d2 in ReceiveNextEventCommon ()
#27 0x93bce10d in BlockUntilNextEventMatchingListInMode ()
#28 0x94dcf3ed in _DPSNextEvent ()
#29 0x94dceca0 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#30 0x94f7aac3 in -[NSButtonCell performClick:] ()
#31 0x94ea0b03 in -[NSApplication sendAction:to:from:] ()
#32 0x94f4f540 in -[NSMenu performActionForItemAtIndex:] ()
#33 0x94f4f245 in -[NSCarbonMenuImpl  
performActionWithHighlightingForItemAtIndex:] ()

#34 0x94f4eecb in -[NSMenu performKeyEquivalent:] ()
#35 0x94f4d770 in -[NSApplication _handleKeyEquivalent:] ()
#36 0x94e6a733 in -[NSApplication sendEvent:] ()
#37 0x94dc7d0f in -[NSApplication run] ()
#38 0x94d94f14 in NSApplicationMain ()
#39 0x2480 in main (argc=1, argv=0xb618) at /Users/andre/ 
development/CocoaTDH/version_courante/main.m:13

___

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

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

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

This email sent to [EMAIL PROTECTED]


[MEET] Amsterdam CocoaHeads - December 10

2008-12-01 Thread Cathy Shive

Hello Cocoa devs!

The next meeting of the Amsterdam CocoaHeads will be Wednesday,  
December 10th from 7-9 PM.


Please visit the Google Group page for location and other information:
http://groups.google.com/group/cocoaheads-amsterdam/web/meeting-20081210

Hope to see you there!

Cathy

___

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

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

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

This email sent to [EMAIL PROTECTED]


[MEET] CocoaHeads Frankfurt, TONIGHT 8PM

2008-12-01 Thread Torsten Curdt
Tonights it's on again!

 Talk: Using git for Cocoa projects

Drop by if you are around. More information at

http://cocoaheads.org/de/Frankfurt/index.html

iCal: webcal://upcoming.yahoo.com/calendar/v2/group/4810/9266a3a167
RSS:  http://upcoming.yahoo.com/syndicate/v2/group/4810/9266a3a167

cheers
--
Torsten
http://vafer.org/blog
http://twitter.com/tcurdt
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: NSArrayController trouble

2008-12-01 Thread Ken Thomases

On Nov 30, 2008, at 3:35 PM, Alexander Cohen wrote:

Hi, Im getting the following line in the console when sending the  
'removeObjectsAtArrangedObjectIndexes:' message to an  
NSArrayController instance.


-[NSCFArray removeObjectAtIndex:]: mutating method sent to immutable  
object


I understand what it means but i'm not sure why it's happening. Is  
there anything i need to set up in order for the contents of the  
arrayController to be mutable?


The array controller is bound to a to-many property of some other  
object.  That to-many property is not properly mutable.


You may be tempted to change that property's type from NSArray to an  
NSMutableArray, but that's not the right solution.  The right solution  
is to implement the mutating indexed accessors for the property:


The minimal accessors for read access:
-countOf
-objectInAtIndex:

One (or both) of the insertion methods:
-insertObject:inAtIndex:
-insert:atIndexes:

One (or both) of the removal methods:
-removeObjectFromAtIndex:
-removeAtIndexes:

Optionally, for performance:
-get:range:
-replaceObjectInAtIndex:withObject:


(Note, you can use an NSMutableArray as the backing store for the  
property, but that's different and separate from changing the type of  
the property to NSMutableArray.  The latter violates encapsulation by  
allowing code outside of your class to modify the state of your  
objects without them being aware of it.)


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]


Core Data vector modeling query

2008-12-01 Thread Paul Tomlin
Using an analogy, I'm trying to model a 'vector' using CD. I have a  
Vector entity, which has 2 to-one relationships to a VectorEnpoint  
entity. The VectorEndpoint entity describes how the Vector is  
connected at one end to other entities in the model


Vector:
source -> to-one -> VectorEndpoint
target -> to-one -> VectorEndpoint

I need a VectorEndpoint entity because the definition of the 'end' of  
each vector is not straightforward.


My query is how should I model the inverse of these 'source' and  
'target' relationships?


VectorEndpoint:
vector -> to-one -> Vector

simply doesn't work because the Vector entity has 2 relationships  
which ideally need inverses (I can only choose 'source' or 'target' as  
the inverse).


One possible solution I can think of involves having different  
entities for each end. I'm pondering if this is going to be a suitable  
solution for my task. It does seem a little wrong, intuitively at least.


AbstractVectorEndpoint:
(abstract + common data)

VectorSourceEndpoint:
vector -> to-one -> Vector (source)

VectorTargetEndpoint:
vector -> to-one -> Vector (target)


Any thoughts or pointers?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: NSTrackingArea strange requirement

2008-12-01 Thread rajesh


On Nov 28, 2008, at 6:52 PM, Quincey Morris wrote:


On Nov 28, 2008, at 01:57, rajesh wrote:

On 27/11/2008, at 10:22 PM, rajesh wrote:


but I see a kind of problem with above approach as well.
Since we are updating the TrackingAreas in updateTrackingAreas  
(removing and adding track areas) , my cursor (which is set to  
"resizeUpDownCursor" mouseEntered:  )  seems to flicker when ever  
try updating/resizing my view  due to the fact that trackAreas  
are changed every time.


You shouldn't be using -mouseEntered: to set the cursor. You  
should init the tracking area with the NSTrackingCursorUpdate  
option and then implement the -cursorUpdate: method.


Sorry my mistake :( . I corrected it. but the cursor still flickers  
and I think I am missing some great deal in implementing the  
tracking.


Given your requirements, there's probably no really easy way for you  
to handle the cursor, but I still think you're making it harder for  
yourself than it needs to be.


IIRC, you have a parent custom view, which contains subviews that  
are instances of NSBox, each of which contains other views, some of  
which may set the cursor on their own (like text fields -- let's  
pretend they're all text fields for the sake of the discussion).


-- When the mouse is over the parent view, but not over any of the  
boxes, you want a "resize" cursor.


-- When the mouse is over a text field, you don't want to interfere.

-- When the mouse is over a box subview, but not over one of the  
text fields, you want to .. what? Let the cursor be whatever it was  
*before it entered the parent view*? Set the cursor to an arrow?


I suspect you're trying to do the former (let the cursor revert to  
whatever it was before you changed to a "resize" cursor), but I  
think the correct answer is the latter (set the cursor to an arrow).


Your assumption is right..  I just want the cursor behave as it is  
supposed to when it is over subview



One reason I think it's correct is that it's doable, while the other  
choice may not be, or not without driving you insane.


So, again, I think you just need one tracking area for the parent  
view, and one tracking area for each box view.


-- When the mouse enters a "resize" region, either by entering it  
from the outside or by exiting one of the box subviews, your custom  
view gets a cursorUpdate event. You should check the mouse location,  
and set the appropriate "resize" cursor.


-- When the mouse enters a text field, it changes to whatever the  
text field wants it to be.


-- When the mouse enters a box region, the cursorUpdate event will  
attempt to go to the view under the mouse -- the box view or one of  
its subviews. If that view implements cursorUpdate, that's fine --  
the cursor is handled. If not (the usual case, I suspect), the event  
goes up the responder chain till some responder handles it. In this  
case, that would be your custom view.


So, your custom view should check the mouse location, and set the  
arrow cursor if the mouse is over one of its subviews.


That is, your custom view's cursorUpdate: method is going to be  
setting the cursor appropriately for *all* of the tracking area  
events, *except* where a sub-subview handles the cursor on its own.  
That means it needs to check the mouse location and determine the  
appropriate cursor.


Having said all that, I'll add:

-- If you re-define tracking areas (delete the old ones and create  
new ones), there's a temporary loss of mouse synchronization --  
whether the mouse is outside or inside becomes "unknown" until at  
least the mouse moves, maybe longer. That means you could fail to  
get expected cursorUpdate events, possibly until the next time the  
mouse enters or exits a tracking area. To minimize the effects of  
this defect, make sure you use the NSTrackingAssumeInside option for  
the tracking areas. That option is mis-documented, and in most cases  
it's better to use it than to not use it. (The correct documentation  
is in the Leopard developer release notes.)


-- Although it may not apply here, there's one cause of cursor  
flickering that's easy to overlook. When the mouse is inside a  
scroll view or any of its subviews, the scroll view itself may  
sometimes set the cursor, especially when scrolling. If your custom  
view is inside a scroll view, you should invoke -[NSScrollView  
setDocumentCursor:] whenever you change the cursor, so that the  
cursor it uses matches the cursor you're trying to use.


this dint occur to me as the problem , but setting the documentCursor  
is working great !!! but again there is catch , the lower part of my  
subview is filled with textView so while dragging (  the gap between  
the subviews , which resizes them ) , its apparent that mouse point  
enters the textView ( while still in dragging state) hence flickering  
starts over but only the direction in which textView appears .


One observation is flickering frequency is not that insane compared to