Re: Mysterious NULL Coming From NSUserDefaults

2008-07-07 Thread Alex Wait
I knew that naming my variables like that was a bad idea. :)
Thanks! I changed the names and updated what needed to be updated because of
the name changes and it works now!

w00t!

Thanks again!
Alex

On Sun, Jul 6, 2008 at 10:52 PM, Boaz Stuller [EMAIL PROTECTED] wrote:

 Well, I see a couple problems here
 1) Even though you're getting directly passed a color in your setters,
 you're ignoring that and trying to find out the color from the wells. That's
 bad form for many reasons, and if those backGroundWell and lineWell
 variables weren't hooked up correctly, that would explain your symptoms.
 Especially since your lineWell and backGroundWell aren't getting hooked up
 correctly.

 2)  Since I can't see your whole project, I can't be 100% sure, but I'm 99%
 sure your lineWell and backGroundWell probably aren't getting hooked up
 correctly.  This is because you named your color setters and getters *the
 exact same thing* as the instance variables for your color wells.  This is
 a big mistake, for reasons that are way too complicated to explain in an
 email.  The short version is that when nibs are loaded, outlets are set
 using key-value coding.  If you have a method named -setLineWell: and an
 ivar named lineWell, the KVC routines assume that the -setLineWell: method
 is the way to set the lineWell ivar and call that method instead of setting
 lineWell directly.  You can avoid this problem in the future by making your
 getter and setter names describe what you're actually getting and setting,
 i.e -lineWell and -setLineWell: should get/set an NSColorWell, while
 -lineColor and -setLineColor: should get/set an NSColor.

 3) Pulling back a bit, you're working way too hard.  You don't have to
 write any code at all to hook a color well up to a preference key.  You just
 bind to the 'Shared User Defaults Controller', set the controller key to
 'values', the Model Key to whatever you want your preference key to be, and
 the Value Transformer to NSUnarchiveFromData (it'll be in the popup
 menu).  It will handle all that archiving and unarchiving you're currently
 doing manually.

 4) The G in Background should not be capitalized. ;)

 Best wishes,
 Bo




-- 
If you can't be kind, at least have the decency to be vague.
___

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

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

2008-07-07 Thread Omar Qazi


On Jul 6, 2008, at 7:46 AM, Martin Hairer wrote:


This works like a treat and is faster by a factor 3 or so than using
the Moriarity implementation. However, it leaves me a bit concerned
about various warnings all over the place concerning the thread
(un)safety of NSTask and NSFileHandle. So my question is: is the kind
of approach that I am taking doable / reasonable? If not, is there an
alternative way of doing this which is more efficient  than the
Moriarty code? Thanks a lot in advance for any help / hint,



NSFileHandle *msgHandle = [standardInput fileHandleForReading];
[msgHandle waitForDataInBackgroundAndNotify];

- (void)newMessage:(NSNotification *)notification {
	NSString *strOutput = [[NSString alloc]initWithData:[msgHandle  
availableData] encoding:NSUTF8StringEncoding];

//Process the data
[msgHandle waitForDataInBackgroundAndNotify];
}

This is what I'm using in one of my Cocoa apps. I don't know if it's  
faster, but I would assume so, since there is no loop. Also, If i've  
interpreted the documentation correctly, the method is run in the main  
thread so you don't have to worry about anything being thread safe.


Omar Qazi
Hello, Galaxy!
1.310.294.1593



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: Efficiently receiving data from an NSTask

2008-07-07 Thread Andrew Farmer

On 06 Jul 08, at 23:24, Omar Qazi wrote:

On Jul 6, 2008, at 7:46 AM, Martin Hairer wrote:

This works like a treat and is faster by a factor 3 or so than using
the Moriarity implementation. However, it leaves me a bit concerned
about various warnings all over the place concerning the thread
(un)safety of NSTask and NSFileHandle. So my question is: is the kind
of approach that I am taking doable / reasonable? If not, is there an
alternative way of doing this which is more efficient  than the
Moriarty code? Thanks a lot in advance for any help / hint,


NSFileHandle *msgHandle = [standardInput fileHandleForReading];
[msgHandle waitForDataInBackgroundAndNotify];

- (void)newMessage:(NSNotification *)notification {
	NSString *strOutput = [[NSString alloc]initWithData:[msgHandle  
availableData] encoding:NSUTF8StringEncoding];

//Process the data
[msgHandle waitForDataInBackgroundAndNotify];
}


I'd be very careful with reading string input like that. It's entirely  
possible for a multi-byte character (é, for example, is represented as  
C3 89) to be split across two separate data chunks, which'll make  
NSString very confused and angry.


I'm not quite sure what the correct solution is here, though. There's  
got to be some easier solution than checking for sequence completeness  
by hand...___


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

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

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

This email sent to [EMAIL PROTECTED]


NSSound won't play wave files???

2008-07-07 Thread Jason Bobier
Has anyone else had issues playing wave files with NSSound? Not only  
does it refuse to play the file (even tho I can open it with the  
Quicktime Player and play it), but it fails to error. It simply  
doesn't make a sound. AIFF files seem to play just fine. Here is the  
code in a generic project.


@implementation TestController
- (void)awakeFromNib
{
BOOL success;

	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.wav byReference:YES];
//	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.aif byReference:YES];


success = [sound play];

NSLog(@%d, (int)success);
}
@end

Very straight forward. The sound allocs and inits just fine and  
success is YES after play is called. Not only does it fail to make a  
sound, but it also fails to call my sound finished delegate.


Looking in the Console, I get this mysterious error:

7/7/08 2:41:51 AM Test[29698] com.apple.console Warning 1

whenever the sound is played.

Any ideas???

Thanks!

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]


Re: NSSound won't play wave files???

2008-07-07 Thread Charles Srstka

On Jul 7, 2008, at 1:53 AM, Jason Bobier wrote:

Has anyone else had issues playing wave files with NSSound? Not only  
does it refuse to play the file (even tho I can open it with the  
Quicktime Player and play it), but it fails to error. It simply  
doesn't make a sound. AIFF files seem to play just fine. Here is the  
code in a generic project.


@implementation TestController
- (void)awakeFromNib
{
BOOL success;

	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.wav byReference:YES];
//	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.aif byReference:YES];


success = [sound play];

NSLog(@%d, (int)success);
}
@end

Very straight forward. The sound allocs and inits just fine and  
success is YES after play is called. Not only does it fail to make a  
sound, but it also fails to call my sound finished delegate.


Looking in the Console, I get this mysterious error:

7/7/08 2:41:51 AM Test[29698] com.apple.console Warning 1

whenever the sound is played.

Any ideas???


Since it works in QuickTime Player, have you tried using QTMovie  
instead of NSSound to play the file?


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSSound won't play wave files???

2008-07-07 Thread Jason Bobier

BTW, this:

- (void)awakeFromNib
{
BOOL success;
NSError *error = nil;

	QTMovie *sound = [[QTMovie movieWithFile:@/Users/jason/Desktop/ 
306.wav error:error] retain];


[sound play];

NSLog(@%d, (int)success);
}


works fine.


On Jul 7, 2008, at 2:53 AM, Jason Bobier wrote:

Has anyone else had issues playing wave files with NSSound? Not only  
does it refuse to play the file (even tho I can open it with the  
Quicktime Player and play it), but it fails to error. It simply  
doesn't make a sound. AIFF files seem to play just fine. Here is the  
code in a generic project.


@implementation TestController
- (void)awakeFromNib
{
BOOL success;

	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.wav byReference:YES];
//	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.aif byReference:YES];


success = [sound play];

NSLog(@%d, (int)success);
}
@end

Very straight forward. The sound allocs and inits just fine and  
success is YES after play is called. Not only does it fail to make a  
sound, but it also fails to call my sound finished delegate.


Looking in the Console, I get this mysterious error:

7/7/08 2:41:51 AM Test[29698] com.apple.console Warning 1

whenever the sound is played.

Any ideas???

Thanks!

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/jbobier%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: NSSound won't play wave files???

2008-07-07 Thread Jason Bobier

Hey Charles,

I just did and that worked fine, so at least I have a work around. :-)

Jason

On Jul 7, 2008, at 3:01 AM, Charles Srstka wrote:


On Jul 7, 2008, at 1:53 AM, Jason Bobier wrote:

Has anyone else had issues playing wave files with NSSound? Not  
only does it refuse to play the file (even tho I can open it with  
the Quicktime Player and play it), but it fails to error. It simply  
doesn't make a sound. AIFF files seem to play just fine. Here is  
the code in a generic project.


@implementation TestController
- (void)awakeFromNib
{
BOOL success;

	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/Users/ 
jason/Desktop/306.wav byReference:YES];
//	NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@/ 
Users/jason/Desktop/306.aif byReference:YES];


success = [sound play];

NSLog(@%d, (int)success);
}
@end

Very straight forward. The sound allocs and inits just fine and  
success is YES after play is called. Not only does it fail to make  
a sound, but it also fails to call my sound finished delegate.


Looking in the Console, I get this mysterious error:

7/7/08 2:41:51 AM Test[29698] com.apple.console Warning 1

whenever the sound is played.

Any ideas???


Since it works in QuickTime Player, have you tried using QTMovie  
instead of NSSound to play the file?


Charles


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: garbage collection and NSConnection

2008-07-07 Thread Joan Lluch (casa)


El 07/07/2008, a las 0:18, Hamish Allan escribió:


On 7/4/08, Chris Hanson [EMAIL PROTECTED] wrote:

Under non-GC, an object's memory may not be reclaimed until the  
current
autorelease pool is drained.  However, under GC, an object's memory  
can be
reclaimed as soon as the collector can tell there are no more  
references to

it -- no matter when that is.


I think Joan's point is not that there are circumstances in which the
GC will never reclaim, but that it is not possible to ensure
reclamation deterministically.

[...]

Collection is subject to interruption on user input -- with no
mention of when it might be re-started.

Hamish



Thanks Hamish. That was exactly my point, and that citation of the  
documentation gives more plausibility to it.


(my native language is not English, nor I live in an English speaking  
country so it can be sometimes difficult for me to express complex  
things or to know the more appropriate word to express a concept, this  
is why I tend to paraphrase on my writing, and I understand that it  
can be difficult to read).


Joan Lluch

___

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

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

2008-07-07 Thread Paul Sargent
Remember that some raw files contain multiple resoltions (i.e. a  
thumbnail and the main image), so you may not always want the first one.


On 6 Jul 2008, at 04:29, James Merkel wrote:

Will look into CGImageRef using ImageIO. However, I found that if I  
use: imageRepsWithContentsOfFile: rather than  
imageRepWithContentsOfFile: I can get a bit map from all raw files  
that are supported by OS X. (At least for the raw files I have  
checked so far). The method  imageRepsWithContentsOfFile returns an  
array of file reps, so the following works:


NSBitmapImageRep * imageBitMap = nil;
NSArray * repsArray;
repsArray = [NSBitmapImageRep imageRepsWithContentsOfFile:theFile];

if([repsArray lastObject] != nil) {
imageBitMap = [repsArray objectAtIndex:0];
}

Jim Merkel


On Sat, 05 Jul 2008 14:16:46 -0700 Chris Hanson wrote:

On Jul 5, 2008, at 2:00 PM, James Merkel wrote:

So the question is how to go about reliably getting a bit map
reliably form these camera raw files?


Try getting a CGImageRef using ImageIO.


On Jul 5, 2008, at 2:00 PM, James Merkel wrote:

I notice there are now about 120 Digital camera raw formats supported
by Mac OS X as of system 10.5.4.
I am trying to get a bit map from these camera files so I am using:

NSBitmapImageRep * imageBitMap = [NSBitmapImageRep
imageRepWithContentsOfFile:theFile]

For some raw files (Nikon NEF and Canon CR2) I get a bit map. But for
other files (Sony DSLR-A100 ARW file) I get a nil bit map.
On the other hand, I notice that the system does support the Sony raw
file in some way, since for example:

[[NSImage alloc] initWithContentsOfFile:theFile] does produce an  
image.


So the question is how to go about reliably getting a bit map  
reliably

form these camera raw files?

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Rerouting keyboard input

2008-07-07 Thread em
I would like to be able to  reassign the primary system keyboard input so as to 
direct it to an incoming  network stream.   It's a general query at present and 
any suggestions would be appreciated.  I'm leaning toward writing a 
Cocoa/Objective C/PPC Masm app--locating and modifying the remote apple 
events api (if there is one), but i'm not sure whether this can be done by 
simply re-directing a unix pipe, or tweaking Darwin.
thanks,
em


___

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

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

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

This email sent to [EMAIL PROTECTED]


archive only what changed?

2008-07-07 Thread Randy Canegaly
I have an application whose data model is an NSMutableArray with  
elements that could be pointers other NSMutableArrays, much like what  
you would navigate with a NSIndexPath.  I am using NSKeyedArchiver to  
archive the data model to a file.  Right now I archive the entire top  
level array object (and therefore all its parts) to the file using  
archiveRootObject:toFile.
Is it possible to archive only the portion of the data model that  
changed rather than the entire thing every time?  I need the entire  
data model to be archived so that it can be reloaded when the  
application starts but for performance reasons I am interested in  
seeing if it's possible upon a change to the data to only re-archive  
the small part that changed.

___

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

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

2008-07-07 Thread John Love
Uli -

To enable/disable the toolbar items, Cocoa uses the
NSUserInterfaceValidation protocol, and asks each responder in the responder
chain, beginning at the first responder. Have you inserted your toolbar
controller in the responder chain so it actually gets asked whether these
methods should be enabled?

Initially, my ToolbarController was sub to NSObject as was the case for
Apple's SimpleToolbar, so I changed the super class of my ToolbarController
to NSControl.  Since NSControl is a NSView, shouldn't the toolbar
automatically be in the Responder chain, just as any NSView in the window?

I read somewhere that NSView calls [self setRefusesFirstResponder:FALSE] ?

John
___

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

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

2008-07-07 Thread I. Savant
\On Mon, Jul 7, 2008 at 10:13 AM, Randy Canegaly [EMAIL PROTECTED] wrote:
 I have an application whose data model is an NSMutableArray with elements
 that could be pointers other NSMutableArrays, much like what you would
 navigate with a NSIndexPath.  I am using NSKeyedArchiver to archive the data
 model to a file.  Right now I archive the entire top level array object (and
 therefore all its parts) to the file using archiveRootObject:toFile.
 Is it possible to archive only the portion of the data model that changed

  There is no direct Cocoa Way to do this, AFAIK. Consider Core Data
(using the SQLite store type).

--
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: archive only what changed?

2008-07-07 Thread Andy Mroczkowski
Another possible option is CDBStore framework.  I haven't personally  
used it, but it claims to fill the gap between archiving/property  
lists and Core Data.


http://mooseyard.com/projects/CDBStore/

- Andy

On Jul 7, 2008, at 10:25 AM, I. Savant wrote:

\On Mon, Jul 7, 2008 at 10:13 AM, Randy Canegaly  
[EMAIL PROTECTED] wrote:
I have an application whose data model is an NSMutableArray with  
elements
that could be pointers other NSMutableArrays, much like what you  
would
navigate with a NSIndexPath.  I am using NSKeyedArchiver to archive  
the data
model to a file.  Right now I archive the entire top level array  
object (and

therefore all its parts) to the file using archiveRootObject:toFile.
Is it possible to archive only the portion of the data model that  
changed


 There is no direct Cocoa Way to do this, AFAIK. Consider Core Data
(using the SQLite store type).

--
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/andy%40mrox.net

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: Stopping actions mid stream

2008-07-07 Thread Jeff Brown
Thanks everyone.
I ended up just disabling the option in the end.

Cheers
Jeff


Thanks Andy and Jean-Daniel.

Peter


On 07/07/2008, at 3:34 AM, Andy Lee wrote:

Yes:

http://ignorethecode.net/blog/2008/07/01/disabling-inactive-menu-items/ 

(by way of DaringFireball)

--Andy

On Jul 6, 2008, at 11:57 AM, Jean-Daniel Dupas wrote:

I haven't test but -[NSMenuItem setToolTip:] look fine to do this.
Now, just chek if this methods works even when the item is disabled.

Le 6 juil. 08 à 16:31, Peter Zegelin a écrit :

Some of the commenters suggest a tool tip over the disabled menu explaining why 
it is disabled, which sounds reasonable. As a newby here would this be easy to 
implement in Cocoa?


snip

___




  Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au
___

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

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

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

This email sent to [EMAIL PROTECTED]


Being notified of current document change

2008-07-07 Thread Laurent Cerveau

Hi

This is probably a stupid question but : in a NSDocument application I  
did not found a way to be notified of change of currentDocument. For  
now I do some tricks with notification on window but I was wondering  
if I simply missed a part?


Thanks

laurent
___

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

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

2008-07-07 Thread Michael Ash
On Mon, Jul 7, 2008 at 2:36 AM, Andrew Farmer [EMAIL PROTECTED] wrote:
 On 06 Jul 08, at 23:24, Omar Qazi wrote:

 On Jul 6, 2008, at 7:46 AM, Martin Hairer wrote:

 This works like a treat and is faster by a factor 3 or so than using
 the Moriarity implementation. However, it leaves me a bit concerned
 about various warnings all over the place concerning the thread
 (un)safety of NSTask and NSFileHandle. So my question is: is the kind
 of approach that I am taking doable / reasonable? If not, is there an
 alternative way of doing this which is more efficient  than the
 Moriarty code? Thanks a lot in advance for any help / hint,

NSFileHandle *msgHandle = [standardInput fileHandleForReading];
[msgHandle waitForDataInBackgroundAndNotify];

 - (void)newMessage:(NSNotification *)notification {
NSString *strOutput = [[NSString alloc]initWithData:[msgHandle
 availableData] encoding:NSUTF8StringEncoding];
//Process the data
[msgHandle waitForDataInBackgroundAndNotify];
 }

 I'd be very careful with reading string input like that. It's entirely
 possible for a multi-byte character (é, for example, is represented as C3
 89) to be split across two separate data chunks, which'll make NSString very
 confused and angry.

 I'm not quite sure what the correct solution is here, though. There's got to
 be some easier solution than checking for sequence completeness by
 hand...

There are really three reasonable choices:

1) Gather all of the data into an NSMutableData buffer, then create an
NSString from it when the task terminates. This obviously doesn't work
so well if you want to display the output while the task is still
running, but it's very easy.

2) Look for an ASCII delimeter. UTF-8 is ASCII-compatible, which means
that if you see something in the stream that looks like a particular
ASCII character or character sequence, then it *is* that character or
sequence. So, for example, you can have an NSMutableData buffer, then
search the incoming data for the ASCII character '\n' or '\r' and
break it apart in those locations.

3) Look for a clean break in the UTF-8 sequence. This is not as
difficult as it sounds. There are two easy scenarios where you can
break. The first is after any ASCII character. You can scan your
NSMutableData buffer for any char value = 127, and break at that
location. Second, you can break *before* any char value that matches
this mask:

c  0xA == 0xA

This will find a char whose first two bits are both 1. In UTF-8, this
denotes the first character in a multi-byte sequence, so you know that
if you break right before that location, it's a safe place.

If you want to get fancier, it's possible to read the rest of that
first byte in the sequence and find out how long the sequence is, then
break at the end of it if you have all of it. But if you don't mind
leaving one extra character in your buffer from time to time (which
will get flushed out when more data arrives), then this is fine.

I should note that in all of these situations you should never assume
the data is always UTF-8. There's no requirement for it to be, it is
at best just a convention. Be prepared for the conversion to an
NSString to fail, and have some sort of reasonable fallback (flag an
error, try a more permissive encoding) in that case.

If anyone is interested in learning more about how UTF-8 works and how
you can parse it, the Wikipedia article is quite good:

http://en.wikipedia.org/wiki/UTF-8

It's a surprisingly simple format and it's easy to manipulate it
directly if you know a little bit about masking and bitshifting in C.

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: NSURLConnection how to handle 502 error

2008-07-07 Thread Kanny
I am still trying to find a solution to quickly resolve the web server 
502 error using NSURLRequest and NSURLConnection. Right now, even if i 
set timeoutinterval to 5 seconds, it takes 30 seconds. But more painful 
thing is that during that time, it makes the app unresponsive with the 
beach ball spinning. Let me know your strategies to handle 502 error.  
I would like something like Safari, it does take time (60-90 sec) to 
display the error message, but it doesn't halt the user's interaction 
with other tabs or windows of safari.


Alternately, is there a way to specify a strict time duration for a 
particular action to execute and return nil if it can't.


Thanks.

-Original Message-
From: [EMAIL PROTECTED]
To: cocoa-dev@lists.apple.com
Sent: Sun, 6 Jul 2008 4:25 am
Subject: NSURLConnection timeoutInterval  only works in multiples of 30 
seconds



Hi,

I am trying to do a periodic update (every 1 minute) based on the 
contents of a url, but when the website is down with 5** error, I would 
like to not wait more than a couple of seconds. So, I wrote the 
following code :


url = [NSURL ...];
updateTimer = [[NSTimer scheduledTimerWithTimeInterval:60.0 
target:self selector:@selector(update:)

     userInfo:nil repeats:YES] retain];
[updateTimer fire];
-(void)update:(id)sender
{
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url 
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:5];

   NSURLResponse *urlResponse;
   NSLog(@ Before );
NSData *urlData = [NSURLConnection 
sendSynchronousRequest:urlRequest returningResponse:urlResponse 
error:error];

   NSLog(@ After : Error = %@ ,error);
   .
   .
}


But when i run the app, the After statement with timed out message 
is logged after 30 seconds from the Before statement. When I set the 
timeoutInterval between 30.1 to 59.9, it is printed after 60 seconds 
and so on. I don't know how to get it to work in desired time 
intervals. Any help would be appreciated.


Thanks

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Efficiently receiving data from an NSTask

2008-07-07 Thread Charles Srstka

On Jul 7, 2008, at 10:16 AM, Michael Ash wrote:


3) Look for a clean break in the UTF-8 sequence. This is not as
difficult as it sounds. There are two easy scenarios where you can
break. The first is after any ASCII character. You can scan your
NSMutableData buffer for any char value = 127, and break at that
location. Second, you can break *before* any char value that matches
this mask:

   c  0xA == 0xA

This will find a char whose first two bits are both 1.


Um, no it won't. The mask for the first two bits would be 0xC0, not  
0xA. 0xA would be 0101, which other than being the ASCII newline  
character, doesn't seem terribly interesting for this use.


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Toolbar code in separate Controller?

2008-07-07 Thread Graham Cox


On 8 Jul 2008, at 12:13 am, John Love wrote:

Initially, my ToolbarController was sub to NSObject as was the case  
for
Apple's SimpleToolbar, so I changed the super class of my  
ToolbarController

to NSControl.


Huh? This makes no sense whatsoever. Why not just make your toolbar's  
delegate/controller the document and save yourself a whole heap o'  
hassle? That's what I expect most people do and it's the easiest  
solution. After all, the document is the controller that pulls  
together all the different bits of UI that your app uses per document,  
such as toolbars, windows, etc. It's the logical place. Sometimes  
making a separate controller makes sense (like for a dialog box),  
sometimes making some existing object do that job makes sense -  
typically a document subclass does end up acting as a bit of a jack of  
all trades in terms of handling various odd bits of different  
functionality (but all related to the document, naturally).


If you really want to do it the hard way, you could maybe subclass  
NSResponder (but definitely NOT NSControl). Even so, no responder is  
put automatically into the responder chain unless it's a view (or  
view's owner) that the user explicitly makes key in some way.  
However, your document is in the responder chain by design - another  
good reason to use it to handle your toolbar. However, making a  
controller a view subclass just to obtain the ability to make it key  
is simply wrong and will never work.




I read somewhere that NSView calls [self  
setRefusesFirstResponder:FALSE]



Only NSControl and NSCell implement this method, as typing it into the  
documentation window's search box will show in a second. So you're  
barking up the wrong tree here.


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: NSURLConnection how to handle 502 error

2008-07-07 Thread Mike Abdullah
I don't know the full solution, but for a start, is there a particular  
reason you are using a synchronous request? Use the asynchronous API  
and the main thread won't be locked.


On 7 Jul 2008, at 16:27, Kanny wrote:

I am still trying to find a solution to quickly resolve the web  
server 502 error using NSURLRequest and NSURLConnection. Right now,  
even if i set timeoutinterval to 5 seconds, it takes 30 seconds. But  
more painful thing is that during that time, it makes the app  
unresponsive with the beach ball spinning. Let me know your  
strategies to handle 502 error.  I would like something like Safari,  
it does take time (60-90 sec) to display the error message, but it  
doesn't halt the user's interaction with other tabs or windows of  
safari.


Alternately, is there a way to specify a strict time duration for a  
particular action to execute and return nil if it can't.


Thanks.

-Original Message-
From: [EMAIL PROTECTED]
To: cocoa-dev@lists.apple.com
Sent: Sun, 6 Jul 2008 4:25 am
Subject: NSURLConnection timeoutInterval  only works in multiples of  
30 seconds



Hi,

I am trying to do a periodic update (every 1 minute) based on the  
contents of a url, but when the website is down with 5** error, I  
would like to not wait more than a couple of seconds. So, I wrote  
the following code :


url = [NSURL ...];
updateTimer = [[NSTimer scheduledTimerWithTimeInterval:60.0  
target:self selector:@selector(update:)

userInfo:nil repeats:YES] retain];
[updateTimer fire];
-(void)update:(id)sender
{
   NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url  
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:5];

  NSURLResponse *urlResponse;
  NSLog(@ Before );
   NSData *urlData = [NSURLConnection  
sendSynchronousRequest:urlRequest returningResponse:urlResponse  
error:error];

  NSLog(@ After : Error = %@ ,error);
  .
  .
}


But when i run the app, the After statement with timed out  
message is logged after 30 seconds from the Before statement. When  
I set the timeoutInterval between 30.1 to 59.9, it is printed after  
60 seconds and so on. I don't know how to get it to work in desired  
time intervals. Any help would be appreciated.


Thanks

___

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

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

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

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: Being notified of current document change

2008-07-07 Thread Graham Cox
I'm not sure if there is a better way, but subscribing to NSWindow  
didBecomeMain/didResignMain, then using:


	NSDocument* cd = [[NSDocumentController sharedDocumentController]  
currentDocument];


is one way to do it.

hth,


Graham


On 8 Jul 2008, at 1:14 am, Laurent Cerveau wrote:


Hi

This is probably a stupid question but : in a NSDocument application  
I did not found a way to be notified of change of currentDocument.  
For now I do some tricks with notification on window but I was  
wondering if I simply missed a part?


Thanks

laurent

___

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

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

2008-07-07 Thread Michael Ash
On Mon, Jul 7, 2008 at 11:52 AM, Charles Srstka
[EMAIL PROTECTED] wrote:
 On Jul 7, 2008, at 10:16 AM, Michael Ash wrote:

 3) Look for a clean break in the UTF-8 sequence. This is not as
 difficult as it sounds. There are two easy scenarios where you can
 break. The first is after any ASCII character. You can scan your
 NSMutableData buffer for any char value = 127, and break at that
 location. Second, you can break *before* any char value that matches
 this mask:

   c  0xA == 0xA

 This will find a char whose first two bits are both 1.

 Um, no it won't. The mask for the first two bits would be 0xC0, not 0xA. 0xA
 would be 0101, which other than being the ASCII newline character, doesn't
 seem terribly interesting for this use.

You're right, my bad. I even checked 0xC0 to make sure it was the
right one, but I guess I got momentarily distracted and somehow put in
this nonsense instead.

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: NSSpeechSynthesizer and empty strings

2008-07-07 Thread Sean McBride
On 6/26/08 11:30 PM, Michael Ash said:

 No; don't ever do that. It is possible for an NSString to have zero length
 but not be empty.

This is backwards. You can have a string that is empty but has
non-zero length, due to the characters it contains being semantically
null.

Neat.  Could you give an example?

Thanks,

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

2008-07-07 Thread Charles Srstka

On Jul 7, 2008, at 11:04 AM, Michael Ash wrote:

Um, no it won't. The mask for the first two bits would be 0xC0, not  
0xA. 0xA
would be 0101, which other than being the ASCII newline character,  
doesn't

seem terribly interesting for this use.


You're right, my bad. I even checked 0xC0 to make sure it was the
right one, but I guess I got momentarily distracted and somehow put in
this nonsense instead.


Oh well, if it makes you feel any better, I appear to have screwed up  
too - 0xA is 1010, not 0101. D'oh.


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Efficiently receiving data from an NSTask

2008-07-07 Thread Daryle Walker

On Jul 7, 2008, at 11:19 AM, Michael Ash wrote:


3) Look for a clean break in the UTF-8 sequence. This is not as
difficult as it sounds. There are two easy scenarios where you can
break. The first is after any ASCII character. You can scan your
NSMutableData buffer for any char value = 127, and break at that
location. Second, you can break *before* any char value that matches
this mask:

c  0xA == 0xA

This will find a char whose first two bits are both 1. In UTF-8, this
denotes the first character in a multi-byte sequence, so you know that
if you break right before that location, it's a safe place.



A hexadecimal digit represents a nybble (4 bits), or half a byte.   
Getting the highest-order 2 digits of a byte would be 0xA0--whoops it  
would be 0xC0.  (A == 10 == 1010b, C == 12 == 1100b.)  So looking at  
http://en.wikipedia.org/wiki/UTF-8:


c  0xC0 == 0xC0 - you have the 1st char of a multi-byte sequence
c  0xC0 == 0x80 - you have a later char of a multi-byte sequence
 - back up until you find a char of the 1st case
otherwise - you have a one-byte char

--
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT 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]


NSButton in a NSPanel's top-right corner?

2008-07-07 Thread Relindor

Hi there

I would like to have a NSButton in my NSPanel's top-right corner (Like  
the app on this image: http://img363.imageshack.us/img363/5733/bild5ex0.png 
 ) but I have absolutely no idea of how to achieve this so any help  
would be appreciated.

Thanks,
Tim
___

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

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

2008-07-07 Thread Joan Lluch (casa)
Core Data does a really good job at what you are describing, when  
using SQLite as a persistent store, although this may not be what are  
you looking for.


The only other approach to this that I think of is to cache the  
objects that change in your model and then only store these objects  
either directly or by tweaking the NSCoding protocol methods in your  
model, but then your code will have to be clever enough to know what  
files or parts will have to retrieve if a revert operation is  
requested. However, it looks to me too complicated or worthless to  
follow that route.


If storing your model is really a performance issue, then you might  
consider going to Core Data and SQLite stores.


Joan Lluch

El 07/07/2008, a las 16:13, Randy Canegaly escribió:

I have an application whose data model is an NSMutableArray with  
elements that could be pointers other NSMutableArrays, much like  
what you would navigate with a NSIndexPath.  I am using  
NSKeyedArchiver to archive the data model to a file.  Right now I  
archive the entire top level array object (and therefore all its  
parts) to the file using archiveRootObject:toFile.
Is it possible to archive only the portion of the data model that  
changed rather than the entire thing every time?  I need the entire  
data model to be archived so that it can be reloaded when the  
application starts but for performance reasons I am interested in  
seeing if it's possible upon a change to the data to only re-archive  
the small part that changed.

___

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

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

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

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: NSButton in a NSPanel's top-right corner?

2008-07-07 Thread Kyle Sluder
Get a reference to a standard button using -[NSWindow
standardWindowButton:], and then insert your button into its
superview.  Position it as you normally would.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Guidelines for Cocoa frameworks supporting garbage collection?

2008-07-07 Thread Sean McBride
On 7/5/08 2:56 PM, Chris Hanson said:

For example, this pseudocode is wrong under GC:

   - (NSURL *)someURL {
   NSURL *URL = (NSURL *)CFURLCreate...(...);
   return [URL autorelease];
   }

It will leak, because the runtime will eat the -autorelease message
when running under GC.

Which reminds me of something else Bill might want to watch out for:
Apple's leak finding tools ('leaks', Instruments, Malloc Debug) do not
work with GC apps.  They report so many false positives that they are
unworkable (except for Malloc Debug, which just crashes).  So if your
code uses malloc/new/NewPtr of whatever, you'll have a hard time finding
leaks.

Also, I second the recommendation to stay away from finalize.  I've used
it exactly twice: 1) to call DisposeHandle() to 2) to call NSLog.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: garbage collection and NSConnection

2008-07-07 Thread Sean McBride
On 7/6/08 11:18 PM, Hamish Allan said:


collectExhaustively
Tells the receiver to collect iteratively.

- (void)collectExhaustively

Discussion
You use this method to indicate to the collector that it should
perform an exhaustive collection. Collection is subject to
interruption on user input.

Availability Available in Mac OS X v10.5 and later.
Declared In NSGarbageCollector.h


Collection is subject to interruption on user input -- with no
mention of when it might be re-started.

There's always the lower-level:

objc_collect (OBJC_EXHAUSTIVE_COLLECTION |
OBJC_WAIT_UNTIL_DONE);

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

This email sent to [EMAIL PROTECTED]


debugging runaway allocations under gc

2008-07-07 Thread [EMAIL PROTECTED]
We have an out of memory crasher in a gc app that we are trying 
debug, but I'm having a bit of difficulty bringing the correct tools 
to bear on the problem.


I suspect that either we have some kind of runaway loop that's 
allocating us into oblivion, or we're outrunning the collector (I 
suspect the latter because the crash is never in exactly the same 
place, and no long processes are in progress).  I have a reproducible 
case where we basically hammer the app with the same command over and 
over again (via script_, and memory usage does indeed increase 
(albeit slowly) over time, but at some stage it reaches a tipping 
point where the allocation just runs away quickly, and in the course 
of a couple seconds consumes all available resources and crashes.


I tried running heap to see what was actually allocated and where, 
but after two hours pegging one of my four cores, heap is still 
churning.  I tried using MallocDebug, but it's not compatible with gc 
(apparently).  I tried using ObjectAlloc in instruments, but it 
generates so much data that instruments itself chokes on all the data 
and starts the machine churning (I was hoping for a windowed time 
facility as in Shark).  I even tried conditional breakpoints on 
malloc to try to catch large allocations, but I don't think I've got 
the syntax of the condition right (I did manage to get it working 
using a debugger command for the breakpoint, but after a while it 
stops working).


So now I'm looking for pointers on where I should be poking to try to 
get more data.  What are good strategies to try and see if I'm 
outrunning the collector?  Can I detect a low resource situation (for 
debug purposes only) and wait it out a bit and see if the collector 
catches up? (how?)  What's the best way to find large malloc 
allocations that doesn't involve instruments collapsing under the 
load of data?  (it can take 10 minutes or more to reach the failure 
point).  All pointers appreciated.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLConnection how to handle 502 error

2008-07-07 Thread Scott Tury

Kanny,

On Jul 7, 2008, at 1:37 PM, [EMAIL PROTECTED] wrote:


I am still trying to find a solution to quickly resolve the web server
502 error using NSURLRequest and NSURLConnection. Right now, even if i
set timeoutinterval to 5 seconds, it takes 30 seconds. But more  
painful

thing is that during that time, it makes the app unresponsive with the
beach ball spinning. Let me know your strategies to handle 502 error.
I would like something like Safari, it does take time (60-90 sec) to
display the error message, but it doesn't halt the user's interaction
with other tabs or windows of safari.



It sounds from your description that you are doing a synchronous  
request on your applications'  main thread.  Modifying your code to  
not make the synchronous request will enable you to avoid locking out  
the UI interaction from the user.  This sounds like your biggest issue.


So instead of something lie this:

NSURLResponse *urlResponse = nil;
   NSError *error = nil;
	NSData* data = [NSURLConnection sendSynchronousRequest:myRequest  
returningResponse:urlResponse error:error];


You would in modify the code to specify a delegate object (in this  
example the current object), and create an asynchronous connection:


	NSURLConnection* urlConnection = [[NSURLConnection alloc]  
initWithRequest:urlRequest delegate:self startImmediately:YES];


Now the request will be scheduled on the main event loop, and you  
won't tie up the UI.  Your delegate object will be called when you  
have data or other information about the connection you have attempted  
to have open.


Scott


___

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

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

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

This email sent to [EMAIL PROTECTED]


More CALayer Questions

2008-07-07 Thread Gordon Apple
I'm suffering from extreme frustration with CALayers.  I obviously don't
understand the documentation available and there is a lot that is not
documented, especially since the Views guide has not been updated to include
CALayers.  Also, as others have observed, the flipped paremeter in
[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES] simply
does not work.

I have a view with inverted coordinates.  I have been able to use a
stack of layers to draw when the view is unmodified.  However, when I scale
the view by any means (usually by changing the frame and resetting to the
original bounds), it works without layers, but when using layers I cannot
get the layers to track and can't seem to force them into the right scale
and position.  I've simplified it to just use only the view's layer and
still can't get it to work properly.

One source of confusion is the anchorPoint/Position relation.  Reference
says The position is relative to anchorPoint.  Huh?  What anchorPoint? --
the layer in question, or its superLayer?  And what does this mean for the
view's layer in terms of the view's coordinates?

Another one is frame.  Specifies receiver¹s frame rectangle in the
super-layer¹s coordinate space.  So ok, how does the view's layer frame
relate to the view's frame?

Both of these questions can likely be answered by the question: How do
the view's layer coordinates relate to the view's coordinates?  Also, do
springs and struts have any meaning between view and layer?

The questions are going to get worse when I start trying to change the
view's bounds size (drawing canvas size), but let's handle one issue at a
time and stick with scaling for now.

Apparently, the view's layer corresponds to the view itself when
created, with the possible exception of coordinate inversion.  I can flip by
transforming the context when drawing, but I would rather transform the
layer, because the latter is also involved when changing scaling.  However,
this gets involved with the entire anchorPoint/position question because the
transform is not around thelayer's bounds origin, but around the
anchorPoint.

What I'm trying to do is conceptually very simple, I just want to scale
the view and have its layer position and scale the same, so that drawing
into the scaled view comes out the same whether layer-backed or not.  Then,
once that works, I will try stacking individual sub-layers again.

Any insights would be appreciated.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Sub-classing NSAtomicStore

2008-07-07 Thread Todd Stanley
Hi All,

Has any one had any luck working with the AutomicStoreSubclass example.  I
need to manage and AtomicStore and thought that I would be able to use the
AutomicStoreSubclass example as a road-map.  When I
addPersistentStoreWithType as follows -

if ([coordinator addPersistentStoreWithType:@AtomicStore
configuration:nil URL:url options:storeOptionsDict error:error])

I get the following error -

Error Domain=NSCocoaErrorDomain Code=134010 UserInfo=0x162240 The store
type is inconsistent with the data format.

Anyone know of any gotchas when subclassing NSAtomicStore?

Todd
___

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

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

2008-07-07 Thread Jens Alfke


On 7 Jul '08, at 12:42 PM, Gordon Apple wrote:

   One source of confusion is the anchorPoint/Position relation.   
Reference
says The position is relative to anchorPoint.  Huh?  What  
anchorPoint? --
the layer in question, or its superLayer?  And what does this mean  
for the

view's layer in terms of the view's coordinates?


When you set the position property of a layer, the point you specify  
becomes the location (in the superlayer's coords) of the layer's  
anchorPoint. The anchorPoint is specified in unit coordinates that  
range from 0 at one side to 1 at the other, so it's independent of  
scale.


So if the layer's anchorPoint is (0.5,0.5), as it is by default, then  
if you set its position to (100,100), the center point of the layer  
will be at (100,100).
But if the anchorPoint were (0,0), then the top left point of the  
layer would be at (100,100) ... assuming non-flipped coords.


   Another one is frame.  Specifies receiver’s frame rectangle in  
the
super-layer’s coordinate space.  So ok, how does the view's layer  
frame

relate to the view's frame?


I am not sure; I don't work with layers directly embedded in views  
much. (I usually just have one big view and work with layers inside  
it.) My expectation would be that the layer's frame would be the same  
as the view's bounds.


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


Releasing objects causes BAD_ACCESS

2008-07-07 Thread Meik Schuetz

Dear all,

according to the document

http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

the connection object as well as the receivedData object are released  
in the connectionDidFinishLoading delegate. However, while debugging,  
I receive an BAD_ACCESS violation doing the release. Can anyone please  
give me some insight on why this is happening? Is there any strategy/  
debugging tool that helps me to find objects that should have been  
released or should I just rely on GC?


Thanks so much
Best regards
Meik

___

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

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

2008-07-07 Thread Jonathan del Strother
On Mon, Jul 7, 2008 at 10:38 PM, Meik Schuetz [EMAIL PROTECTED] wrote:
 Dear all,

 according to the document

 http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

 the connection object as well as the receivedData object are released in the
 connectionDidFinishLoading delegate. However, while debugging, I receive an
 BAD_ACCESS violation doing the release. Can anyone please give me some
 insight on why this is happening? Is there any strategy/ debugging tool that
 helps me to find objects that should have been released or should I just
 rely on GC?



NSZombieEnabled is a good start -
http://developer.apple.com/technotes/tn2004/tn2124.html#SECFOUNDATION
___

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

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

2008-07-07 Thread Randall Meadows

On Jul 7, 2008, at 3:44 PM, Jonathan del Strother wrote:
On Mon, Jul 7, 2008 at 10:38 PM, Meik Schuetz [EMAIL PROTECTED]  
wrote:

according to the document

http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

the connection object as well as the receivedData object are  
released in the
connectionDidFinishLoading delegate. However, while debugging, I  
receive an
BAD_ACCESS violation doing the release. Can anyone please give me  
some
insight on why this is happening? Is there any strategy/ debugging  
tool that
helps me to find objects that should have been released or should I  
just

rely on GC?


NSZombieEnabled is a good start -
http://developer.apple.com/technotes/tn2004/tn2124.html#SECFOUNDATION


See also Technical Note TN2124 - Mac OS X Debugging Magic:
http://developer.apple.com/technotes/tn2004/tn2124.html
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: More CALayer Questions

2008-07-07 Thread Gordon Apple
OK, a little update.  Through watching a number of parameters, a lot of
experimentation, and probably blind a** luck, I've managed to get rescaling
to sort of work.  However, to do editing of objects (e.g., dragging them
around), I had to call removeAllAnimations.  When I change the scale, the
scale does change, but the layer does not change to the correct position
until I resize the window -- then it snaps into correct position.  Resizing
the window results in the drawing disappearing and reappearing, mostly
reappearing when downsizing.  It also disappears when scrolled, until the
window is resized. I assume this has something to do with re-caching the
layer.  How do I fix that?

I need to get this working right before I go back to stacking layers.

BTW, I've preordered (July 17) the upcoming book on animation, but I
have no idea whether or not it will have anything useful for these CALayer
issues.


   I'm suffering from extreme frustration with CALayers.  I obviously don't
 understand the documentation available and there is a lot that is not
 documented, especially since the Views guide has not been updated to include
 CALayers.  Also, as others have observed, the flipped paremeter in
 [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES] simply
 does not 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: garbage collection and NSConnection

2008-07-07 Thread Hamish Allan
On Mon, Jul 7, 2008 at 6:33 PM, Sean McBride [EMAIL PROTECTED] wrote:

 There's always the lower-level:

objc_collect (OBJC_EXHAUSTIVE_COLLECTION |
OBJC_WAIT_UNTIL_DONE);

If this were called from the main thread, would it guarantee that the
collector run without interruption, given that user input would be
suspended?

Otherwise, there's still rather a difference between do and wait
until done...

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Delete action from variety of key presses

2008-07-07 Thread Nathan Vander Wilt
I want to be able to delete the items selected in a view, but am  
struggling finding a best way to turn the different key presses into a  
-delete: action that my controller can handle. I think I want (it  
seems expected functionality anyway) the delete key, the forward  
delete key, as well as Cmd-Delete to all trigger this action.


I could assign one of those as a Key Equivalent for the EditDelete  
menu item, but that leaves the other two out in the cold. Furthermore,  
several applications (Keynote, iTunes) don't show any such key  
equivalent yet accept some or all of those keystrokes to delete a  
selection. iPhoto has PhotosMove To Trash equivalized to Cmd-Delete,  
but also performs that action if simply Delete is pressed. So I'm not  
finding a lot of clues in existing applications.


A search through the archives would have me either a) add hidden  
buttons equivalent to these keys or b) subclass view(s) to handle the  
keystrokes myself. The first option seems really, really hackish but  
the second option means I'd have to subclass any view that could be  
key when the user wants to delete, and implement the same keychecking  
method in each. Is there a cleaner way to let my controller know  
whenever the user wants delete? Or am I making this too complicated  
to begin with somehow?


thanks,
-natevw
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why aren't my bindings firing?

2008-07-07 Thread Hamish Allan
On Thu, Jul 3, 2008 at 1:12 AM, mmalc crawford [EMAIL PROTECTED] wrote:

 On Jul 2, 2008, at 4:04 PM, Hamish Allan wrote:

 This is a rather unuseful attitude to take. Clearly, this thread
 started as a result of the distinction. Also, Apple's own
 documentation disagrees with you, as it states that Cocoa bindings are
 built on KVB.

 No, it doesn't.

No, really, it does! Read Ken's post again: he links to docs that talk
of Cocoa bindings relying on KVB, and KVB being one of the main
technologies underpinning Cocoa bindings. You yourself make pretty
much the same distinction:

 Cocoa bindings is an abstract term that refers to a collection of
 technologies that used together keep views, controllers, and models
 synchronised.
 Key-value binding is one of those technologies.

 There are not two different kinds of binding.

If that is the case, let me ask: is KVB unidirectional or bi-directional?

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: More CALayer Questions

2008-07-07 Thread douglas a. welton

See my comments embedded below...

On Jul 7, 2008, at 3:42 PM, Gordon Apple wrote:

   I'm suffering from extreme frustration with CALayers.  I  
obviously don't

understand the documentation available and there is a lot that is not
documented, especially since the Views guide has not been updated to  
include

CALayers.  Also, as others have observed, the flipped paremeter in
[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]  
simply

does not work.


A layer's context exist without regards to the current drawing  
context.  This makes sense because layer do not necessarily have to be  
rendered anywhere.  Why should they care about the graphic context?   
If you care about the context when you are drawing, then query the  
context being passed to your drawing method or delegate method.   
NSGraphicsContext's -isFlipped method may become your new best  
friend . ;^}



 I have a view with inverted coordinates.  I have been able to use a
stack of layers to draw when the view is unmodified.  However, when  
I scale
the view by any means (usually by changing the frame and resetting  
to the
original bounds), it works without layers, but when using layers I  
cannot
get the layers to track and can't seem to force them into the right  
scale
and position.  I've simplified it to just use only the view's layer  
and

still can't get it to work properly.


What exactly are you doing to scale your views? layers?

When scaling layers within a non-scrolling view, I have used the  
following method:


	[targetLayer setValue: [NSNumber numverWithFloat: newScaleValue]  
forKeyPath: @scale];


Usually, I place a statement like this in an action method that is  
targetted by a slider and it produces no-brainer results


When I needed to scale a layer hosted by a view that was enclosed in a  
NSScrollview, i used the following method:


clipView = [targetScrollView contentView];
`	newBoundsSize = NSMakeSize( NSWidth( [clipView frame] ) /  
newScaleValue, NSHeight( [clipView frame]) / newScaleValue);

[clipView setBoundsSize: newBoundsSize];

This works for the most part.  The scaling is sluggish and sometimes  
the view doesn't redraw properly until a scroller is movedc.


Have you tried both of these methods?  Other methods?

   One source of confusion is the anchorPoint/Position relation.   
Reference
says The position is relative to anchorPoint.  Huh?  What  
anchorPoint? --

the layer in question, or its superLayer?


Think of the anchor point as the place where you stick a pin into the  
layer when positioning it.  An anchorpoint of (0.0, 0.0) puts the pin  
in the lower left corner.  An anchorPoint of (0.5, 0.5) puts the pin  
in the center.  And an achorPoint of (1.0, 1.0) places the pin in the  
upper right corner.


Your layer's position will be aligned based on where the pin is stuck.


  And what does this mean for the
view's layer in terms of the view's coordinates?


Important:  There is no (real) implicit relationship between a view's  
coordinate system and any of the hosted layer's coordinate system...   
or at least not one that I have been able to find a reference to.   
From what I have observed, the view's layer ( i.e., the layer  
property)  seems to operate as if the bounds of the enclosing view  
defines its geometry.



 Another one is frame.  Specifies receiver’s frame rectangle in the
super-layer’s coordinate space.  So ok, how does the view's layer  
frame

relate to the view's frame?
Both of these questions can likely be answered by the question: How do
the view's layer coordinates relate to the view's coordinates?


See previous Important notice.  For any arbitrary layer that is  
hosted within a view, there is no actual relationship between the  
view's frame and the layer's frame.  Remember, the frame of a layer is  
computed dynamically given an anchorPoint, position, bounds and  
transform matrix.  The transform matrix is very important in this  
equation.


Also Important:  Note that if you want to convert from a layer's  
coordinate system to the view coordinate system, there is really no  
out-of-the-box way to do this.  Somewhere in the archives is a  
discussion of this.  If you need to know this relationship (for hit  
testing, for example) then you'll have to roll your own... or rethink  
how you are doing this (I had to follow this route, but ultimately it  
made my code simpler)



Also, do springs and struts have any meaning between view and layer?


I think not.  Layers have no clue as to what a view is.  You can't ask  
a layer what view is currently hosting it.  Moreover, a layer can  
exist without being in a view all together.  If you want to manage the  
springs and struts of you layers, then you need to make friend with  
CAConstraint.  Constraints give you mare flexibility (my opinion) to  
manage how your layers are laid out in regards to one another



The questions are going to get worse when I start trying to change the
view's 

Re: More CALayer Questions

2008-07-07 Thread douglas a. welton

Hi Gordon,

I'm not sure what you really want to do is -removeAllAnimations.  I  
suspect that you probably want to temporarily disable animation within  
the scope of a CATransaction.  Take a look at the code found here:


	http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Transactions.html#//apple_ref/doc/uid/TP40006096-SW9 



later,

douglas

On Jul 7, 2008, at 6:05 PM, Gordon Apple wrote:

   OK, a little update.  Through watching a number of parameters, a  
lot of
experimentation, and probably blind a** luck, I've managed to get  
rescaling
to sort of work.  However, to do editing of objects (e.g., dragging  
them
around), I had to call removeAllAnimations.  When I change the  
scale, the
scale does change, but the layer does not change to the correct  
position
until I resize the window -- then it snaps into correct position.   
Resizing

the window results in the drawing disappearing and reappearing, mostly
reappearing when downsizing.  It also disappears when scrolled,  
until the
window is resized. I assume this has something to do with re-caching  
the

layer.  How do I fix that?

   I need to get this working right before I go back to stacking  
layers.


   BTW, I've preordered (July 17) the upcoming book on animation,  
but I
have no idea whether or not it will have anything useful for these  
CALayer

issues.


 I'm suffering from extreme frustration with CALayers.  I obviously  
don't

understand the documentation available and there is a lot that is not
documented, especially since the Views guide has not been updated  
to include

CALayers.  Also, as others have observed, the flipped paremeter in
[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]  
simply

does not 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/douglas_welton%40earthlink.net

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: More CALayer Questions

2008-07-07 Thread Bill Dudney

Hi Gordon,

'the upcomming book on animation'?

If by that you mean the Core Animation book from Pragmatic Programmers  
you can get the PDF now from


http://www.pragprog.com/titles/bdcora

and then the paper when it ships. You get a really good discount on it  
if you buy both.


Not sure where the July 17 date comes from (amazon.com?) but its  
likely off by at least 2 weeks and probably a bit more like 4.


Now on to the real question... Basically what you are doing is  
confusing the tar out of the layer living in your view by messing with  
any of its properties.


If you do something like this;

myView.wantsLayer = YES;

And then do something like this;

myView.layer.position = myPoint;

you are asking for trouble.

You should instead do something like this;

myView.layer = [CALayer layer];
myView.wantsLayer = YES:
layerToMove = [CALayer layer];
[myView.layer addSublayer:layerToMove]

then you can

layerToMove.position = somePoint;

To your hearts desire and everything should be lovely :)

Then if you want to do 'struts and springs' type stuff with  
layerToMove you can use a layoutManager to do all sorts of cool and  
exciting stuff.


Good luck!

-bd-
http://bill.dudney.net/roller/objc

On Jul 7, 2008, at 4:05 PM, Gordon Apple wrote:

   OK, a little update.  Through watching a number of parameters, a  
lot of
experimentation, and probably blind a** luck, I've managed to get  
rescaling
to sort of work.  However, to do editing of objects (e.g., dragging  
them
around), I had to call removeAllAnimations.  When I change the  
scale, the
scale does change, but the layer does not change to the correct  
position
until I resize the window -- then it snaps into correct position.   
Resizing

the window results in the drawing disappearing and reappearing, mostly
reappearing when downsizing.  It also disappears when scrolled,  
until the
window is resized. I assume this has something to do with re-caching  
the

layer.  How do I fix that?

   I need to get this working right before I go back to stacking  
layers.


   BTW, I've preordered (July 17) the upcoming book on animation,  
but I
have no idea whether or not it will have anything useful for these  
CALayer

issues.


 I'm suffering from extreme frustration with CALayers.  I obviously  
don't

understand the documentation available and there is a lot that is not
documented, especially since the Views guide has not been updated  
to include

CALayers.  Also, as others have observed, the flipped paremeter in
[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]  
simply

does not 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/bdudney%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: Delete action from variety of key presses

2008-07-07 Thread Ken Thomases

On Jul 7, 2008, at 5:29 PM, Nathan Vander Wilt wrote:

I want to be able to delete the items selected in a view, but am  
struggling finding a best way to turn the different key presses  
into a -delete: action that my controller can handle. I think I  
want (it seems expected functionality anyway) the delete key, the  
forward delete key, as well as Cmd-Delete to all trigger this action.


The Cocoa Text Bindings system already translates keys and key  
combinations into invocations of NSResponder methods.  http:// 
developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/ 
TextDefaultsBindings/chapter_9_section_1.html


So, what you need to do is determine which methods those keys are  
already mapping to, override those methods in the appropriate place  
in your responder chain (e.g. on your custom view or application  
delegate), and have them all invoke some common method to do what you  
want.


Here's a (somewhat dated) third-party page describing the text- 
binding system: http://www.hcs.harvard.edu/~jrus/Site/Cocoa%20Text% 
20System.html.


And here's that guy's list of the default bindings, which has a few  
minor inaccuracies but should be mostly useful: http:// 
www.hcs.harvard.edu/~jrus/Site/system-bindings.html.


The definitive list can be found by interpreting /System/Library/ 
Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict, but  
the use of non-printable characters can make interpreting that file  
somewhat difficult.


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: [NSTextStorage/NSAttributedString] How can we know the height of a rendered string?

2008-07-07 Thread Jean-Daniel Dupas


Le 7 juil. 08 à 23:54, Stéphane Sudre a écrit :



On Jul 6, 2008, at 11:26 PM, Jean-Daniel Dupas wrote:


Le 6 juil. 08 à 21:25, Stéphane Sudre a écrit :


Problem:


I would like/need to know the height that would be required to  
render a string inside a fixed width box.


Solution that does not work:


So far, I've been using a solution found from a google search and  
which looks like this:


- (float) heightOfString:(NSString *) inString forFont:(NSFont *)  
inFont andMaxWidth:(float) inMaxWidth

{
float tHeight=0;

if (inString!=nil)
{
[...]
}

return tHeight;
}


usedRectForTextContainer: causes neither glyph generation nor  
layout, and so the result is may be inaccurate (the layout manager  
may be computing the layout in background and does not have finish).

You have to make sure it is ready before using this function.

[tLayoutManager ensureLayoutForTextContainer:tTextContainer];


I'm running on Mac OS X 10.4.11, this method is only available on  
Leopard and later.


But this made me think of trying setBackgroundLayoutEnabled: with  
NO. Yet it does not solve the issue.


Maybe someone has a better solution, but I think you can mimic the - 
ensureLayoutForTextContainer: method behavior using this:


[layoutManager boundingRectForGlyphRange:[layoutManager  
glyphRangeForTextContainer:myContainer] inTextContainer:myContainer];


The doc says this method Performs glyph generation and layout if  
needed. And after you can send an -usedRectForTextContainer: message.







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: Delete action from variety of key presses

2008-07-07 Thread Nathan Vander Wilt
The Cocoa Text Bindings system already translates keys and key  
combinations into invocations of NSResponder methods. http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/chapter_9_section_1.html 



So, what you need to do is determine which methods those keys are  
already mapping to, override those methods in the appropriate place  
in your responder chain (e.g. on your custom view or application  
delegate), and have them all invoke some common method to do what  
you want.


Thanks, I forgot to mention that I tried overriding some of those  
action methods. However, I couldn't get them to fire.


If I implement:

- (BOOL)acceptsFirstResponder {
return YES;
}

- (void)keyDown:(NSEvent*)keyEvent {
(void)keyEvent;
printf(key event received\n);
}

- (void)deleteBackward:(id)sender {
(void)sender;
printf(delete backward received\n);
}

- (void)deleteForward:(id)sender {
(void)sender;
printf(delete forward received\n);
}


...and then press delete or forward-delete, I only ever get key event  
received. According to the chart at http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_3.html#/ 
/apple_ref/doc/uid/1060i-CH3-SW10, it looks like the event should  
flow all the way down to the Key Action? conditional, and since it's  
a bound key binding I thought I should get the Yes: Send action  
message to first responder path.


However, on further investigation, I see that this is just a  
potential path diagram, and seems to be an example for if the first  
responder view is a text one, which mine will rarely be. Under what  
circumstances will the Cocoa Text Bindings system convert keypresses  
to the text actions, so that a non-NSResponder (ie, a window/app  
delegate) can perform the action?


thanks,
-natevw
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delete action from variety of key presses

2008-07-07 Thread Greg Titus

Hi Nathan,

By overriding -keyDown: and not calling [super keyDown:keyEvent], you  
have stopped your view from actually processing the keys any further.  
That's why you aren't getting to either of the delete methods.


Hope this helps,
- Greg

On Jul 7, 2008, at 4:59 PM, Nathan Vander Wilt wrote:

The Cocoa Text Bindings system already translates keys and key  
combinations into invocations of NSResponder methods. http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/chapter_9_section_1.html 



So, what you need to do is determine which methods those keys are  
already mapping to, override those methods in the appropriate place  
in your responder chain (e.g. on your custom view or application  
delegate), and have them all invoke some common method to do what  
you want.


Thanks, I forgot to mention that I tried overriding some of those  
action methods. However, I couldn't get them to fire.


If I implement:

- (BOOL)acceptsFirstResponder {
return YES;
}

- (void)keyDown:(NSEvent*)keyEvent {
(void)keyEvent;
printf(key event received\n);
}

- (void)deleteBackward:(id)sender {
(void)sender;
printf(delete backward received\n);
}

- (void)deleteForward:(id)sender {
(void)sender;
printf(delete forward received\n);
}


...and then press delete or forward-delete, I only ever get key  
event received. According to the chart at http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_3.html#/ 
/apple_ref/doc/uid/1060i-CH3-SW10, it looks like the event  
should flow all the way down to the Key Action? conditional, and  
since it's a bound key binding I thought I should get the Yes: Send  
action message to first responder path.


However, on further investigation, I see that this is just a  
potential path diagram, and seems to be an example for if the  
first responder view is a text one, which mine will rarely be. Under  
what circumstances will the Cocoa Text Bindings system convert  
keypresses to the text actions, so that a non-NSResponder (ie, a  
window/app delegate) can perform the action?


thanks,
-natevw
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/greg%40omnigroup.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: Delete action from variety of key presses

2008-07-07 Thread Graham Cox
The view that is first responder needs to override -keyDown: and do  
this:


[self interpretKeyEvents:[NSArray arrayWithObject:event]];

which hooks the event into the standard dispatcher for these methods.

(One thing that has long puzzled me about this though - why is the  
parameter an array of events when only one event is ever available?)



hth,

Graham



On 8 Jul 2008, at 9:59 am, Nathan Vander Wilt wrote:

The Cocoa Text Bindings system already translates keys and key  
combinations into invocations of NSResponder methods. http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/chapter_9_section_1.html 



So, what you need to do is determine which methods those keys are  
already mapping to, override those methods in the appropriate place  
in your responder chain (e.g. on your custom view or application  
delegate), and have them all invoke some common method to do what  
you want.


Thanks, I forgot to mention that I tried overriding some of those  
action methods. However, I couldn't get them to fire.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Delete action from variety of key presses

2008-07-07 Thread Ken Thomases

On Jul 7, 2008, at 6:59 PM, Nathan Vander Wilt wrote:

Thanks, I forgot to mention that I tried overriding some of those  
action methods. However, I couldn't get them to fire.


If I implement:

- (BOOL)acceptsFirstResponder {
return YES;
}

- (void)keyDown:(NSEvent*)keyEvent {
(void)keyEvent;
printf(key event received\n);
}



You need to forward the event to -interpretKeyEvents:.

See http://developer.apple.com/documentation/Cocoa/Conceptual/ 
EventOverview/HandlingKeyEvents/chapter_6_section_3.html.


Sorry I didn't point that out before.  I actually didn't realize that  
was necessary and thought the default implementation of -keyDown: did  
that.


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: Delete action from variety of key presses

2008-07-07 Thread Nathan Vander Wilt
By overriding -keyDown: and not calling [super keyDown:keyEvent],  
you have stopped your view from actually processing the keys any  
further. That's why you aren't getting to either of the delete  
methods.


Hmm, the flowchart I mentioned (http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_3.html 
) gave me the impression that the Cocoa Text System would kick in  
before the view even had a chance at the event. I did try passing it  
to super (which in my case is NSView), but still didn't get the text  
binding actions to fire.


The more I think about it though, it wouldn't make sense for Cocoa  
Text Bindings to always get first refusal of a key event. I think the  
links Ken Thomases provided, while great references for that system,  
only are relevant in subclasses of Cocoa's *Text* subclasses, where  
Apple has provided a subclass of NSView that loads the key mappings  
and does the action dispatch itself.


Without the key view being one of Cocoa's text views, would I ever get  
these actions? Is there a similar built-in mechanism for application-  
or document-wide bindings unrelated to text editing? If not, then is  
the only way to turn a key event into an action by doing it myself in  
an NSResponder subclass put (or picked from) somewhere in the chain?


thanks,
-natevw
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: More CALayer Questions

2008-07-07 Thread Gordon Apple
Thanks.  That's a good suggestion.  I just realized that the thing was
trying to animate and was interfering with my attempts to manually draw.  I
saw removeAllAnimations and tried it to solved my immediate problem.  I'll
see if I can use what you mentioned instead.  I'm not currently using
CALayers for animation (yes, eventually), but just wanted a layering system
that will hopefully let me to stack drawing layers, annotation, etc. along
with live video layers and other things.


 Hi Gordon,
 
 I'm not sure what you really want to do is -removeAllAnimations.  I
 suspect that you probably want to temporarily disable animation within
 the scope of a CATransaction.  Take a look at the code found here:
 
 http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide
 /Articles/Transactions.html#//apple_ref/doc/uid/TP40006096-SW9
 
 
 later,
 
 douglas


The view is a main presentation view that is (optionally) in a scroll
view.  I started out using the clipView, a la the Sketch example.  Then at
someone else's suggestion I switched to scaling my main view instead.
Either way works great for a non-layer-backed view.  The popup in the scroll
bar ranges from 10% to 1600%.

Currently, I'm just changing the view's frame and then resetting the
bounds to the original size.  I also tried scaleUnitSquareToSize.  It
worked, but produced no different result with CALayers.  I will also need to
be able to change the bounds when the user changes the presentation
dimmensions, e.g., 640 x 480 to/from 1024 x 786.  All that worked until I
tried CALayers.

If I could figure out what changing the scroller size does, maybe I
could make it do the same thing to adjust properly when the user changes the
scale.


 What exactly are you doing to scale your views? layers?
 
 When scaling layers within a non-scrolling view, I have used the
 following method:
 
 [targetLayer setValue: [NSNumber numverWithFloat: newScaleValue]
 forKeyPath: @scale];
 
 Usually, I place a statement like this in an action method that is
 targetted by a slider and it produces no-brainer results
 
 When I needed to scale a layer hosted by a view that was enclosed in a
 NSScrollview, i used the following method:
 
 clipView = [targetScrollView contentView];
 `newBoundsSize = NSMakeSize( NSWidth( [clipView frame] ) /
 newScaleValue, NSHeight( [clipView frame]) / newScaleValue);
 [clipView setBoundsSize: newBoundsSize];
 
 This works for the most part.  The scaling is sluggish and sometimes
 the view doesn't redraw properly until a scroller is movedc.
 
 Have you tried both of these methods?  Other methods?

___

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

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

2008-07-07 Thread Scott Ribe
 the connection object as well as the receivedData object are released
 in the connectionDidFinishLoading delegate

The sample also retains receivedData after creating the connection. Did you
do that? And did you create the connection using alloc initxxx?


-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

2008-07-07 Thread Kyle Sluder
On Mon, Jul 7, 2008 at 8:34 AM, em [EMAIL PROTECTED] wrote:
 I would like to be able to  reassign the primary system keyboard input so as 
 to direct it to an incoming  network stream.   It's a general query at 
 present and any suggestions would be appreciated.  I'm leaning toward writing 
 a Cocoa/Objective C/PPC Masm app--locating and modifying the remote apple 
 events api (if there is one), but i'm not sure whether this can be done by 
 simply re-directing a unix pipe, or tweaking Darwin.

...huh?  You're looking at writing an application in Objective-C using
the Cocoa framework in PowerPC assembler?  This doesn't make sense.
Alternatively, you want to know if you can achieve your goal of
sending Remote Apple Events by re-directing a unix pipe (which also
doesn't make sense) or tweaking the open-source operating system that
is based on the same kernel as OS X?

What exactly are you trying to accomplish?  Something similar to
netcat, or VNC, or a proprietary remote control interface, or...?

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to support dictionary service in a custom text view?

2008-07-07 Thread Evan Gross
On 03/07/08 3:26 PM, Charles Srstka [EMAIL PROTECTED] wrote:

 On Jul 3, 2008, at 12:03 PM, Charles Srstka wrote:
 
 Okay, so I've got a custom text view that's a subclass of NSView
 (not NSTextView). I've followed the instructions on this page:
 
 http://developer.apple.com/documentation/Cocoa/Conceptual/InputManager/Tasks/
 TextViewTask.html#/
 /apple_ref/doc/uid/20001040
 
 I override acceptsFirstResponder to return YES, I override keyDown:
 to call interpretKeyEvents:, and I've implemented the NSTextInput
 protocol. I override all the mouse events and send those to the
 current input manager if it wants them (it never does). I even told
 the NSWindow to accept mouseMoved: events so I could forward them if
 the input manager wanted them (it doesn't). I've also implemented
 Services support, accepting NSStringPboardType data and providing it
 to services.
 
 Anyway, this all works great for the most part. Text editing works
 fine, services work fine, everyone's happy, except for one thing - I
 want that dictionary widget that NSTextView has when you type
 command-control-D with the mouse hovering over a word. Since this is
 a system service and seems to get loaded into every Cocoa app, there
 must be a simple way to get my view to support it, but I'm drawing a
 blank as to what it is. I'm sure it's something simple, I'm just not
 sure what's the remaining piece of the puzzle that I need to
 implement. Anyone know what I'm forgetting?
 
 Never mind! I found the answer to my own question - I needed to
 implement the NSAccessibility protocol. I've done that, and now it
 works.
 
 Charles
 
 

While supporting AX is always a good thing to do, the Dictionary service
doesn't require access to be enabled. Have you tested at all with
accessibility off?

My product (well, the new version I'm working on) makes heavy use of the
same TSM and AX APIs that the Dictionary service uses (and a few other). I'd
be very interested to see a custom NSView that's not derived from NSTextView
that supports these APIs (to know that someone has done it!).

Feel free to contact me off-list if this interests you as well...

Thanks,
Evan Gross  
-- 
Evan Gross, President, Rainmaker Research Inc.
Developers of Macintosh and Windows Software
Spell Catcher for Mac OS and Windows
http://www.rainmakerinc.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: Rerouting keyboard input

2008-07-07 Thread Matt Burnett
Take a look at the darwin-dev lists. You could reroute the keyboard  
events in kernel space to go to your daemon instead of its typical  
path to user land. Then have your daemon send the events over the  
network to a daemon on a 2nd computer, then have the 2nd daemon  
reinject them to your target system. Take a look at the IOHIKeyboard  
class, it is easily hookable. It isnt too different to do the same  
with mouse events as well.


On Jul 7, 2008, at 7:34 AM, em wrote:

I would like to be able to  reassign the primary system keyboard  
input so as to direct it to an incoming  network stream.   It's a  
general query at present and any suggestions would be appreciated.   
I'm leaning toward writing a Cocoa/Objective C/PPC Masm app-- 
locating and modifying the remote apple events api (if there is  
one), but i'm not sure whether this can be done by simply re- 
directing a unix pipe, or tweaking Darwin.

thanks,
em


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/matt.w.burnett%40gmail.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: More CALayer Questions

2008-07-07 Thread Gordon Apple
Yup, Amazon, July 15, $23.07 + shipping.  BTW, you might want them to
update the title because it doesn't mention iPhone.  Considering the huge
number of iPhone SDKs downloaded, that could be a big draw.  I may cancel
Amazon and order the PDF package from your site.

I had considered adding my own base-layer as you suggested, but that
still begs the question since that layer will live in the view's layer as a
sublayer amd I still don't know how the view's layer responds to changes in
the view's frame/bounds. If the view's layer lives within the view's bounds,
then I should only have to deal with the flipped coordinates.  I was hoping
I could flip and scale using a transform so it would carry through to the
sublayer stack I wanted to include for my actual drawing layers.  That way,
I wouldn't have to mess with the sublayer stack -- they should automatically
scale when the base-layer is scaled.

 You may be right that I shouldn't muck with the view's layer, but
should add my own base-layer, especially since it seems to be a mystery how
the view's layer responds to changes in the view.

Gordon

 Hi Gordon,
 
 'the upcomming book on animation'?
 
 If by that you mean the Core Animation book from Pragmatic Programmers
 you can get the PDF now from
 
 http://www.pragprog.com/titles/bdcora
 
 and then the paper when it ships. You get a really good discount on it
 if you buy both.
 
 Not sure where the July 17 date comes from (amazon.com?) but its
 likely off by at least 2 weeks and probably a bit more like 4.
 
 Now on to the real question... Basically what you are doing is
 confusing the tar out of the layer living in your view by messing with
 any of its properties.
 
 If you do something like this;
 
 myView.wantsLayer = YES;
 
 And then do something like this;
 
 myView.layer.position = myPoint;
 
 you are asking for trouble.
 
 You should instead do something like this;
 
 myView.layer = [CALayer layer];
 myView.wantsLayer = YES:
 layerToMove = [CALayer layer];
 [myView.layer addSublayer:layerToMove]
 
 then you can
 
 layerToMove.position = somePoint;
 
 To your hearts desire and everything should be lovely :)
 
 Then if you want to do 'struts and springs' type stuff with
 layerToMove you can use a layoutManager to do all sorts of cool and
 exciting stuff.
 
 Good luck!

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to support dictionary service in a custom text view?

2008-07-07 Thread Charles Srstka

On Jul 7, 2008, at 9:48 PM, Evan Gross wrote:

While supporting AX is always a good thing to do, the Dictionary  
service

doesn't require access to be enabled. Have you tested at all with
accessibility off?


I'm not sure what you're referring to with regards to accessibility  
off. If you are referring to the Allow access for assistive devices  
check box in the Universal Access preference pane, that isn't what I  
was talking about at all. What I did was implement the methods in the  
NSAccessibility informal protocol such as accessibilityAttributeNames,  
accessibilityAttributeValue:,  
accessibilityAttributeValue:forParameter:, and the rest. Implementing  
these after having implemented NSTextInput caused the Dictionary  
service to start working with my custom view.


I know that the Dictionary service *does* apparently make use of the  
accessibility APIs, as if I set a breakpoint in the accessibility  
methods, they get called quite a bit when one invokes the Dictionary  
service via command-control-D with the mouse cursor over my view.


My product (well, the new version I'm working on) makes heavy use of  
the
same TSM and AX APIs that the Dictionary service uses (and a few  
other). I'd
be very interested to see a custom NSView that's not derived from  
NSTextView

that supports these APIs (to know that someone has done it!).


It's not complicated - all you have to do is implement the  
NSAccessibility APIs (you might have to implement NSTextInput as well  
- I did before I implemented NSAccessibility, so I don't know whether  
it would have worked without NSTextInput or not. Regardless,  
NSTextInput is something you always want to implement anyway if you're  
making a text view). When you do this, it suddenly Just Works™, just  
like NSTextView.


Charles___

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

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

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

This email sent to [EMAIL PROTECTED]


controlling system muting ?

2008-07-07 Thread Jason Bobier

Hey folks,

Has anyone figured out how to control a machine's volume level  
(specifically muting) from code? I know that you can do it from  
Applescript, but running an applescript from code seems to be a rather  
clunky approach.


This is for emergency notification, so I have to be able to crank the  
volume on the system and then restore it afterwards.


Thanks for any insight!

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]


Re: How to support dictionary service in a custom text view?

2008-07-07 Thread Evan Gross
On 07/07/08 11:14 PM, Charles Srstka [EMAIL PROTECTED] wrote:

 I'm not sure what you're referring to with regards to accessibility  off. If
 you are referring to the Allow access for assistive devices  check box in
 the Universal Access preference pane, that isn't what I  was talking about at
 all.

That is what I was talking about. The Dictionary service will work if Allow
access for assistive devices is deselected (off).

 What I did was implement the methods in the  NSAccessibility informal
 protocol such as accessibilityAttributeNames,  accessibilityAttributeValue:,
 accessibilityAttributeValue:forParameter:, and the rest. Implementing  these
 after having implemented NSTextInput caused the Dictionary  service to start
 working with my custom view.

Sure, but when Allow access for assistive devices is deselected, those
methods will (should!) not be called.

 
 I know that the Dictionary service *does* apparently make use of the
 accessibility APIs, as if I set a breakpoint in the accessibility  methods,
 they get called quite a bit when one invokes the Dictionary  service via
 command-control-D with the mouse cursor over my view.

Sure, it uses (possibly requires) NSTextInput (TSM  document access events)
support, and (optionally) accessibility to do it's thing. If accessibility
isn't available (Allow access for assistive devices deselected, or the
app/editing view doesn't support access to text via accessibility), the
Dictionary service will work using only NSTextInput.

See what happens if you deselect Allow access for assistive devices - as
long as your NSTextInput implementation is complete (enough for the
Dictionary service, anyway), it should still work.

Evan


___

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

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

2008-07-07 Thread Phil
On Tue, Jul 8, 2008 at 3:25 PM, Jason Bobier [EMAIL PROTECTED] wrote:
 Has anyone figured out how to control a machine's volume level (specifically
 muting) from code? I know that you can do it from Applescript, but running
 an applescript from code seems to be a rather clunky approach.

 This is for emergency notification, so I have to be able to crank the volume
 on the system and then restore it afterwards.


Take a read of QA1016:
http://developer.apple.com/qa/qa2006/qa1016.html

Also, TN2102, if you haven't already:
http://developer.apple.com/technotes/tn2002/tn2102.html

However, I would urge you not to mess around with the user's volume
control, even you think it is an emergency---the user may feel very
differently. Your application should play an alert sound, and trust
that the user's system output volume and alert volume are correct for
what they want to hear (although, I have no idea what your application
does; but in the general case, messing around with user settings when
they don't expect it isn't good).

-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: Why aren't my bindings firing?

2008-07-07 Thread Ron Lue-Sang

*sigh*

I haven't looked at these docs recently. With that in mind, here's how  
I think of things…


YES: Cocoa Bindings ®™ is built on KVC, KVO and KVB

KVB is an informal protocol. So Cocoa Bindings™® provides a concrete  
implementation (on NSObject) of the KVB protocols.


In addition to providing a KVB implementation, Cocoa Bindings®™ adds a  
set of reusable controllers to Cocoa.


None of this really matters if you ask me. Did you ask me?

The NSKeyValueBindingCreation protocol itself doesn't explicitly  
specify whether bindings are unidirectional or bidirectional.  Many of  
the bindings implemented by Cocoa Bindings®™ are implemented for  
specific Cocoa views (and the Cocoa Bindings®™ provided controllers).  
Many of these bindings happen to be bi-directional. Yay.


Cocoa Binding™® also happens to provide a super generic implementation  
of NSKeyValueBindingCreation protocols so that even if you bind  
something that isn't exposed as a binding (like, you wouldn't see it  
in the object's exposedBindings list), something useful still happens.


Are there two different kinds of bindings? Without getting too  
philosophical, I don't think there are. Hamish, what are the two types  
you're thinking of?




On Jul 7, 2008, at 3:51 PM, Hamish Allan wrote:

On Thu, Jul 3, 2008 at 1:12 AM, mmalc crawford [EMAIL PROTECTED]  
wrote:


On Jul 2, 2008, at 4:04 PM, Hamish Allan wrote:


This is a rather unuseful attitude to take. Clearly, this thread
started as a result of the distinction. Also, Apple's own
documentation disagrees with you, as it states that Cocoa bindings  
are

built on KVB.


No, it doesn't.


No, really, it does! Read Ken's post again: he links to docs that talk
of Cocoa bindings relying on KVB, and KVB being one of the main
technologies underpinning Cocoa bindings. You yourself make pretty
much the same distinction:


Cocoa bindings is an abstract term that refers to a collection of
technologies that used together keep views, controllers, and models
synchronised.
Key-value binding is one of those technologies.



There are not two different kinds of binding.


If that is the case, let me ask: is KVB unidirectional or bi- 
directional?


Hamish
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/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: Style Question (Robert Claeson)

2008-07-07 Thread Scott Ribe
 Should be possible, no?

Emacs ;-)

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]