Re: File Extensions Problem

2008-08-29 Thread Uli Kusterer

On 29.08.2008, at 02:12, Graham Cox wrote:
Well, that was me. But I do see the error of my ways... I guess it  
was Michael Ash's comment that NSArray *could* change its storage  
half way through enumeration (if the collection were mutated) that  
woke me up. I suspect it would only do this if the collection  
dramatically changed in size but clearly that wouldn't be something  
to rely on. I checked my own code to make sure I wasn't following my  
own "advice" anywhere and turns out I've never done it without  
making a copy anyway.



 One other reason why this is dangerous is that NSArray isn't  
guaranteed to be a plain C-style array, internally.


 NSArray is a very abstractly defined collection class. It gives you  
some performance guarantees for its operations, but beyond that it may  
choose any implementation it wishes. So, it could actually implement  
itself as a tree, or a linked list, or a simple C array of  
pointers, ... or hamsters in a box, for all we care. It could even  
store the array backwards internally, which would mean that every  
removal from the end changes all the pointers, while removal from the  
start would be safe.


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





___

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

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

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

This email sent to [EMAIL PROTECTED]


Busy doing nothing

2008-08-29 Thread Gerriet M. Denkmann

I have an app which does not take any Cpu-time when it is doing nothing.
So what? you might say. Every app does this.

Well, not quite.

If I add these magic lines it will use 0.2% of my Cpu just doing  
nothing:


NSMetadataQuery *query = [ [ NSMetadataQuery alloc] init];
[ query startQuery ];
[ query stopQuery ];
NSArray *results = [ query results ];   //  
_NSMetadataQueryResultArray
[ query release ];

From now on until quit I get every 100 msec  one Context Switch and  
two Mach System Calls - as observed via Activity Monitor.


Is this normal? Correct?
And could someone explain why?

Tiger 10.4.11


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: programatically quit a program

2008-08-29 Thread Stéphane Sudre


On Aug 28, 2008, at 10:45 PM, Robert Claeson wrote:



On 28 Aug 2008, at 22:38, Wayne Shao wrote:

What is the correct way to quit a cocoa app?  I could use C exit()  
but that

would loose the chance to invoke the right callbacks for clean up.
What is the call that would be equivalent to user explicitly  
selecting the

Quit from the menu.

I only found this

[[NSApplication sharedApplication] teminate:??];

But the  terminate function takes an id for sender. What shall I use?


[[NSApplication sharedApplication] terminate:self]; works great.  
This is what I tend to use in smallish applications that don't need  
to do much else than simply terminate when asked to do so, and also  
terminate when the user closes the last window:


- (IBAction)terminate:(id)sender {
[[NSApplication sharedApplication] terminate:self];
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed: 
(NSApplication *)theApplication {

return YES;
}

- (id)init {
self = [super init];
if (self != nil) {
[[NSApplication sharedApplication] setDelegate:self];
}
return self;
}


Just in case:

to spare some electrons (at least for the source code), you can  
replace NSApplication sharedApplication] with NSApp.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Convert unicode string into ascii

2008-08-29 Thread Davide Scheriani

yes, it is for a small hex reader.
I need to read some old c64 file (.prg) then
visualize the hex and the ascii
so when I translate this:

01 08 0B 08 01 00 9E 32 30 36 31 00 00 00 A9 93
20 D2 FF A9 08 85 FC 8D 6B 10 A9 38 8D DC 17 A9
30 8D DB 17 A9 37 85 01 A9 13

I get this:

î2061	ì¢PêàU(6ìà3!pj0É1	7Ö	 2U	É 
¢2êRPêÇP⁄	ÖP	ÖQP)U0B• ÇRÉe$ÄÄê
00Q!)P)PE)•ê5ríÖ2íPê⁄É4BR Ñ  
B#x†1îX10$êRêX


so,not nice looking string :)

What I want to see after parsing is:

..2061..k..8.07

etc etc___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSXMLNode and NSXMLElement issue

2008-08-29 Thread Andrew R. Kinnie

Thanks, I have no idea how I missed that.

Exactly what I was looking for!

Andrew

On Aug 28, 2008, at 9:40 PM, Graff wrote:


On Aug 28, 2008, at 3:11 PM, Andrew R. Kinnie wrote:

I am attempting to programmatically create an html (rather, xhtml)  
document using NSXMLDocument, NSXMLElement, etc.


I am able to create the document and it works, but I am not sure  
how to create text which is not inside a paragraph or another tag  
which can be a node.


You can do that with the NSXMLNode class method textWithStringValue:

example:

	NSXMLElement *root = (NSXMLElement *)[NSXMLNode  
elementWithName:@"test"];
	NSXMLDocument *aDoc = [[NSXMLDocument alloc]  
initWithRootElement:root];


[root addChild:[NSXMLNode textWithStringValue:@"some text"]];

	NSString *aFile =  [@"~/Desktop/test.txt"  
stringByExpandingTildeInPath];

[[aDoc XMLData] writeToFile:aFile atomically:YES];

result:

some text

- Ken Bruno


___

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

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

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

This email sent to [EMAIL PROTECTED]


Image in NSOutlineView

2008-08-29 Thread mahaboob
Hi all,
I'm trying to develop an application that uses an OutlineView in which it
displays items like a disclosure triangle, then one checkbox, then a text
field int the same column. For that I gone through the
DragNDropOutlineview example provided with Xcode. Then I copied the
ImageAndTextCell class and uses two images, one is checked and other is
unchecked. Now the application works with  showing one image.I want to
change the image when clicking on it. How can I do that ?. In which method
I want to write the code ?
In outlineViewSelectionDidChange method I wrote some code but it faild.
When I taking the information about image like:
id cell = [[[OutlineView tableColumns] objectAtIndex:0]
dataCellForRow:[OutlineView selectedRow]];
id info = [cell image];
NSLog(@" %@",info);

It writes the log like:cell NSImage 0x17d8a0 Name=checkbox_click Size={13,
13} Reps=(
NSBitmapImageRep 0x17e0c0 Size={13, 13}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=13x13
Alpha=NO Planar=NO Format=1 CGImage=0x17ded0.
How can i get the Image name only ?

Thanks in advance

___

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

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

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

This email sent to [EMAIL PROTECTED]


Deploying project

2008-08-29 Thread mahaboob
Hi all,
I developed one application that uses some files.I can deploy the
application.
Now what I want is when double clicking the .app file in any system it
should be installed in a specific folder like :Macintosh HD | Library |
Application Support | Macware | TheProject. And also the files should be
copied into the folder like: Macintosh HD | Library | Application Support
| Macware | TheProject | Resources. How can I do that ? If the path is not
existing it should be created that path and installed. How can I achieve
this task ?

Thanks in advance

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Deploying project

2008-08-29 Thread Filip van der Meeren


On 29 Aug 2008, at 14:22, [EMAIL PROTECTED] wrote:


Hi all,
I developed one application that uses some files.I can deploy the
application.
Now what I want is when double clicking the .app file in any system it
should be installed in a specific folder like :Macintosh HD |  
Library |
Application Support | Macware | TheProject. And also the files  
should be
copied into the folder like: Macintosh HD | Library | Application  
Support
| Macware | TheProject | Resources. How can I do that ? If the path  
is not
existing it should be created that path and installed. How can I  
achieve

this task ?

Thanks in advance


Have you tried to use PackageMaker ?
It is located in your Utilities folder...




___

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

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

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


NSColorPanel picker mask

2008-08-29 Thread Ivy Feraco

Hello

I am having trouble customizing NSColorPanel.
I want the user to be able to pick colors for parts of the app using  
color wells.
But I need to have some color wells only allow grayscale while others  
can be set to the full range of color.


My solution for this was to have the NSColorPanel sometimes show all  
pickers and modes, while others would be confined to the grayscale mode.
It seems the only way I can create a grayscale-only picker (where the  
user has no color options) is by calling setPickerMask with a value  
NSColorPanelGrayModeMask.
But setPickerMask can only be called once before the shared instance  
is ever created.


Any ideas around this?
 I do have a solution that seems so work, where the sharedColorPanel  
gets destroyed so setPickerMask can be called again, but I'm wary of  
memory issues and this just seems silly.


Thanks!
Ivy Feraco
UI Developer
[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: Busy doing nothing

2008-08-29 Thread Phil
On Fri, Aug 29, 2008 at 9:42 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
> If I add these magic lines it will use 0.2% of my Cpu just doing nothing:
>
>NSMetadataQuery *query = [ [ NSMetadataQuery alloc] init];
>[ query startQuery ];
>[ query stopQuery ];
>NSArray *results = [ query results ];   //
>  _NSMetadataQueryResultArray
>[ query release ];
>
> From now on until quit I get every 100 msec  one Context Switch and two Mach
> System Calls - as observed via Activity Monitor.
>

It's noted in the documentation that using -results is "not
recommended due to performance and memory issues". My guess is that
Spotlight might be keeping something alive for it; you might want to
post this on the Spotlight-dev list, that's where the people who know
about Spotlight behind-the-scenes tend to hang out.

Phil
___

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

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

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

This email sent to [EMAIL PROTECTED]


Path animation with CGPathAddArcToPoint

2008-08-29 Thread Gordon Hughes
In my attempts to animate objects along a circular/elliptical path, I
naturally turned to CGPathAddEllipseToPoint.  Imagine a clock face with four
equidistant objects located on the path; I want the objects to animate 360
degrees from their start points.  Using the elliptical path, all four
objects consistently move to the 3 o'clock position, and rotate around the
path all stacked together before jumping back to their starting positions.
 When I then used CGPathAddArc, it behaved the same way - always starting at
the 3 o'clock position.  I'm guessing that both methods start and end the
path at that same position.
To get around this, I tried CGPathAddArcToPoint.  I know the path is being
laid out correctly, because when I draw it in a context, I get a perfect
circle.  I know that all my objects are sitting on the path, because I
verified this with CGPathContainsPoint.

In the case of CGPathAddEllipseToPoint and CGPathAddArc is there any way to
move the starting position of the ellipse/arc to a user-defined point?

The offending code from my CGPathAddArcToPoint implementation is below.
 Like I said, it draws a perfect circle, but I can't animate along it.  If I
replace the arcs with a single elliptical path, the animation works, but
from the wrong starting points.


Thanks in advance.
Gordon



CGPoint arc[8] =

{

CGPointMake(200.0, 300.0),

CGPointMake(300.0, 300.0),

CGPointMake(300.0, 200.0),

CGPointMake(300.0, 100.0),

CGPointMake(200.0, 100.0),

CGPointMake(100.0, 100.0),

CGPointMake(100.0, 200.0),

CGPointMake(100.0, 300.0),

};



CGMutablePathRef thePath = CGPathCreateMutable();

CGPathMoveToPoint(thePath, NULL, arc[0].x, arc[0].y);

CGPathAddArcToPoint(thePath, NULL, arc[1].x, arc[1].y, arc[2].x, arc[2].y,
100.0);

CGPathAddArcToPoint(thePath, NULL, arc[3].x, arc[3].y, arc[4].x, arc[4].y,
100.0);

CGPathAddArcToPoint(thePath, NULL, arc[5].x, arc[5].y, arc[6].x, arc[6].y,
100.0);

CGPathAddArcToPoint(thePath, NULL, arc[7].x, arc[7].y, arc[0].x, arc[0].y,
100.0);

CGPathCloseSubpath(thePath);


CAKeyframeAnimation *followPath = [CAKeyframeAnimation animationWithKeyPath:
@"position"];

followPath.path = thePath;

followPath.delegate = self;

followPath.duration = animationDuration;

followPath.calculationMode = kCAAnimationPaced;

followPath.timingFunction = [CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut];

return followPath;
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableColumn not usable with binder of class NSTextValueBinder?

2008-08-29 Thread Dave Dribin

On Aug 27, 2008, at 1:34 AM, Ron Lue-Sang wrote:


Woah.
If you really want to use a custom cell, you're gonna want a custom  
column as well. The bindings for the tableColumn come from the  
tableColumn's dataCell's available bindings. Yea, as you've found,  
NSActionCell has a value binding, not plain old NSCell.


[.. snip ..]

Does any of this make sense?
Possibly, you've already solved this some other way, but hopefully  
I've cleared up a couple of things.


Yeah, this all mostly makes sense.  I'm content just subclassing  
NSActionCell for this case, though.


FWIW, what I am trying to do is create a circular, nondeterminate (pie  
chart style) progress indicator cell and use it in a table column.  So  
it's just doing some drawing based on objectValue (I'm using nil to  
mean hide the progress).  Of course, I want to use bindings to hook  
this up to my model, too.  Subclassing NSCell and binding the column's  
"value" seemed like the best approach.


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


Image in NSOutlineView

2008-08-29 Thread mahaboob pa
Hi all,
I'm trying to develop an application that uses an OutlineView in which it
displays items like a disclosure triangle, then one checkbox, then a text
field int the same column. For that I gone through the DragNDropOutlineview
example provided with Xcode. Then I copied the ImageAndTextCell class and
uses two images, one is checked and other is unchecked. Now the application
works with  showing one image.I want to change the image when clicking on
it. How can I do that ?. In which method I want to write the code ?
In outlineViewSelectionDidChange method I wrote some code but it faild. When
I taking the information about image like:
id cell = [[[OutlineView tableColumns] objectAtIndex:0]
dataCellForRow:[OutlineView selectedRow]];
id info = [cell image];
NSLog(@" %@",info);

It writes the log like:cell NSImage 0x17d8a0 Name=checkbox_click Size={13,
13} Reps=(
NSBitmapImageRep 0x17e0c0 Size={13, 13}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=13x13 Alpha=NO
Planar=NO Format=1 CGImage=0x17ded0.
How can i get the Image name only ?

Thanks in advance
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: programatically quit a program

2008-08-29 Thread Ben Stiglitz
What is the correct way to quit a cocoa app?  I could use C exit()  
but that

would loose the chance to invoke the right callbacks for clean up.



FWIW, if you don’t have any termination delegate methods of your own,  
and don’t have any user defaults that might not be synchronized, it’s  
safe to call exit().


-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: Image in NSOutlineView

2008-08-29 Thread Ben Stiglitz
I'm trying to develop an application that uses an OutlineView in  
which it
displays items like a disclosure triangle, then one checkbox, then a  
text

field int the same column. For that I gone through the
DragNDropOutlineview example provided with Xcode. Then I copied the
ImageAndTextCell class and uses two images, one is checked and other  
is

unchecked. Now the application works with  showing one image.I want to
change the image when clicking on it. How can I do that ?. In which  
method

I want to write the code ?


Instead of an image with a check box on it, you can add a table view  
column to the outline view with an NSButtonCell of the appropriate  
style as its prototype.


-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: Convert unicode string into ascii

2008-08-29 Thread Gary L. Wade
Maybe I'm missing something from your example, previous postings, and my ISP's 
web mail client, but it appears your desired output doesn't seem to match in 
character count to your original text.  Nevertheless, if all you want is to 
turn low-ASCII (values less than 0x20) and high-ASCII (values greater than 
0x7F) into period characters, you'd find better performance and flexibility for 
your particular needs by simply writing a function that takes an unsigned 8-bit 
integer (e.g., in a loop, 0x01, 0x08, 0x0B, ..., 0x13) and returns the desired 
character.  In that function, do your test for low-ASCII and high-ASCII, 
returning the period character in those cases, and the supplied character in 
all other cases.  Since this code is pretty trivial, you could even inline it 
rather than code it into a separate function, but I don't know if you need to 
call it in more than one place in your code.

>yes, it is for a small hex reader.
>I need to read some old c64 file (.prg) then
>visualize the hex and the ascii
>so when I translate this:
>
>01 08 0B 08 01 00 9E 32 30 36 31 00 00 00 A9 93
>20 D2 FF A9 08 85 FC 8D 6B 10 A9 38 8D DC 17 A9
>30 8D DB 17 A9 37 85 01 A9 13
>
>I get this:
>
>î2061 ì¢PêàU(6ìà3!pj0É17Ö  2UÉ 
>¢2êRPêÇP⁄ ÖP ÖQP)U0B• ÇRÉe$ÄÄê
>00Q!)P)PE)•ê5ríÖ2íPê⁄É4BR Ñ  
>B#x†1îX10$êRêX
>
>so,not nice looking string :)
>
>What I want to see after parsing is:
>
>..2061..k..8.07
>
>etc etc___
___

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

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

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

This email sent to [EMAIL PROTECTED]


What to use observeValueForKeyPath: context

2008-08-29 Thread Dave Dribin

Hi all,

It seems that KVO best practice is to use the "context" in  
observeValueForKeyPath:ofObject:change:context: to differentiate  
between different key paths, rather than check key path strings for  
equality.  Since context is a void *, it also seems best practice to  
just use some unique pointer values.  For example, mmalc's Graphics  
Bindings sample does this:


static void *PropertyObservationContext = (void *)1091;
static void *GraphicsObservationContext = (void *)1092;
static void *SelectionIndexesObservationContext = (void *)1093;

I'm not quite understanding the point of using number values like  
this, though.  Won't using unique string literals (char * or NSString  
*) also work?


static NSString *PropertyObservationContext = @"Property Context";
static NSString *GraphicsObservationContext = @"Graphics Context";
static NSString *SelectionIndexesObservationContext = @"Selection  
Indexes Context";


Is there some benefit to using number values over string constants, or  
is it just stylistic differences?


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: What to use observeValueForKeyPath: context

2008-08-29 Thread Phil
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]> wrote:
> Is there some benefit to using number values over string constants, or is it
> just stylistic differences?
>

Using NSStrings (or any other object) will work fine, but comparing
two primitive numbers is a lot faster than comparing to strings.

Personally, I wouldn't use arbitary numbers for any pointer value
(even a context variable like this), but that's just my stylistic
difference.

Phil
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread Dave Dribin

On Aug 29, 2008, at 10:03 AM, Phil wrote:
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]>  
wrote:
Is there some benefit to using number values over string constants,  
or is it

just stylistic differences?



Using NSStrings (or any other object) will work fine, but comparing
two primitive numbers is a lot faster than comparing to strings.


As long as the pointers point to unique objects (and they remain valid  
even in a GC world), you just need to compare their pointer value.  So  
even with this:


static NSString *PropertyObservationContext = @"Property Context";

You can still check (context == PropertyObservationContext) in  
observeValueForKeyPath:ofObject:change:context:.



Personally, I wouldn't use arbitary numbers for any pointer value
(even a context variable like this), but that's just my stylistic
difference.


I generally wouldn't either, unless there's some benefit I'm not seeing.

-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: Image in NSOutlineView

2008-08-29 Thread Corbin Dunn
You'll want to look at the PhotoSearch demo I presented at WWDC a few  
years ago. It shows how to do exactly what you are talking about  
(well, it is similar, but the concepts should be the same).


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

corbin

On Aug 29, 2008, at 5:08 AM, mahaboob pa wrote:


Hi all,
I'm trying to develop an application that uses an OutlineView in  
which it
displays items like a disclosure triangle, then one checkbox, then a  
text
field int the same column. For that I gone through the  
DragNDropOutlineview
example provided with Xcode. Then I copied the ImageAndTextCell  
class and
uses two images, one is checked and other is unchecked. Now the  
application
works with  showing one image.I want to change the image when  
clicking on

it. How can I do that ?. In which method I want to write the code ?
In outlineViewSelectionDidChange method I wrote some code but it  
faild. When

I taking the information about image like:
id cell = [[[OutlineView tableColumns] objectAtIndex:0]
dataCellForRow:[OutlineView selectedRow]];
   id info = [cell image];
   NSLog(@" %@",info);

It writes the log like:cell NSImage 0x17d8a0 Name=checkbox_click  
Size={13,

13} Reps=(
   NSBitmapImageRep 0x17e0c0 Size={13, 13}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=13x13  
Alpha=NO

Planar=NO Format=1 CGImage=0x17ded0.
How can i get the Image name only ?


___

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

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

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

This email sent to [EMAIL PROTECTED]


NSPredicateEditorRowTemplates and preserving user input

2008-08-29 Thread Jim Turner
Hi List,

I noticed something today while building a new popup-popup-popup
template: when the user changes the comparator (a simple is/is not in
my case), the third popup resets itself to the default value instead
of maintaining the selection the user had already chosen.  The same is
true if the third view in my template is a text field.  If they enter
text, then change the value from "contains" to "begins with", the text
they've entered is removed.

I understand that templates are copied like mad behind the scenes of
the editor and that popups are treated differently, but I'm not sure
how I go about fixing this.  I tried subclassing NSPopUpButton to see
what is passed for setObjectValue but the editor doesn't seem to like
a subclassed NSPopUpButton.  Instead, it ignores it and displays
nothing.  Very strange.

Any thoughts on where I should start looking?  Thanks

-- 
Jim
http://nukethemfromorbit.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: File Extensions Problem

2008-08-29 Thread Michael Ash
On Thu, Aug 28, 2008 at 9:50 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
> While if fully agree with you about valid assumptions and so, I am still
> wondering what is the disadvantage of forgetting about NSEnumerator, Fast
> Enumeration and the like and simply doing:
>
> unsigned count = [ array count ];
> if ( count == 0 ) return;
> for( unsigned i = count - 1;; i--)
> {
>id a = [ array objectAtIndex: i ];
>if ( a is not nice ) [ array removeObjectAtIndex: i ];
>if ( i == 0 ) break;
> }
>
> Maybe not "Fast" as in "Fast Enumeration" but maybe simpler and faster than
> copying all the "nice" objects into a secondary array.

The disadvantage is simply that it's more code (and therefore more
potential for bugs) and it may be slower.

If performance were not a concern then I'd much prefer something like this:

for(id obj in [NSArray arrayWithArray: array])
if( condition(obj) )
[array removeObject:obj];

And if performance is a concern, I'd probably prefer something like this:

NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
unsigned index = 0;
for( id obj in array )
{
if(condition(obj))
[indexes addIndex:index];
index++;
}
[array removeObjectsAtIndexes:indexes];

But this is really getting into the realm of personal preference.
Certainly I can't tell you whether this is faster than yours or not,
and the amount of code is such that I wouldn't say that it's
absolutely obvious that it's prettier.

And lastly I just want to note that if your condition fits easily into
an NSPredicate, you can do this whole business as a simple one-liner.

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: What to use observeValueForKeyPath: context

2008-08-29 Thread Ron Lue-Sang


On Aug 29, 2008, at 8:13 AM, Dave Dribin wrote:


On Aug 29, 2008, at 10:03 AM, Phil wrote:
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]>  
wrote:
Is there some benefit to using number values over string  
constants, or is it

just stylistic differences?



Using NSStrings (or any other object) will work fine, but comparing
two primitive numbers is a lot faster than comparing to strings.


As long as the pointers point to unique objects (and they remain  
valid even in a GC world), you just need to compare their pointer  
value.  So even with this:


static NSString *PropertyObservationContext = @"Property Context";

You can still check (context == PropertyObservationContext) in  
observeValueForKeyPath:ofObject:change:context:.


I do this as well…  sorta… My dao is usually

static NSString *ABCFooPropertyObservingContext;

observeValueFoKeyPath:
(context == &ABCFooPropertyObservingContext) that way you don't use up  
space for char storage. Yea, that amount of storage probably doesn't  
matter, but "probably" isn't "definitely"   =)


I (and some coworkers) have also done plain old

static void* ABCblahblahContext;






Personally, I wouldn't use arbitary numbers for any pointer value
(even a context variable like this), but that's just my stylistic
difference.


I generally wouldn't either, unless there's some benefit I'm not  
seeing.


-Dave





--
RONZILLA



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Quitting all active applications

2008-08-29 Thread Michael Ash
On Thu, Aug 28, 2008 at 1:52 PM, Martin Stoufer <[EMAIL PROTECTED]> wrote:
> I had always naively assumed that all the some *Framework underneath an app
> was setting up signal handlers for you with default behaviours. If this
> isn't the case, then yes any killall approach will cause loss of data.
>
> Now I'm interested into finding out why this isn't the case.

Signals are a very poor mechanism for this. Apple Events provide two
important semantics:

1) They allow for an "I'm finished" reply. This allows the sender to
find out when the target is done with its business, so that it can
allow the sender to take a tenth of a second or a hundred seconds as
it needs.

2) They allow for an "I'm not ready to quit yet" reply. You'll see
this in action if you try to log out when you have unsaved documents
in an application, and you click Cancel when it asks you whether you
want to save.

Signals don't support either of these. For #1, the standard technique
is to do a SIGTERM, wait one second, then do a SIGKILL to anybody
who's still left alive. This is less than ideal for what should be
obvious reasons. For #2, the possibility that a target might abort the
action is simply ignored. Targets die when they are killed, end of
story.

Consider what happens when you send a quit Apple Event to TextEdit
when you have an unsaved document open. You get a nice window asking
if you want to save, and letting you cancel. Now compare with what
happens when you send SIGTERM to pico or emacs with an unsaved
document open. They terminate instantaneously and take all of your
work down with them.

Now, there's nothing preventing the frameworks from installing a
handler for SIGTERM and closing down more gracefully. But the
convention is for SIGTERM to kill you very quickly, and a process is
only expected to clean up critical resources that might otherwise be
corrupted. Since a mechanism already exists for the "user-friendly
quit", there's not too much point in changing the meaning of SIGTERM
as well.

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: What to use observeValueForKeyPath: context

2008-08-29 Thread Michael Ash
On Fri, Aug 29, 2008 at 10:56 AM, Dave Dribin <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> It seems that KVO best practice is to use the "context" in
> observeValueForKeyPath:ofObject:change:context: to differentiate between
> different key paths, rather than check key path strings for equality.  Since
> context is a void *, it also seems best practice to just use some unique
> pointer values.  For example, mmalc's Graphics Bindings sample does this:
>
> static void *PropertyObservationContext = (void *)1091;
> static void *GraphicsObservationContext = (void *)1092;
> static void *SelectionIndexesObservationContext = (void *)1093;
>
> I'm not quite understanding the point of using number values like this,
> though.  Won't using unique string literals (char * or NSString *) also
> work?

This (void *)1091 business seems highly dangerous to me. After all,
what prevents somebody else from using 1091 too? If everybody uses a
pointer value that's guaranteed to be unique (like a unique string
literal) then you know you're safe.

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: What to use observeValueForKeyPath: context

2008-08-29 Thread Dave Dribin

On Aug 29, 2008, at 11:27 AM, Michael Ash wrote:

This (void *)1091 business seems highly dangerous to me. After all,
what prevents somebody else from using 1091 too? If everybody uses a
pointer value that's guaranteed to be unique (like a unique string
literal) then you know you're safe.


It really just needs to be unique in your class hierarchy, right?   
But, yeah, it still seems dangerous.  I mean, what number do you start  
using, and what if your class hierarchy changes?


I'm liking Ron's way, because that's guaranteed to be a unique pointer  
value.  I still like the static string, too, but it sounds like in  
order to ensure uniqueness of the string within a class hierarchy, it  
may be a good idea to put the class name in there.  Two classes using  
static @"Property Context" should still be unique, unless the linker  
does some cross-module string literal optimization so that there's  
only a single @"Property Context" string literal in the entire  
binary.  I don't think it does now, but perhaps with LLVM it'll do  
more aggressive optimizations like this.


-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: What to use observeValueForKeyPath: context

2008-08-29 Thread Keith Duncan

After all, what prevents somebody else from using 1091 too?


Nothing whatsoever. But that isn't a problem. So long as the  
observation context remains internal it doesn't have to be universally  
unique.


If you're performing [anotherObjectNotSelf addObserver... then yes,  
I'd make sure that the context is unique, so that it doesn't conflict  
with an internal context.


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: What to use observeValueForKeyPath: context

2008-08-29 Thread Jim Correia

On Aug 29, 2008, at 10:56 AM, Dave Dribin wrote:

It seems that KVO best practice is to use the "context" in  
observeValueForKeyPath:ofObject:change:context: to differentiate  
between different key paths, rather than check key path strings for  
equality.  Since context is a void *, it also seems best practice to  
just use some unique pointer values.  For example, mmalc's Graphics  
Bindings sample does this:


static void *PropertyObservationContext = (void *)1091;
static void *GraphicsObservationContext = (void *)1092;
static void *SelectionIndexesObservationContext = (void *)1093;


Your KVO context has to be unique.

If you use 1091, there is no way to guarantee that any of your  
subclasses or superclasses aren't also using that magic number, so  
this sets you up for possible failure.


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]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread mmalc crawford


On Aug 29, 2008, at 7:56 AM, Dave Dribin wrote:

Since context is a void *, it also seems best practice to just use  
some unique pointer values.  For example, mmalc's Graphics Bindings  
sample does this:

static void *PropertyObservationContext = (void *)1091;
static void *GraphicsObservationContext = (void *)1092;
static void *SelectionIndexesObservationContext = (void *)1093;

Sorry about that -- I think I put them in there originally when I was  
testing things, and they stuck.

Fixing them now...

mmalc

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread Jim Correia

On Aug 29, 2008, at 12:43 PM, Keith Duncan wrote:


After all, what prevents somebody else from using 1091 too?


Nothing whatsoever. But that isn't a problem. So long as the  
observation context remains internal it doesn't have to be  
universally unique.


It has to be unique within an inheritance hierarchy.

The context is the only thing you use to determine if an - 
observeValueForKeyPath:... was meant for you, or for one of your  
superclasses.


If you use a magic number, you have no guarantee that a superclass  
didn't also use the same magic number. Solution: don't use magic  
numbers.


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]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread Michael Ash
On Fri, Aug 29, 2008 at 12:41 PM, Dave Dribin <[EMAIL PROTECTED]> wrote:
> On Aug 29, 2008, at 11:27 AM, Michael Ash wrote:
>>
>> This (void *)1091 business seems highly dangerous to me. After all,
>> what prevents somebody else from using 1091 too? If everybody uses a
>> pointer value that's guaranteed to be unique (like a unique string
>> literal) then you know you're safe.
>
> It really just needs to be unique in your class hierarchy, right?

True, but not particularly useful. Your class hierarchy includes
NSObject, which is free to observe whatever it feels like in your
objects.

> I'm liking Ron's way, because that's guaranteed to be a unique pointer
> value.  I still like the static string, too, but it sounds like in order to
> ensure uniqueness of the string within a class hierarchy, it may be a good
> idea to put the class name in there.  Two classes using static @"Property
> Context" should still be unique, unless the linker does some cross-module
> string literal optimization so that there's only a single @"Property
> Context" string literal in the entire binary.  I don't think it does now,
> but perhaps with LLVM it'll do more aggressive optimizations like this.

I agree. If you use a constant string, you should make sure that the
string *contents* are unique, in order to ensure uniqueness of the
pointer to it. So don't call it @"context", use @"MyFunkyClass KVO
observer context". After all there's no penalty for being verbose in
this case. Of course using a pointer to a global solves this too.

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]


Help with "ditto"

2008-08-29 Thread Dale Jensen
I sure wish that some of these command line tools had weird names so  
that google was more helpful.


If I have a file that I've compressed with ditto and navigate to it in  
the Finder and double click on it, it extracts the file in the same  
directory, as expected.


If, however, I use NSTask to send "ditto -x -k Resume080622.docx.zip  
Resume080622.docx" (assuming proper directories, of course,) ditto  
creates a folder with the name "Resume080622.docx" and then puts the  
file in that.  This screws up a lot of things, as you can imagine.   
Any idea what I have to do or what argument to pass to get it to  
extract just the file, not embedded in another folder.


Thanks!


dale

--
Dale Jensen, CEO
Ntractive, LLC
[EMAIL PROTECTED]
http://www.ntractive.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: What to use observeValueForKeyPath: context

2008-08-29 Thread j o a r


On Aug 29, 2008, at 9:56 AM, Michael Ash wrote:


It really just needs to be unique in your class hierarchy, right?


True, but not particularly useful. Your class hierarchy includes
NSObject, which is free to observe whatever it feels like in your
objects.



No this is not generally true, so just forget about that and instead  
ensure that the context pointers are globally unique.




If you use a constant string, you should make sure that the
string *contents* are unique, in order to ensure uniqueness of the
pointer to it. So don't call it @"context", use @"MyFunkyClass KVO
observer context". After all there's no penalty for being verbose in
this case. Of course using a pointer to a global solves this too.



The penalty for using constant strings is that they will end up  
wasting space in your binary...

Rons suggestion is probably optimal.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help with "ditto"

2008-08-29 Thread Randall Meadows

On Aug 29, 2008, at 11:19 AM, Dale Jensen wrote:

I sure wish that some of these command line tools had weird names so  
that google was more helpful.


If I have a file that I've compressed with ditto and navigate to it  
in the Finder and double click on it, it extracts the file in the  
same directory, as expected.


If, however, I use NSTask to send "ditto -x -k Resume080622.docx.zip  
Resume080622.docx" (assuming proper directories, of course,) ditto  
creates a folder with the name "Resume080622.docx" and then puts the  
file in that.  This screws up a lot of things, as you can imagine.   
Any idea what I have to do or what argument to pass to get it to  
extract just the file, not embedded in another folder.


According to the fourth form described by 'man ditto', you are  
explicitly giving a destination directory, so you're getting exactly  
what you asked for!


Instead of specifying the file name where you want the output to go  
(which is wrong, according to the man page), specify the directory  
where you want the output to go, which should be "." (meaning the  
current directory).


ditto -x -k Resume080622.docx.zip .


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread Dave Dribin

On Aug 29, 2008, at 12:23 PM, j o a r wrote:
The penalty for using constant strings is that they will end up  
wasting space in your binary...

Rons suggestion is probably optimal.


I'm definitely leaning towards that way, now.  Though I may combine  
both for debugging.


static NSString *PropertyObservationContext = @"Property Context";

Use &PropertyObservationContext as the context.  This way you could  
"po *(id *)context" in gdb for a human readable context.


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


Bindings: Specifying the Class of a Controlle r’s Content

2008-08-29 Thread Oleg Krupnov
Here's a fragment of documentation from the "Cocoa Bindings
Programming Topics" guide:

"In order for a controller to create new content objects automatically
or in response to the target-action methods, it must know the
appropriate class to use."

My question is: what is a real example of a case when the controller
needs to create new content objects?

As far as I see, it can only happen when a view sends addObject to the
controller, but in that case the object is already created and the
controller simply adds it to the collection. Have I missed something?

Also, if the controller does need to know the class/entity of the
content object, what about polymorphic objects? I.e. I have one
abstract entity "Shape" which is not directly instantiatable, and a
few concrete subclasses. What entity should I specify?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help with "ditto"

2008-08-29 Thread Dale Jensen

On Aug 29, 2008, at 12:29 PM, Randall Meadows wrote:


On Aug 29, 2008, at 11:19 AM, Dale Jensen wrote:

I sure wish that some of these command line tools had weird names  
so that google was more helpful.


If I have a file that I've compressed with ditto and navigate to it  
in the Finder and double click on it, it extracts the file in the  
same directory, as expected.


If, however, I use NSTask to send "ditto -x -k  
Resume080622.docx.zip Resume080622.docx" (assuming proper  
directories, of course,) ditto creates a folder with the name  
"Resume080622.docx" and then puts the file in that.  This screws up  
a lot of things, as you can imagine.  Any idea what I have to do or  
what argument to pass to get it to extract just the file, not  
embedded in another folder.


According to the fourth form described by 'man ditto', you are  
explicitly giving a destination directory, so you're getting exactly  
what you asked for!


Instead of specifying the file name where you want the output to go  
(which is wrong, according to the man page), specify the directory  
where you want the output to go, which should be "." (meaning the  
current directory).


ditto -x -k Resume080622.docx.zip .



Thanks, that fixed it for those singleton files.  However, now it  
breaks packages (puts the contents of the packages into the directory  
instead of into the "package directory".)  With the previous  
rendition, packages worked perfectly.  Aside from tracking what's in  
the archive, any ideas on what I need to change to have both types of  
files unzip correctly (packages into a same named folder, singletons  
into no folder)?


Thanks again,


dale

--
Dale Jensen, CEO
Ntractive, LLC
[EMAIL PROTECTED]
http://www.ntractive.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: Bindings: Specifying the Class of a Con troller’s Content

2008-08-29 Thread Dave Dribin

On Aug 29, 2008, at 12:38 PM, Oleg Krupnov wrote:

My question is: what is a real example of a case when the controller
needs to create new content objects?


-[NSArrayController add:] ? You can use that as an action for a button  
in IB.


-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: Busy doing nothing

2008-08-29 Thread Gerriet M. Denkmann


On 29 Aug 2008, at 20:57, Phil wrote:


On Fri, Aug 29, 2008 at 9:42 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
If I add these magic lines it will use 0.2% of my Cpu just doing  
nothing:


   NSMetadataQuery *query = [ [ NSMetadataQuery alloc] init];
   [ query startQuery ];
   [ query stopQuery ];
   NSArray *results = [ query results ];   //
 _NSMetadataQueryResultArray
   [ query release ];

From now on until quit I get every 100 msec  one Context Switch  
and two Mach

System Calls - as observed via Activity Monitor.



It's noted in the documentation that using -results is "not
recommended due to performance and memory issues".


My (Tiger) documentation says: "While it is possible to copy the  
proxy array and receive a “snapshot” of the complete current query  
results, it is generally not recommended due to performance and  
memory issues."
(I had read this, but as I never copied the array, I thought it would  
be ok.)


It continues: "you should instead use the resultCount and  
resultAtIndex: methods."
Following this advice I succeeded in bringing the idle Cpu-time to 0%  
in one app.

Thanks for pointing me in the right direction!

But the documentation also says: "The results array is a proxy object  
that is primarily intended for use with Cocoa bindings."
And I have another app, where I never use "results" directly, but  
which has an NSTableColumn bound via an NSArrayController to "results".

And this app also uses 0.2% Cpu while doing nothing.

Same behaviour in: /Developer/Examples/AppKit/Spotlighter.


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]


Checking for memory leaks with Instruments

2008-08-29 Thread Christian Giordano
Hi guys, I'm new to Objective-C and didn't have so much experience, in
general, with manual managed memory. Despite I'm using Objective-C 2.0
I'm keen on not using the autorelease garbage collector. I'm try to
understand if my application has memory leaks using Instruments. To
check the total ram used I'm checking in Memory Monitor the Real
Memory assigned to the process. Unfortunately this increases and makes
me think that there is a memory leak. On th e Leaks Instrument though,
no leak is shown. I can't really find why the ram continues to
increase, and my app is really simple. I tested then a sample app from
apple and this a part having an increase memory usage, like mine, also
shown some memory leaks in the related instrument. What am I missing?
I there a recommended tutorial to interpret the data from Instruments?
I followed this tutorial as well but no leak was found on my app.

http://www.cimgf.com/2008/04/02/cocoa-tutorial-fixing-memory-leaks-with-instruments/


Best, chr
___

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

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

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

This email sent to [EMAIL PROTECTED]


Dynamic right-sizing of TextContainer

2008-08-29 Thread Martin Stoufer
I am able to set the initial height/width of the NSTextContainer object 
of a NSTextView object in IB. However, I cannot find any method that 
will allow the programmatic re-sizing of the container when the text I'm 
adding exceeds this size.


Optimally, I'd like to utilize the setContainerSize with an NSSize 
object that just handles the amount of text that needs displaying (I'm 
leaving the scrolling behavior up to NSScrollView).


Currently, I'm just punting with the following in awakeFromNib:

   [decimalStringView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
   [decimalStringView setVerticallyResizable:YES];
   [[decimalStringView textContainer] 
setContainerSize:NSMakeSize([decimalStringView minSize].width, FLT_MAX)];


This guarantees that any string I will generate will fit in.

Where I am stuck is the height calculation for an NSSize object given a 
string of length N. For my purposes, the width will stay fixed. Since I 
know the font size (12 pt) and assuming the leading of the layout is 
fixed and measurable (~6px), I could calculate a new total pixel height 
if needed.


Is this the way to go, or should I just leave the height at the system max?

--
* Martin C. Stoufer  *
* ISS/IT *
* Lawrence Berkeley National Lab *
* 510-486-5306   *
* MS 937-700 *



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: Checking for memory leaks with Instruments

2008-08-29 Thread I. Savant
On Fri, Aug 29, 2008 at 2:08 PM, I. Savant <[EMAIL PROTECTED]> wrote:

>  Without more (a LOT more) information about your application, it's
> hard (if not impossible) to tell you where your problem is.

  Sorry, I hit send before adding this: Try the "Object Allocations"
instrument (read the documentation regarding how to use it) and see
what's getting created. I bet you'll find a lot of one type of object
being created by your own application. Any code responsible for doing
that is your most likely starting point.

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


Convert unicode string into ascii

2008-08-29 Thread Davide Scheriani

this is a cool idea.
mapping into an array all the chars I need and run the parse..
quite cool.tnx!
I need to call the parse only one time after loaded the .prg C64 file.



Maybe I'm missing something from your example, previous postings,  
and my ISP's web mail client, but it appears your desired output  
doesn't seem to match in character count to your original text.   
Nevertheless, if all you want is to turn low-ASCII (values less than  
0x20) and high-ASCII (values greater than 0x7F) into period  
characters, you'd find better performance and flexibility for your  
particular needs by simply writing a function that takes an unsigned  
8-bit integer (e.g., in a loop, 0x01, 0x08, 0x0B, ..., 0x13) and  
returns the desired character.  In that function, do your test for  
low-ASCII and high-ASCII, returning the period character in those  
cases, and the supplied character in all other cases.  Since this  
code is pretty trivial, you could even inline it rather than code it  
into a separate function, but I don't know if you need to call it in  
more than one place in your code.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File Extensions Problem

2008-08-29 Thread Gerriet M. Denkmann


On Fri, 29 Aug 2008 12:13:34 -0400, "Michael Ash"  
<[EMAIL PROTECTED]> wrote:


On Thu, Aug 28, 2008 at 9:50 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
While if fully agree with you about valid assumptions and so, I am  
still
wondering what is the disadvantage of forgetting about  
NSEnumerator, Fast

Enumeration and the like and simply doing:

unsigned count = [ array count ];
if ( count == 0 ) return;
for( unsigned i = count - 1;; i--)
{
   id a = [ array objectAtIndex: i ];
   if ( a is not nice ) [ array removeObjectAtIndex: i ];
   if ( i == 0 ) break;
}

Maybe not "Fast" as in "Fast Enumeration" but maybe simpler and  
faster than

copying all the "nice" objects into a secondary array.


The disadvantage is simply that it's more code (and therefore more
potential for bugs) and it may be slower.

If performance were not a concern then I'd much prefer something  
like this:


for(id obj in [NSArray arrayWithArray: array])
if( condition(obj) )
[array removeObject:obj];

And if performance is a concern, I'd probably prefer something like  
this:


NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
unsigned index = 0;
for( id obj in array )
{
if(condition(obj))
[indexes addIndex:index];
index++;
}
[array removeObjectsAtIndexes:indexes];

But this is really getting into the realm of personal preference.
Certainly I can't tell you whether this is faster than yours or not,
and the amount of code is such that I wouldn't say that it's
absolutely obvious that it's prettier.

And lastly I just want to note that if your condition fits easily into
an NSPredicate, you can do this whole business as a simple one-liner.


You are right. removeObjectsAtIndexes: is much better than my  
suggestion. I did not know about this method.

Another thing I should check out is NSPredicate.

Thanks for enlightening me!


Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dynamic right-sizing of TextContainer

2008-08-29 Thread Douglas Davidson


On Aug 29, 2008, at 11:01 AM, Martin Stoufer wrote:

I am able to set the initial height/width of the NSTextContainer  
object of a NSTextView object in IB. However, I cannot find any  
method that will allow the programmatic re-sizing of the container  
when the text I'm adding exceeds this size.


Don't do this.  NSTextView handles this automatically for you.  See / 
Developer/Examples/AppKit/TextSizingExample for examples of various  
different ways to set up a text view depending on how you want it to  
resize vertically, horizontally, etc.  If the width is fixed and you  
just want the container to size properly vertically, you don't need to  
do anything; the stock NSTextView you create in IB should be fine.


Douglas Davidson

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Checking for memory leaks with Instruments

2008-08-29 Thread I. Savant
On Fri, Aug 29, 2008 at 1:49 PM, Christian Giordano
<[EMAIL PROTECTED]> wrote:

> On th e Leaks Instrument though,
> no leak is shown. I can't really find why the ram continues to
> increase, and my app is really simple. I tested then a sample app from
> apple and this a part having an increase memory usage, like mine, also
> shown some memory leaks in the related instrument. What am I missing?
> I followed this tutorial as well but no leak was found on my app.

  Maybe because there ARE no leaks. :-) Have you considered that you
might have some container sitting around somewhere (an array or a set)
that keeps collecting stuff and not letting go? A 'leak' is (in
general) an object with no reference with a retain count >0 ... it
will never be released and this is a memory management error. Runaway
memory usage is not necessarily a leak, however.

  Without more (a LOT more) information about your application, it's
hard (if not impossible) to tell you where your problem is.

--
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: What to use observeValueForKeyPath: context

2008-08-29 Thread Dave Dribin

On Aug 29, 2008, at 12:35 PM, Dave Dribin wrote:

On Aug 29, 2008, at 12:23 PM, j o a r wrote:
The penalty for using constant strings is that they will end up  
wasting space in your binary...

Rons suggestion is probably optimal.


I'm definitely leaning towards that way, now.  Though I may combine  
both for debugging.


static NSString *PropertyObservationContext = @"Property Context";

Use &PropertyObservationContext as the context.  This way you could  
"po *(id *)context" in gdb for a human readable context.


I've filed rdar://problem/6185473 to update the "Key-Value Observing  
Programming Guide" about proper use of the context.  The doc doesn't  
even use the context at all.


-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: What to use observeValueForKeyPath: context

2008-08-29 Thread Keith Duncan
Use &PropertyObservationContext as the context.  This way you could  
"po *(id *)context" in gdb for a human readable context.


That was my main concern of using the address of a static variable,  
but combining the two approaches works nicely.


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]


Explanation

2008-08-29 Thread J. Todd Slack

Hi All,

Continuing learning the Quicktime API.

I am confused about QTTimeRanges, etc

Consider the following:

QTMovie *aQTMovie = [QTMovie movieWithFile:path error:nil];

[aQTMovie setAttribute:[NSNumber numberWithBool:YES]  
forKey:QTMovieEditableAttribute];


QTTime qStartTime = QTMakeTime([starttime intValue], 1);
QTTime qDuration = QTMakeTime([duration intValue], 1);

QTTimeRange aQTMovieRange = 

[aQTMovie SetSelection: aQTMovieRange];
[aQTMovie replaceSelectionWithSelectionFromMovie: aQTMovie];

I have 2 QTTime's and I want to take my QTMovie and clip out the  
section between time A and time B


This is the example I found:

// set the duration to 10 seconds
QTTimeRange range = QTMakeTimeRange(QTZeroTime, [movie duration]);
[movie scaleSegment:range newDuration:QTMakeTime(10, 1)];

But what I dont understand is when you scaleSegment the use of range  
and such for my case. I want to take a clip from 10 seconds to 35  
seconds.


Can anyone demonstrate?

-Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Cocoa Developer Needed - San Jose, Ca

2008-08-29 Thread Darren Tessitore

Software Developer - COCOA

Company:Confidential
Job ID#:8082102
# of Positions: 1
Posted: Aug 21, 2008
Job Type:   Full Time Permanent or Contract on-site
Location:   San Jose, Ca
Contact:Darren Tessitore ([EMAIL PROTECTED])

Position Description:

Our client is a leading data forensics firm, and they are seeking  
developers with significant GUI experience to join a growing team  
building both electronic discovery and data forensic applications.  
This position requires strong Mac development experience and  
specifically Cocoa expertise. They are seeking candidates with product  
design, development, and release experience with particular expertise  
designing innovative and elegant user experiences. Our client is  
committed to developing the most innovative technology available to  
law enforcement and corporate clients. We are seeking balanced  
candidates, capable of contributing to specific client engagements, as  
well as to the overall innovation of the firm. Successful completion  
of a background investigation is required.


Qualifications:

◦   Five (5+) years product design / development experience.
◦   Strong Cocoa experience
◦   Proven ability to design innovative user interfaces.
◦   Working understanding of different file systems.
◦   Desire to work in a Mac environment.

Compensation:

Competitive salary and benefits with bonus potential. Compensation  
commensurate with experience and technical knowledge.___


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

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

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

This email sent to [EMAIL PROTECTED]


Connecting NSToolbar and NSTabView

2008-08-29 Thread David Reitter
To create a preference window with a NSToolbar at the top and a  
tabless NSTabView containing a few panels.

How would I go about connecting the two in Interface Builder?

I can set the NSToolbar selector to invoke  
takeSelectedTabViewItemFromSender on the NSTabView, which seems  
promising.  But it seems that NSToolbar does not respond to   
indexOfSelectedItem, as it should for this to work.


There are some classes out there that does them - I've tried  
UKPrefsPanel, which didn't compile.  Others require separate NIBs with  
the panels, which I presume will cause extra work for me on another end.


This is simple enough to work without extra coding, isn't it?

___

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

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

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

This email sent to [EMAIL PROTECTED]


understanding conversions between CF and NS datatypes

2008-08-29 Thread Allen Curtis
Hello,

I am writing a Cocoa application for accessing a serial device. (IOKit) In
order to do this, you need to translate between CF and NS data types. (I
believe)

For instance:
CFMutableArrayRef devicePaths = CFArrayCreateMutable(NULL, 0, NULL);

GetSerialPortPaths(serialServices, devicePaths);  // Fills in
CFMutableArray
serialPorts = (NSMutableArray *) devicePaths;
//CFRelease(devicePaths);
printf("Found %d serial ports\n", [serialPorts count]);

The problem:  I found that if you release the CFMutableArray, you also loose
the NSMutableArray

Question:
1. Where can I get a better understanding of the data conversion between
these different frameworks?
2. Ultimately the device path names will appear in a ComboBox. Was it
necessary to convert the CFMutableArray to a NSMutableArray for the
datasource function?

TIA

Allen
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: understanding conversions between CF and NS datatypes

2008-08-29 Thread Randall Meadows

On Aug 29, 2008, at 11:38 AM, Allen Curtis wrote:

I am writing a Cocoa application for accessing a serial device.  
(IOKit) In
order to do this, you need to translate between CF and NS data  
types. (I

believe)

For instance:
   CFMutableArrayRef devicePaths = CFArrayCreateMutable(NULL, 0,  
NULL);


   GetSerialPortPaths(serialServices, devicePaths);  // Fills in
CFMutableArray
   serialPorts = (NSMutableArray *) devicePaths;
   //CFRelease(devicePaths);
   printf("Found %d serial ports\n", [serialPorts count]);

The problem:  I found that if you release the CFMutableArray, you  
also loose

the NSMutableArray


Yep, because you're merely casting types, you're not creating a new  
object.



Question:
1. Where can I get a better understanding of the data conversion  
between

these different frameworks?


Does  help?



2. Ultimately the device path names will appear in a ComboBox. Was it
necessary to convert the CFMutableArray to a NSMutableArray for the
datasource function?


I don't know about "necessary", but it's certainly convenient, because  
then you can use the (IMO) more convenient accessors of NSArray.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: understanding conversions between CF and NS datatypes

2008-08-29 Thread Dave Carrigan


On Aug 29, 2008, at 10:38 AM, Allen Curtis wrote:

1. Where can I get a better understanding of the data conversion  
between

these different frameworks?


As I understand it, it's not a "data conversion". If a class is toll- 
free bridged, a CFRef is also an objective-c object. So whether you do  
something with a CF API or you pass it an objective-c message, they  
both operate on the same object. When you come down to it, both  
objective-c objects and CFRefs are pointers, so this makes sense, as  
long as both sides understand how to interpret the chunk of memory  
that the pointer references.


--
Dave Carrigan
[EMAIL PROTECTED]
Seattle, WA, USA



PGP.sig
Description: This is a digitally signed message part
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Bindings: Specifying the Class of a Con troller’s Content

2008-08-29 Thread Ron Lue-Sang


On Aug 29, 2008, at 10:38 AM, Oleg Krupnov wrote:


Here's a fragment of documentation from the "Cocoa Bindings
Programming Topics" guide:

"In order for a controller to create new content objects automatically
or in response to the target-action methods, it must know the
appropriate class to use."

My question is: what is a real example of a case when the controller
needs to create new content objects?


Like Dave said, add: - the IBAction method.
Also if you call newObject for any reason, which is usually to fiddle  
with the result before calling addObject:






As far as I see, it can only happen when a view sends addObject to the
controller, but in that case the object is already created and the
controller simply adds it to the collection. Have I missed something?

Also, if the controller does need to know the class/entity of the
content object, what about polymorphic objects? I.e. I have one
abstract entity "Shape" which is not directly instantiatable, and a
few concrete subclasses. What entity should I specify?


If you have multiple concrete classes, then entity mode won't work for  
you by default. Subclass the arraycontroller and override newObject to  
return the kind you want, or don't depend on the controller object  
creation convenience - create the managedObjects yourself directly and  
either add them to the controller, if you're not using auto-prepare  
contents, or - if your controller *is* set to auto-prepare contents -  
wait for the controller to get the notification from the MOC that a  
new managedObject of your abstract entity was created and inserted  
into the context.




___

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

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

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

This email sent to [EMAIL PROTECTED]



--
RONZILLA



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: understanding conversions between CF and NS datatypes

2008-08-29 Thread Jason Coco


On Aug 29, 2008, at 13:38 , Allen Curtis wrote:
The problem:  I found that if you release the CFMutableArray, you  
also loose

the NSMutableArray

Question:
1. Where can I get a better understanding of the data conversion  
between

these different frameworks?
2. Ultimately the device path names will appear in a ComboBox. Was it
necessary to convert the CFMutableArray to a NSMutableArray for the
datasource function?


It's more convenient to do it this way... however, you were just  
casting the

types, not converting them. You could do something like this:

serialPorts = [(NSArray*)devicePaths copy];
CFRelease(devicePaths);

Or you could just retain your serialPorts object:

serialPorts = (NSArray *)devicePaths;
[serialPorts retain];
CFRelease(devicePaths);

/jason

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: Connecting NSToolbar and NSTabView

2008-08-29 Thread Quincey Morris

On Aug 29, 2008, at 08:20, David Reitter wrote:

To create a preference window with a NSToolbar at the top and a  
tabless NSTabView containing a few panels.

How would I go about connecting the two in Interface Builder?

I can set the NSToolbar selector to invoke  
takeSelectedTabViewItemFromSender on the NSTabView, which seems  
promising.  But it seems that NSToolbar does not respond to   
indexOfSelectedItem, as it should for this to work.


The easiest way is probably to use IB to set each toolbar item  
identifier and its corresponding tab view item to the same string, and  
bind the tab view's "selectedIdentifier" binding to  
toolbar.selectedItemIdentifier.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dynamic right-sizing of TextContainer

2008-08-29 Thread Paul Archibald
Doug is correct. Check out NSText in the APIs. I used this method  
just yesterday to size a text view:



-sizeToFit
Resizes the receiver to fit its text.
- (void)sizeToFit
Discussion
The text view will not be sized any smaller than its minimum size,  
however.

Availability
•   Available in Mac OS X v10.0 and later.
See Also
•   – isHorizontallyResizable
•   – isVerticallyResizable

To prove it to yourself, create a rectangle r, make a textview with  
r, -insertText into it, check r in debugger,  call -sizeToFit, and  
look at the rectangle now. Horizontal does not adjust automatically,  
maybe due to wordwrapping concerns?



Paul

On Aug 29, 2008, at 12:27 PM, [EMAIL PROTECTED] wrote:


On Aug 29, 2008, at 11:01 AM, Martin Stoufer wrote:


I am able to set the initial height/width of the NSTextContainer
object of a NSTextView object in IB. However, I cannot find any
method that will allow the programmatic re-sizing of the container
when the text I'm adding exceeds this size.


Don't do this.  NSTextView handles this automatically for you.  See /
Developer/Examples/AppKit/TextSizingExample for examples of various
different ways to set up a text view depending on how you want it to
resize vertically, horizontally, etc.  If the width is fixed and you
just want the container to size properly vertically, you don't need to
do anything; the stock NSTextView you create in IB should be fine.

Douglas Davidson


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Connecting NSToolbar and NSTabView

2008-08-29 Thread Quincey Morris

On Aug 29, 2008, at 12:49, Quincey Morris wrote:


On Aug 29, 2008, at 08:20, David Reitter wrote:

To create a preference window with a NSToolbar at the top and a  
tabless NSTabView containing a few panels.

How would I go about connecting the two in Interface Builder?

I can set the NSToolbar selector to invoke  
takeSelectedTabViewItemFromSender on the NSTabView, which seems  
promising.  But it seems that NSToolbar does not respond to   
indexOfSelectedItem, as it should for this to work.


The easiest way is probably to use IB to set each toolbar item  
identifier and its corresponding tab view item to the same string,  
and bind the tab view's "selectedIdentifier" binding to  
toolbar.selectedItemIdentifier.


Oops, meant to say "... and its corresponding tab view item  
identifier..."


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: understanding conversions between CF and NS datatypes

2008-08-29 Thread Allen Curtis
Based on the information in the "interchangable data types" document, Would
it be possible to do the following?

  NSMutableArray serialPorts = [[NSMutableArray alloc] init];
  GetSerialPortPaths(serialServices, (CFMutableArrayRef)serialPorts);
  printf("Found %d serial ports\n", [serialPorts count]);

This way I do not have multiple copies. The NSMutableArray is populated
directly.

TIA

Allen

On Fri, Aug 29, 2008 at 12:22 PM, Randall Meadows <[EMAIL PROTECTED]>wrote:

> On Aug 29, 2008, at 11:38 AM, Allen Curtis wrote:
>
>  I am writing a Cocoa application for accessing a serial device. (IOKit) In
>> order to do this, you need to translate between CF and NS data types. (I
>> believe)
>>
>> For instance:
>>   CFMutableArrayRef devicePaths = CFArrayCreateMutable(NULL, 0, NULL);
>>
>>   GetSerialPortPaths(serialServices, devicePaths);  // Fills in
>> CFMutableArray
>>   serialPorts = (NSMutableArray *) devicePaths;
>>   //CFRelease(devicePaths);
>>   printf("Found %d serial ports\n", [serialPorts count]);
>>
>> The problem:  I found that if you release the CFMutableArray, you also
>> loose
>> the NSMutableArray
>>
>
> Yep, because you're merely casting types, you're not creating a new object.
>
>  Question:
>> 1. Where can I get a better understanding of the data conversion between
>> these different frameworks?
>>
>
> Does <
> http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/Articles/InterchangeableDataTypes.html>
> help?
>
>  2. Ultimately the device path names will appear in a ComboBox. Was it
>> necessary to convert the CFMutableArray to a NSMutableArray for the
>> datasource function?
>>
>
> I don't know about "necessary", but it's certainly convenient, because then
> you can use the (IMO) more convenient accessors of NSArray.
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File Extensions Problem

2008-08-29 Thread Greg Parker

Gerriet Denkmann wrote:
While if fully agree with you about valid assumptions and so, I am  
still wondering what is the disadvantage of forgetting about  
NSEnumerator, Fast Enumeration and the like and simply doing:


unsigned count = [ array count ];
if ( count == 0 ) return;
for( unsigned i = count - 1;; i--)
{
id a = [ array objectAtIndex: i ];
if ( a is not nice ) [ array removeObjectAtIndex: i ];
if ( i == 0 ) break;
}


That's a fine way of processing deletions from an array. You might  
prefer this C idiom to simplify the "loop backwards" code:


unsigned i = [ array count ];
while (i--) {
id a = [ array objectAtIndex: i ];
if ( a is not nice ) [ array removeObjectAtIndex: i ];
}


--
Greg Parker [EMAIL PROTECTED] Runtime Wrangler


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: understanding conversions between CF and NS datatypes

2008-08-29 Thread Randall Meadows

On Aug 29, 2008, at 2:28 PM, Allen Curtis wrote:

Based on the information in the "interchangable data types"  
document, Would it be possible to do the following?


  NSMutableArray serialPorts = [[NSMutableArray alloc] init];
  GetSerialPortPaths(serialServices, (CFMutableArrayRef)serialPorts);
  printf("Found %d serial ports\n", [serialPorts count]);


NSMutableArray *serialPorts...

It has to be a pointer.

This way I do not have multiple copies. The NSMutableArray is  
populated directly.


You didn't have multiple copies in the first place; that was your  
problem.  You had *1* object that you were looking at from 2 different  
perspectives, but treating it as if it were 2 objects.


And to answer your question, yes, the above should work (with my  
correction applied).


--
randy

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPredicateEditorRowTemplates and preserving user input

2008-08-29 Thread Peter Ammon


On Aug 29, 2008, at 8:51 AM, Jim Turner wrote:


Hi List,

I noticed something today while building a new popup-popup-popup
template: when the user changes the comparator (a simple is/is not in
my case), the third popup resets itself to the default value instead
of maintaining the selection the user had already chosen.  The same is
true if the third view in my template is a text field.  If they enter
text, then change the value from "contains" to "begins with", the text
they've entered is removed.


Hi Jim,

This is a known issue and I don't think there's a workaround yet, sorry.




I understand that templates are copied like mad behind the scenes of
the editor and that popups are treated differently, but I'm not sure
how I go about fixing this.  I tried subclassing NSPopUpButton to see
what is passed for setObjectValue but the editor doesn't seem to like
a subclassed NSPopUpButton.  Instead, it ignores it and displays
nothing.  Very strange.


If you subclass NSPopUpButton, NSPredicateEditor assumes it has  
special behavior and you want it to be treated like other views.  It's  
only instances of NSPopUpButton themselves that get the different  
treatment of being merged together to build the tree of options.


-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: NSPredicateEditorRowTemplates and preserving user input

2008-08-29 Thread Jim Turner
Thanks for the reply Peter.

Just for the archives, my subclassed NSPopUpButton wasn't showing up
because, like you said, it was being treated differently and I was
initializing it with NSZeroRect.  Giving it a starting size and
sending it sizeToFit in templateViews got it on screen.

Jim

On Fri, Aug 29, 2008 at 4:17 PM, Peter Ammon <[EMAIL PROTECTED]> wrote:
>
> On Aug 29, 2008, at 8:51 AM, Jim Turner wrote:
>
>> Hi List,
>>
>> I noticed something today while building a new popup-popup-popup
>> template: when the user changes the comparator (a simple is/is not in
>> my case), the third popup resets itself to the default value instead
>> of maintaining the selection the user had already chosen.  The same is
>> true if the third view in my template is a text field.  If they enter
>> text, then change the value from "contains" to "begins with", the text
>> they've entered is removed.
>
> Hi Jim,
>
> This is a known issue and I don't think there's a workaround yet, sorry.
>
>>
>>
>> I understand that templates are copied like mad behind the scenes of
>> the editor and that popups are treated differently, but I'm not sure
>> how I go about fixing this.  I tried subclassing NSPopUpButton to see
>> what is passed for setObjectValue but the editor doesn't seem to like
>> a subclassed NSPopUpButton.  Instead, it ignores it and displays
>> nothing.  Very strange.
>
> If you subclass NSPopUpButton, NSPredicateEditor assumes it has special
> behavior and you want it to be treated like other views.  It's only
> instances of NSPopUpButton themselves that get the different treatment of
> being merged together to build the tree of options.
>
> -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: ODBCKit problems with MySQL DB [SOLVED]

2008-08-29 Thread Matthew Youney
Well, solved kinda... I have worked around the inability to use ODBC to
access my MySQL database by using the MCPkit framework (AKA MySQLCocoa).
This is a very complete library that works well.  It does however have the
obvious limitation of being "MySQL only".

I would prefer to be using ODBC, and I am quite surprised that there is not
stronger support within Cocoa.  As an ongoing request, if anyone does find
some relevant information, please pass it along to the list.  I will do the
same.

As always, thanks everyone for your assistance, and best regards,

Matt




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: mark added object in NSArrayController as "dirty"?

2008-08-29 Thread Matt Neuburg
On Thu, 28 Aug 2008 16:49:04 -0700, Quincey Morris
<[EMAIL PROTECTED]> said:
>If the insertion *must* be modal, it might be better to be explicit
>about it: instead of creating an invalid object when the Add button is
>clicked, display a sheet that has fields for the required object
>properties, and create the object after the sheet data is validated
>and OKed.
>
>Of course, this is said knowing nothing about the application, but
>considering a different solution might give something better-defined
>to implement and, as a bonus, more convenient for users.
>
>Feel free to ignore this if I'm off base here.

Not at all, I think your view is very sensible - thanks! m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], 
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: 
AppleScript: the Definitive Guide - Second Edition!




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Connecting NSToolbar and NSTabView

2008-08-29 Thread David Reitter

On 29 Aug 2008, at 15:52, Quincey Morris wrote:


On Aug 29, 2008, at 12:49, Quincey Morris wrote:


On Aug 29, 2008, at 08:20, David Reitter wrote:

To create a preference window with a NSToolbar at the top and a  
tabless NSTabView containing a few panels.

How would I go about connecting the two in Interface Builder?

I can set the NSToolbar selector to invoke  
takeSelectedTabViewItemFromSender on the NSTabView, which seems  
promising.  But it seems that NSToolbar does not respond to   
indexOfSelectedItem, as it should for this to work.


The easiest way is probably to use IB to set each toolbar item  
identifier and its corresponding tab view item to the same string,  
and bind the tab view's "selectedIdentifier" binding to  
toolbar.selectedItemIdentifier.


Oops, meant to say "... and its corresponding tab view item  
identifier..."


Sorry, where in IB do I set the identifier of the NSToolbarItem?  Is  
it just the Label?  At least this is what can be bound.


Do I just call the toolbar 'prefstoolbar' in "Interface Builder  
Identity", in order to access it?
I don't quite understand how I can address the NSToolbar instance from  
the NSTabview.


Also, doesn't a delegate to the NSToolbar have to provide  
toolbarSelectableItemIdentifiers to make them permanently selectable?



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Connecting NSToolbar and NSTabView

2008-08-29 Thread Quincey Morris

On Aug 29, 2008, at 15:08, David Reitter wrote:

Sorry, where in IB do I set the identifier of the NSToolbarItem?  Is  
it just the Label?  At least this is what can be bound.


Doh, I forgot that IB 3.1 fails to expose the toolbar item  
identifiers. Perhaps a future version of IB might do this.


The workaround is to create outlets in your window controller that are  
connected to the toolbar items. Then, in your window controller  
awakeFromNib, use the outlets to get each toolbar item identifier and  
set it as the tab item identifier of the correponding tab view item.  
That makes them match.


Do I just call the toolbar 'prefstoolbar' in "Interface Builder  
Identity", in order to access it?
I don't quite understand how I can address the NSToolbar instance  
from the NSTabview.


Also, doesn't a delegate to the NSToolbar have to provide  
toolbarSelectableItemIdentifiers to make them permanently selectable?


Assuming that your window controller is File's Owner of the window  
nib, you can get to the toolbar's selected item identifier as File's  
Owner.window.toolbar.selectedItemIdentifier.


Or, as a no-bindings approach, you could probably forget about  
identifiers and set the toolbar item tags to the corresponding tab  
view item indexes in IB, then give all of the toolbar items a shared  
action that retrieves the tag, and uses it to set the appropriate tab  
view item index.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: What to use observeValueForKeyPath: context

2008-08-29 Thread Chris Kane

On Aug 29, 2008, at 10:23, j o a r wrote:

If you use a constant string, you should make sure that the
string *contents* are unique, in order to ensure uniqueness of the
pointer to it. So don't call it @"context", use @"MyFunkyClass KVO
observer context". After all there's no penalty for being verbose in
this case. Of course using a pointer to a global solves this too.



The penalty for using constant strings is that they will end up  
wasting space in your binary...

Rons suggestion is probably optimal.



Even more optimal than...

static NSString *ABCFooPropertyObservingContext;

is this:

static char ABCFooPropertyObservingContext;

and then still using &ABCFooPropertyObservingContext as the context  
value.  If nothing ends up being packed up tight right after that  
char, due to data alignment, well then you still haven't lost anything.



Chris Kane
Cocoa Frameworks, Apple


___

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

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

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

This email sent to [EMAIL PROTECTED]


Target change problem

2008-08-29 Thread James Pengra
	A program I have developed will not run on a PPC machine (G5 
iMac) using OS 10.4.11. It was developed on Xcode 3.0 on an Intel 
machine running OS 10.5.4. Initially the projects "Cross_Develop 
Using Target SDK" was set to "Current Mac OS", so it's not surprising 
that it wouldn't run on the G5 machine. When I changed the target SDK 
to Mac OS 10.4 (Universal), "cleaned" the project, and rebuilt it, 
the G5 PPC still would not run it.
 I suspect there is still some setting in XCode that I need to 
change, but I don't see anything obvious. Other programs that I've 
developed with the same system do run nicely on the G5. Their Target 
SDK setting started out set to 10.4 (Universal).


   Suggestions?

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


Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Brad Gibbs
I'm having a hard time with what should be a simple task - storing an  
integer for a gradient angle as a user default and then updating the  
screen.  When I quit the app and open it again, the NSTextField shows  
the last value I set for the gradient, but with the following code:


- (IBAction)changeElementBarGradientAngle:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField  
intValue]);
	[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];
	NSLog(@"Element bar angle is now: %d", [ICNElementBarGradientAngleKey  
intValue]);

}

I get:

2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75
2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0

I've also tried turning the int into an NSNumber object and using  
defaults setObject: foKey: without success.


It seems as though I have to use:

[gradient drawInRect:[self bounds] angle: 
[ICNElementBarGradientAngleKey intValue]];



turning ICNElementBarGradientAngleKey back into an int, which makes me  
wonder, is setInteger in:


[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];



meant to be used with an int, or an object, such as NSUInteger?  What  
am I doing wrong?



Thanks,

Brad
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Brad Gibbs

Thanks.

I'd read that dictionaries and plists were particular in the types  
they accept, but I was looking at page 201 of Hillegass (3rd edition),  
which shows:


- (void)setInteger:(int)value forKey:(NSString *)defaultName

and

- (int)integerForKey:(NSString *)defaultName

and blindly followed  Apple's NSUserDefaults documentation shows:

- (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName


which makes more sense.  Must be a typo in the book?



On Aug 29, 2008, at 7:14 PM, Andrei Kolev wrote:


Brad,

You can't store an int into a Dictionary or user defaults. For the  
objects you can use, see here:


http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#/ 
/apple_ref/doc/uid/20001010


NSNumber and NSString should work.

Also, [ICNElementBarGradientAngleKey intValue] will try to turn the  
key into a number, not get it's value. You want to use:

[[defaults objectForKey: ICNElementBarGradientAngleKey] intValue];

Andrei

On 30.08.2008, at 04:54, Brad Gibbs wrote:

I'm having a hard time with what should be a simple task - storing  
an integer for a gradient angle as a user default and then updating  
the screen.  When I quit the app and open it again, the NSTextField  
shows the last value I set for the gradient, but with the following  
code:


- (IBAction)changeElementBarGradientAngle:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField  
intValue]);
	[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];
	NSLog(@"Element bar angle is now: %d",  
[ICNElementBarGradientAngleKey intValue]);

}

I get:

2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75
2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0

I've also tried turning the int into an NSNumber object and using  
defaults setObject: foKey: without success.


It seems as though I have to use:

[gradient drawInRect:[self bounds] angle: 
[ICNElementBarGradientAngleKey intValue]];



turning ICNElementBarGradientAngleKey back into an int, which makes  
me wonder, is setInteger in:


[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];



meant to be used with an int, or an object, such as NSUInteger?   
What am I doing wrong?



Thanks,

Brad
___

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

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

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


This email sent to [EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Cancel application terminate on Logout/Shut Down

2008-08-29 Thread Andrei Kolev

Hi list,

I had to subclass the NSApplication's -terminate method and have a  
hopefully minor problem:


When I receive replyToApplicationShouldTerminate:NO I want to notify  
the OS that the application will not quit. Otherwise on logout or  
shutdown after the 30 seconds timeout I get the info window that The  
shutdown/Logout has timed out because my application failed to quit.


Please note that I spend some time trying to use the delegate methods  
instead of subclassing the NSApplication class but I can not return  
the NSTerminateLater  because the Application run loop is stalled and  
the application hangs. NSTerminateNow and NSTerminateCancel work fine,  
but that is not what I want. Why this happens is a long story and it  
is much harder to fix.


Thanks,
Andrei
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Andrei Kolev

Brad,

You can't store an int into a Dictionary or user defaults. For the  
objects you can use, see here:


http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#/ 
/apple_ref/doc/uid/20001010


NSNumber and NSString should work.

Also, [ICNElementBarGradientAngleKey intValue] will try to turn the  
key into a number, not get it's value. You want to use:

[[defaults objectForKey: ICNElementBarGradientAngleKey] intValue];

Andrei

On 30.08.2008, at 04:54, Brad Gibbs wrote:

I'm having a hard time with what should be a simple task - storing  
an integer for a gradient angle as a user default and then updating  
the screen.  When I quit the app and open it again, the NSTextField  
shows the last value I set for the gradient, but with the following  
code:


- (IBAction)changeElementBarGradientAngle:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField  
intValue]);
	[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];
	NSLog(@"Element bar angle is now: %d",  
[ICNElementBarGradientAngleKey intValue]);

}

I get:

2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75
2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0

I've also tried turning the int into an NSNumber object and using  
defaults setObject: foKey: without success.


It seems as though I have to use:

[gradient drawInRect:[self bounds] angle: 
[ICNElementBarGradientAngleKey intValue]];



turning ICNElementBarGradientAngleKey back into an int, which makes  
me wonder, is setInteger in:


[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];



meant to be used with an int, or an object, such as NSUInteger?   
What am I doing wrong?



Thanks,

Brad
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Brad Gibbs
Well, it appears that I need to convert either an NSNumber or an  
NSString to a CGFloat, rather than an int:


- (void)drawInRect:(NSRect)rect angle:(CGFloat)angle

There don't appear to be any methods in either NSNumber or NSString to  
do this



On Aug 29, 2008, at 7:36 PM, Brad Gibbs wrote:


Thanks.

I'd read that dictionaries and plists were particular in the types  
they accept, but I was looking at page 201 of Hillegass (3rd  
edition), which shows:


- (void)setInteger:(int)value forKey:(NSString *)defaultName

and

- (int)integerForKey:(NSString *)defaultName

and blindly followed  Apple's NSUserDefaults documentation shows:

- (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName


which makes more sense.  Must be a typo in the book?



On Aug 29, 2008, at 7:14 PM, Andrei Kolev wrote:


Brad,

You can't store an int into a Dictionary or user defaults. For the  
objects you can use, see here:


http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#/ 
/apple_ref/doc/uid/20001010


NSNumber and NSString should work.

Also, [ICNElementBarGradientAngleKey intValue] will try to turn the  
key into a number, not get it's value. You want to use:

[[defaults objectForKey: ICNElementBarGradientAngleKey] intValue];

Andrei

On 30.08.2008, at 04:54, Brad Gibbs wrote:

I'm having a hard time with what should be a simple task - storing  
an integer for a gradient angle as a user default and then  
updating the screen.  When I quit the app and open it again, the  
NSTextField shows the last value I set for the gradient, but with  
the following code:


- (IBAction)changeElementBarGradientAngle:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField  
intValue]);
	[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];
	NSLog(@"Element bar angle is now: %d",  
[ICNElementBarGradientAngleKey intValue]);

}

I get:

2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75
2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0

I've also tried turning the int into an NSNumber object and using  
defaults setObject: foKey: without success.


It seems as though I have to use:

[gradient drawInRect:[self bounds] angle: 
[ICNElementBarGradientAngleKey intValue]];



turning ICNElementBarGradientAngleKey back into an int, which  
makes me wonder, is setInteger in:


[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];



meant to be used with an int, or an object, such as NSUInteger?   
What am I doing wrong?



Thanks,

Brad
___

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

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

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

This email sent to [EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: understanding conversions between CF and NS datatypes

2008-08-29 Thread Michael Ash
On Fri, Aug 29, 2008 at 1:38 PM, Allen Curtis <[EMAIL PROTECTED]> wrote:
> 1. Where can I get a better understanding of the data conversion between
> these different frameworks?
> 2. Ultimately the device path names will appear in a ComboBox. Was it
> necessary to convert the CFMutableArray to a NSMutableArray for the
> datasource function?

Ultimately the most important thing to understand about toll-free
bridging (the link between CF and NS data types) is that you don't
have to convert anything. You *can't* convert anything. Because they
aren't two different things. An NSArray *is* a CFArray. An
NSMutableArray is a CFMutableArray. They are just two different names
for the same type.

It gets slightly tricky because the compiler doesn't know this crucial
fact. So when you have a CFMutableArrayRef and you try to treat it
like it was an NSMutableArray*, the compiler gets complainey. So you
have to do some fancy typecasting to shut it up. But it's very
important to understand that this typecast doesn't do any sort of
conversion or translation or anything of the sort, it just tells the
compiler to look at the exact same pointer to the exact same object in
a new light.

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: Design Question: Bindings & Custom Views

2008-08-29 Thread Erik Buck
"Cocoa Design Patterns" Chapter 29, "Controllers,"  contains an MVC  
solution to exactly the problem Oleg Krupnov describes.   The chapter  
presents a relatively simple MVC MYShapeDraw application.  The chapter  
leads the reader through the step by step process of re-inventing  
NSArrayController  as part of the MYShapeDraw application.  The goal  
is to highlight the rationale and use pattern for array controller and  
other controllers.  One of the reasons to use an array controller as a  
mediator between model objects and views is precisely so that it's  
easy to have multiple different views and potentially different  
models.  Therefore, the application provides multiple views. The  
example even discusses sharing selection information by multiple views  
or letting each view have a different notion of the current selection.


The application also uses the "Associative Storage" pattern from  
chapter 19 to enable any view to store whatever extra information it  
wants along with model objects.  Categories are used to separate view  
related code from the model code.  Apple uses this approach in several  
places to add view layer capabilities to model layer objects.  See  
NSString and NSStringAdditions.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Graham Cox


On 30 Aug 2008, at 12:14 pm, Andrei Kolev wrote:


Brad,

You can't store an int into [...] user defaults.


Sure you can:

- (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName;



Note that NSInteger == int, so the book doesn't have a typo, it's just  
using the pre-Leopard type conventions.




But anyway, the angle used by NSGradient is a float, not an int, so  
you probably want:


- (void)setFloat:(float)value forKey:(NSString *)defaultName



Note that, again, CGFloat == float.



hth,

Graham








___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Design Question: Bindings & Custom Views

2008-08-29 Thread Erik Buck
Sorry.  When I posted about "the problem Oleg Krupnov describes", I  
wasn't caught up on my reading of the list.  The VC MYShapeDraw  
application I describe is a drawing application and not related to  
image thumbnail caching.  Of course, the pattern is general and  
applicable to image thumbnail caching.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Ken Thomases

On Aug 29, 2008, at 8:54 PM, Brad Gibbs wrote:

I'm having a hard time with what should be a simple task - storing  
an integer for a gradient angle as a user default and then updating  
the screen.  When I quit the app and open it again, the NSTextField  
shows the last value I set for the gradient, but with the following  
code:


- (IBAction)changeElementBarGradientAngle:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField  
intValue]);
	[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];


In this line, ICNElementBarGradientAngleKey is being used as a key  
into the defaults dictionary.  I don't know what its value is, but I  
suspect its a name.




	NSLog(@"Element bar angle is now: %d",  
[ICNElementBarGradientAngleKey intValue]);


In this line, you're not looking up the value using the key.  Instead,  
you're asking the key string to convert itself into an integer.  If  
the key string is not numerical itself, it will return 0.


Consider the following:

[@"Hello" intValue];

vs.

[@"123" intValue];

Neither of these has anything to do with looking up a value in the  
user defaults.  They are just attempts to parse a string and obtain an  
integer.  The first produces 0 because @"Hello" doesn't contain an  
integer value, while the second produces 123.  Your usage corresponds  
to the @"Hello" case.


To look up the value of a default, you do the following:

[[NSUserDefaults standardUserDefaults]  
integerForKey:ICNElementBarGradientAngleKey]



Cheers,
Ken

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Graham Cox


On 30 Aug 2008, at 11:54 am, Brad Gibbs wrote:

	NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField  
intValue]);
	[defaults setInteger:[elementBarGradientAngleTextField intValue]  
forKey:ICNElementBarGradientAngleKey];
	NSLog(@"Element bar angle is now: %d",  
[ICNElementBarGradientAngleKey intValue]);

}

I get:

2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75
2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0


Hmm, yes. Well, what is your code doing? It's first taking the  
intValue from elementBarGradientAngleTextField. It then sets that  
value in the user defaults, quite correctly, using the key  
"ICNElementBarGradientAngleKey" which I take it is defined somewhere  
as a constant literal string. You then ask the KEY for its intValue.  
The key's intValue is indeed 0, because the key is  
"ICNElementBarGradientAngleKey" which isn't a number.


I think you mean:

NSLog(@"Element bar angle is now: %d", [defaults  
integerForKey:ICNElementBarGradientAngleKey]);


which should return the same as the first log.


meant to be used with an int, or an object, such as NSUInteger?   
What am I doing wrong?



NSInteger is NOT an object. It's just another name for int. Just  
because something is prefixed by 'NS' do not assume its an object -  
there are many, many things in Cocoa that are prefixed 'NS' that are  
not objects - types, constants, functions, you name it. You can really  
tell what is or isn't an object purely from its name alone - check the  
documentation.


hth,

Graham

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Graham Cox


On 30 Aug 2008, at 2:04 pm, Graham Cox wrote:


You can really tell



I meant of course that you CAN'T really tell...

G.
___

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

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

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

This email sent to [EMAIL PROTECTED]


-dataWithPDFInsideRect: unsafe within -drawRect:?

2008-08-29 Thread Graham Cox
I'm getting a problem when I call -dataWithPDFInsideRect: within a  
view's -drawRect: method. I'm doing this as part of an attempt to  
cache the contents as a PDF under some circumstances, but I get a  
number of assertions/exceptions thrown. This was previously working so  
I'm not sure what's changed - something in the last Leopard update  
perhaps (I'm using 10.5.4).


The assertions are:

2008-08-30 14:20:30.410 Ortelius[48682:10b] *** Assertion failure in - 
[DKDrawingView getRectsBeingDrawn:count:], /SourceCache/AppKit/ 
AppKit-949.33/AppKit.subproj/NSView.m:7334
2008-08-30 14:20:30.411 Ortelius[48682:10b] Invalid parameter not  
satisfying: windowRegionBeingDrawn != nil

failed to find start of cross-reference table.
missing or invalid cross-reference trailer.
2008-08-30 14:20:30.412 Ortelius[48682:10b] *** Assertion failure in - 
[DKDrawingView getRectsBeingDrawn:count:], /SourceCache/AppKit/ 
AppKit-949.33/AppKit.subproj/NSView.m:7334
2008-08-30 14:20:30.413 Ortelius[48682:10b] unlockFocus called too  
many time.
2008-08-30 14:20:30.413 Ortelius[48682:10b] *** Assertion failure in - 
[GCPlacardScrollView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:], /SourceCache/AppKit/AppKit-949.33/AppKit.subproj/NSView.m:6272
2008-08-30 14:20:30.417 Ortelius[48682:10b] Invalid parameter not  
satisfying: rectSetBeingDrawn != nil



Any ideas? Is it just not safe to try generating a PDF within drawRect?


tia, Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Explanation

2008-08-29 Thread Rob Keniger


On 30/08/2008, at 4:50 AM, J. Todd Slack wrote:


Continuing learning the Quicktime API.

I am confused about QTTimeRanges, etc



Hi Jason,

You might be better off asking these questions on the QuickTime API  
list:


http://lists.apple.com/mailman/listinfo/quicktime-api

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


Re: Undocumented Leopard support for overlapping sibling views

2008-08-29 Thread Jamie Johnson


On Aug 28, 2008, at 2:40 PM, Corbin Dunn wrote:



On Aug 28, 2008, at 1:48 PM, Ricky Sharp wrote:



On Aug 28, 2008, at 3:28 PM, Nathan Vander Wilt wrote:

According to two list postings (http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg01760.html 
, http://lists.apple.com/archives/cocoa-dev/2007/Nov/ 
msg01764.html) both by Apple employees, overlapping sibling  
subviews are fully supported in Leopard (and presumably beyond).


However, the official documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/chapter_5_section_5.html 
) still says:
"Cocoa does not enforce clipping among sibling views or guarantee  
correct invalidation and drawing behavior when sibling views  
overlap. If you want a view to be drawn in front of another view,  
you should make the front view a subview (or descendant) of the  
rear view."


And Interface Builder 3.1 on the one hand has options like "Layout  
> Send to Front" that change the ordering of subviews, yet on the  
other still warns about "Illegal geometry" when a view overlaps  
one of its siblings even when the deployment target is set to 10.5.



I can't find anything in the documentation (or even release notes)  
that describes that/how overlapping views are supported. Why isn't  
this documented? Can we rely on overlapping sibling views working  
now and in the future? Are there any caveats we should be aware of?


I believe that Apple relaxed the rules to allow CoreAnimation  
layers to work correctly.  Whether or non a non-layered UI fully  
supports overlapping sibling views, I do not know.


Please do log bugs requesting the documentation to be enhanced.  
Overlapping views do work in Leopard+, with or without layers.  
However, a sibling layered view will always be on top of a sibling  
non-layered view.


corbin


Are you saying that overlapped sibling views composite correctly with  
regard to z-order, clipping and invalidation? If so this contradicts  
the results of a test I performed earlier this year where it was  
fairly simple to get z fighting (this on 10.5 system). Are there  
special requirements, other than 10.5, for this to work?

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -dataWithPDFInsideRect: unsafe within -drawRect:?

2008-08-29 Thread Graham Cox


On 30 Aug 2008, at 2:23 pm, Graham Cox wrote:

Any ideas? Is it just not safe to try generating a PDF within  
drawRect?


Clarification: these are in two *different* views - i.e. one is in the  
middle of -drawRect: and creates a new view and calls its - 
dataWithPDFInsideRect: method. Obviously calling it on the same view  
wouldn't be safe because it creates an infinite loop.


Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -dataWithPDFInsideRect: unsafe within -drawRect:?

2008-08-29 Thread Joel Norvell
Hi Graham,

You might try saving and restoring graphics states for the pertinent 
NSGraphicsContexts, although this wouldn't seem to explain why your code broke.

Sincerely,
Joel




  
___

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

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

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

This email sent to [EMAIL PROTECTED]