Re: How to catch [NSEvent dealloc]?

2010-07-08 Thread Paul Sanders
 In that case I'd guess you might want to use method swizzling on
 -[NSEvent dealloc]:
 
 http://www.cocoadev.com/index.pl?MethodSwizzling
 
 Beware that swizzling is a powerful and dangerous technique, and you
 want to code your override with the utmost caution, but it's a great
 way to intercept methods like this.

 Mike

 Since the event is application-defined, any handler will, of course, also be 
 application-defined.
 Can't you handle this in the handler?  Or, alternatively, in an override of 
 -[NSApplication sendEvent:]?

 Regards,
 Ken

That's what I'm currently doing - releasing the referenced object in an 
override of sendEvent.  The problem is that events don't always go through 
there (in a modal tracking loop, specifically) so I need handle that case too.  
Why?  Well, it's too complicated to go into here but I actually play all kinds 
of games with event handling in order to emulate the Windows API, which has a 
rather different view of the world.  It's not my most favourite piece of code.  
Strangely, if you post a mouse or keyboard event to the input queue, the event 
that is eventually delivered is a copy of the original, rather than the event 
you actually posted.  Why this should be I don't know but it makes life much 
harder for me.

So I shall ponder my options.  What I have works, but I have had one crash 
report from the field (just one) where my referenced object pointer was 
obviously stale so there must be a little loophole in there somewhere.  Thanks 
for the input guys, much appreciated.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


How to catch [NSEvent dealloc]?

2010-07-07 Thread Paul Sanders
I have a problem.  I need to know when an NSApplicationDefined NSEvent is 
deallocated, because it contains a reference to an object in data1 and I want 
to release that object at that time.  Problem is, you can't subclass NSEvent 
because there are no public initialisers.  Short of swizzling [NSEvent dealloc] 
(erk!) does anyone have an idea about how I might be able to catch an NSEvent 
object at the point of deallocation?

Many thanks,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to catch [NSEvent dealloc]?

2010-07-07 Thread Paul Sanders
 If you can require 10.6 (or iOS 4, maybe?) then you can use the new
 associated object API. Use objc_setAssociatedObject to attach your
 object to the NSEvent object, and the runtime will automatically take
 care of destroying it for you when the NSEvent is destroyed.

Sadly (and possibly mistakenly), I'm still supporting 10.4.  I think I need to 
review this policy!  Good idea though.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Bypass Network System Preferences for DNS lookup

2010-07-02 Thread Paul Sanders
On Jul 1, 2010, at 9:42 PM, Michael Jackson wrote:

 Is there any way to bypass the system network preferences for DNS
 servers to perform all DNS lookups from within a Cocoa app? For
 example, I would like my app to always make DNS queries to a
 particular pair of DNS servers.

As a starting point (following on from Jens' suggestion): 
http://sourceforge.net/projects/adns/.  Nice, simple source code which you can 
hack around, liberal license.  No doubt there are other options out there.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Toolbar Icon Workflow

2010-06-27 Thread Paul Sanders
 if you use a PDF, it has the resolution independence, but will look fuzzy at 
 non-native resolutions


But if a PDF contains only vector graphics elements it has no native resolution 
so it should scale to any size reasonably well.  Just don't put any bitmaps in 
there.

Here's a simple example:

http://img819.imageshack.us/img819/8696/screenshot20100627at094.png

This was created as a vector graphic and scaled at display time.  As you can 
see, it looks pretty good.   Perhaps not as sharp as a pixel-perfect bitmap but 
good enough for me.  The image is just the green bit (space was at a premium!). 
 And in fact it's not as good as it could be because it goes via an 
intermediate bitmap for cross-platform reasons.  Using the PDF direct might 
look a bit better still.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Toolbar Icon Workflow

2010-06-26 Thread Paul Sanders
I create my icons as vector graphics without worrying *at all* about pixel 
boundaries and then scale them to fit at display time.  Life improved markedly 
when I went this route.  Although they might not be as sharp as 'pixel-perfect' 
bitmapped images it means I don't have to worry too much about the exact size 
at which they will be displayed.  That said, my talents are limited and my 
icons are pretty boring.  The alternative is to create 'pixel-perfect' bitmaps 
in a bitmap editor at the size they will be displayed, but it's hard work and I 
would only do it for a small image where display quality is paramount.

I would store your vector-graphics icons as PDF.  You only need a .icns file 
for your application icon.  Make your images with the correct aspect ratio and 
if you need the same image with two different aspect ratios, make two separate 
PDF's.

Just my $0.02.

Regards,

Paul Sanders.

- Original Message - 
From: Richard Somers 
To: cocoa-dev@lists.apple.com 
Sent: Saturday, June 26, 2010 8:19 PM
Subject: Toolbar Icon Workflow


My current ad hoc work flow for toolbar icons which are geometric in  
nature.

• Use Inkscape.

• Use a small canvas size of 28 points wide x 22 points high.

• Try to make sure the ink is generally constrained with the  
individual point boundaries.

• Save the Inkscape file as a pdf.

• Open the pdf in MakeThumbnail and create an icns file.

• Use the icns file for the toolbar image.

Short of getting a degree in graphic design or spending money on  
software or hiring a graphic artist, what can I do that will make  
better looking toolbar icons?

The pdf art work looks good. The toolbar icons don't look so good, the  
edges are a little fuzzy. The toolbar icons at regular size are  
slightly larger than the original pdf.

With an NSButton the pdf file works great and looks great when scaling  
set to none. When the pdf file is used as the image for the toolbar  
item, it gets asymmetrically stretched and looks horrible. Thus the  
reason for converting the pdf to an icns file.

The MakeThumbnail application actually makes 9 images from very  
large to small. The large ones are obviously an overkill for the  
toolbar.

The Apple Human Interface Guidelines has this to say Although toolbar  
icons should conserve screen real estate (32 x 32 pixels is the  
recommended size), they should be inviting and easy to identify. This  
is nice to know but doesn't provide much help.

--Richard
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Best way to determine if a directory is a package

2010-06-25 Thread Paul Sanders
 Hidden item names begin with a .

There is also a UF_HIDDEN flag in stat.st_flags.  Google man stat os x for 
details (you want stat(2)).  The Finder respects this flag on my 10.6.3 system. 
 Whether it corresponds to kLSItemInfoIsVisible in 
LSItemInfoRecord.LSItemInfoFlags (as recommended by Jean-Daniel) I don't know.  
As usual in Mac-land, there are 6 ways of doing everything.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
I use #1 and it works fine for me.  Note that SCDynamicStoreCopyComputerName 
might return NULL, and don't forget to CFRelease temp.

In the case of #1, what is the NSLog statement that is failing?  And I take it 
that name hasn't been autoreleased before you log it - it will only survive 
until the current autorelease pool 'pops'.  You can look at name (and probably 
temp, but I'm not sure) in the debugger, of course.

Regards,

Paul Sanders.

- Original Message - 
From: Steve Steinitz 
To: cocoa-dev@lists.apple.com 
Sent: Sunday, June 20, 2010 11:10 AM
Subject: Getting Computer Name


Hello,

I've found several examples of getting the computer Name but 
some give warnings about making a pointer from an integer and 
they all fail with signal EXC_BAD_ACCESS here

 objc_msgSend_vtable5
 _NSDescriptionWithLocaleFunc
 _CFStringAppendFormatAndArgumentsAux
 _CFStringCreateWithFormatAndArgumentsAux
 _CFLogvEx
 NSLogv
 NSLog

Here are three examples I've tried:

1.  CFStringRef temp = SCDynamicStoreCopyComputerName (NULL, NULL);
 NSString * name = [NSString stringWithString: temp];
 return name;

2.  CFStringEncoding encoding = kCFStringEncodingUTF8;
 CFStringRef name = SCDynamicStoreCopyComputerName (NULL, encoding);
 return name;

3.  #import SystemConfiguration/SCDynamicStore.h

 SCDynamicStoreContext context = {0, NULL, NULL, NULL};
 SCDynamicStoreRef store = SCDynamicStoreCreate (kCFAllocatorDefault,
 CFSTR(testStrings),
 NULL,
 context);
 NSLog(@SCDynamicStoreCopyLocalHostName() = %@,
 SCDynamicStoreCopyLocalHostName(store));

According to the docs CFStringRef is toll-free-bridged with 
NSString and so interchangeable.  The authors of the examples 
cite no issues.  Could I have done something to my project to 
break toll-free bridging?  I confess, I haven't thought about 
toll-free bridging since the WebObjects days.

Thanks for any ideas,

Steve
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
It looks like SCDynamicStoreCopyComputerName is not prototyped correctly so the 
compiler assumes it returns an int.  In what I assume is a 64-bit build this 
will lose the top 32 bits of the CFStringRef.

Are you #including CoreServices/CoreServices.h?  Other than that I am 
compiling 32 bit so I don't know what else might be wrong with the setup of 
your project but at least now you have an idea of what to look for.

Regards,

--
Paul Sanders
AlpineSoft
http://www.alpinesoft.co.uk

- Original Message - 
From: Steve Steinitz 
To: Paul Sanders ; cocoa-dev@lists.apple.com 
Sent: Sunday, June 20, 2010 11:52 AM
Subject: Re: Getting Computer Name


Here is my method:

+ (NSString *)
computerName
{
 CFStringRef   temp = SCDynamicStoreCopyComputerName (NULL, NULL);
 NSString* name = [NSString stringWithString: temp];
 NSLog (@computer name = %@, name);
 CFRelease (temp);
 return name;
}

The line creating temp warns: initialization makes pointer from integer.

The line creating name warns: passing argument 1 of 
StringwithString from incompatible pointer type
and fails with signal EXC_BAD_ACCESS

Thanks again,

Steve
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
 Are you #including CoreServices/CoreServices.h?

 I wasn't.  I added it.  Were you wondering if it would make a difference?

Well, yes.  Default return type is int.  In fact I'm suprised you didn't get a 
warning about the function being undefined.  My Mac is powered off or I would 
check.  Does adding the #include sort things out?

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
 The correct import is #import 
 SystemConfiguration/SCDynamicStoreCopySpecific.h.

So it is, sorry.  It was half-way down my source file.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSAttributedString with columns

2010-06-14 Thread Paul Sanders
 I would like to use an NSAttributed string in order to render a type of 
 key/value 2 column display
 in a NSTextField. As of now, i'm using tabs between key's and value's on each 
 line but some values
 need to wrap to the next line and i would like them to wrap to the start of 
 value column and not
 wrap all the way to the beginning og the new line. Is this possible using 
 attributes and an
 NSAttaributedString. Heres an example:

I believe you are looking for - [NSMutableParagraphStyle setHeadIndent:]

Regards,

Paul Sanders
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-09 Thread Paul Sanders
 Except that would still rely on inserting a custom view in the
 WebView's private scrollview hierarchy.

If the clipping path method works, and if you can subclass your webview, then 
you shouldn't need a separate view at all.  Just override drawRect: and draw 
your rectangles after calling super.  It sounds almost too easy.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Scrolling Behavior of NSTextView

2010-06-08 Thread Paul Sanders
 Martin, I tried the  [NSTextView scrollRangeToVisible:] with 
 NSMakeRange(0,0) , but it is the same as to use [scrollPoint:] solely. Only 
 with
 [glyphRangeForTextContainer:] in prior the scroll-to-top works. I don't think 
 it is the problem of coordinate system flip-ness, because when using
 [scrollPoint:] without [glyphRangeForTextContainer:], the text view does not 
 always scroll to bottom, either, it just does not always scroll to top under
 certain window size and text length. And it seems not solely 
 [glyphRangeForTextContainer:] triggers the scroll-to-top because without 
 [scrollPoint:] the
 scrolling does not work, either.

I thank Martin is right though - the fact that the coordinate system is flipped 
means that it is not necessary to know the dimensions of the text in order to 
position point (0, 0) in the top-lefthand corner.  And just calling 
glyphRangeForTextContainer: on its own will not cause any scrolling.

 Another minor wired problem is the trick of using both 
 [glyphRangeForTextContainer:] and [scrollPoint:] works only when you 
 drag-drop a NSScrollView
 in IB and then set the embedded custom view as NSTextView. If an NSTextView 
 is dragged and dropped directly (and IB automatically embed it in a
 NSScrollView), the scroll-to-top does not work even with the trick (and I 
 haven't found a trick to make it work under such situation).

That would seem to point to some difference in the way the NSTextView is 
initialised by IB, although I'm not sure what.  Using a custom view is clearly 
undesirable as you cannot set the properties of the text view in IB that way.

You could try calling displayIfNeeded on the enclosing scroll view before 
calling scrollPoint:.  This ought to perform any necessary layout and maybe one 
or two other things.  It shouldn't cause any screen flash because the window 
will not be flushed until you return to the run loop.  You can get hold of the 
enclosing scroll view via [[myTextView superview] superview].

I also thought that Martin's idea of putting a breakpoint on [NSTextView 
scrollPoint:] might turn up something interesting.  You could also put a 
breakpoint on [NSTextView setBounds:] as that is what scrollPoint: will 
ultimately call, see:

http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/NSScrollViewGuide/Articles/Basics.html#//apple_ref/doc/uid/TP40003461-SW1

Regards,

Paul Sanders
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-08 Thread Paul Sanders
 Unfortunately this causes the background to turn black and not transparent. I 
 would need the view to become transparent
 (so the WebView underneath is visible). 

Try this:

[[NSColor clearColor] setFill];
NSRectFill (myRect);

That's what I do.

Regards,

Paul Sanders
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-08 Thread Paul Sanders
On Jun 8, 2010, at 10:03 AM, Kyle Sluder kyle.slu...@gmail.com wrote:

 You can't do this. All your views are composited back-to-front into  
 the window's backing store, so filling with anything will obliterate  
 your web view's drawing.

Of course, silly me.  Can something be done with a layer-backed view here, used 
as some kind of overlay?  Alternatively, one could position a borderless window 
over the WebView and draw your rectangles into that.  This window can be made 
initially transparent by:
  - calling setOpaque: NO on the window
  - having the content view return isOpaque as YES
  - filling the content view with clearColor

Then draw your rectangles in the content view of this window and the NSRectFill 
trick should work.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-08 Thread Paul Sanders
 The window overlay sounds like it could work. Hoverer, a NSView overlay would 
 be preferred since I'm inserting
 the overlay in the WebView's scroll view (and matching the documents view 
 size via bounds change
 notifications). This works very well when scrolling both the web and overlay 
 view at the same time (and is also
 efficient). 

A layer-backed (or layer-hosted) view matching the bounds of a large web page 
would use a lot of memory (bounds.width * bounds.height * 4 bytes, probably).  
I would handle scrolling in the overlay window yourself by offsetting the 
content view's bounds in the way that a scrollview does for its document view.  
Flipping the view's coordinates might help with the maths.  It looks like 
listening for NSViewBoundsDidChangeNotification will let you track the scroll 
position of the webview and you need only draw those rectanges which are 
visible, of course.

Kyle, I rather liked your stack of 'bees'.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-08 Thread Paul Sanders
 The window overlay sounds like it could work. Hoverer, a NSView overlay would 
 be preferred since I'm inserting
 the overlay in the WebView's scroll view (and matching the documents view 
 size via bounds change
 notifications). This works very well when scrolling both the web and overlay 
 view at the same time (and is also
 efficient). 


Also, you can probably make your overlay window a child window of the window 
containing the webview.  Then:
  - it will stay on top of it
  - it will move with it

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: setting tab stops in a document

2010-06-07 Thread Paul Sanders
 /** ADDED CODE **/
 NSMutableDictionary* typingAttributes = [[myTextView typingAttributes] 
 mutableCopy];
 [typingAttributes setObject:paraStyle forKey:NSParagraphStyleAttributeName];
 [myTextView setTypingAttributes:typingAttributes];
 NSRange rangeOfChange = NSMakeRange(0, [[myTextView string] length]);
 [myTextView shouldChangeTextInRange:rangeOfChange replacementString:nil];
 [[myTextView textStorage] setAttributes:typingAttributes range:rangeOfChange];
 [myTextView didChangeText]; 
 [typingAttributes release];
 // end added code 


It's probably harmless but I don't think it's appropriate to call 
shouldChangeTextInRange: here as this is not a 'user-initiated editing change', 
see



http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSTextView_Class/Reference/Reference.html#//apple_ref/doc/uid/2373-BBBE



You should call didChangeText though, so that the appropriate notifications are 
sent.  didChangeText doesn't get called for you when you modify the 
NSTextStorage object programmatically.



Just in case you missed it, you might also like to know about the beginEditing 
and endEditing methods of NSMutableAttributedString (from which NSTextStorage 
derives).  These can be used to 'bracket' multiple changes to the text and so 
doing improves efficiency.  This is covered here:



http://developer.apple.com/mac/library/documentation/cocoa/conceptual/TextEditing/Tasks/BatchEditing.html



Again, for what you are doing here this is not really relevant; the code you 
posted should work just fine.  But if you are making a number of changes at the 
same time it is worth calling these methods.



Regards,



Paul Sanders.


___

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

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

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

This email sent to arch...@mail-archive.com


Re: Scrolling Behavior of NSTextView

2010-06-07 Thread Paul Sanders
 I encountered a wired behavior of NSTextView. I tried to use the following 
 statement to scroll to top:
 [[_scrollView documentView] scrollPoint:NSMakePoint(0, 0)];

 where the *documentView* is a NSTextView. But it seems when the window is in
 certain size, the scroll-to-top behavior does not take effect. Then I added
 a seemingly irrelevant statement before the above statement, by accidental,
 so the fragment become the follows:

 [[[_scrollView documentView] layoutManager] glyphRangeForTextContainer:[[self 
 dictionaryContent] textContainer]];
 [[_scrollView documentView] scrollPoint:NSMakePoint(0, 0)];

 The complete source code is at http://techsingular.net/dict_mac/dict_mac.dmg

 The problem happens when you search for 灵 or 神 through this dictionary 
 program.

I haven't looked at your code so I don't know what is going on in detail but 
[NSLayoutManager glyphRangeForTextContainer:] performs layout, if it hasn't 
been done already, which is probably why it is affecting the results you get.  
Until layout has been performed, the Cocoa text system doesn't know the size of 
the text (in terms of the amount of space it will take up on the display) and 
so (I surmise) scrollPoint: doesn't work as expected.

In other words, the code you have now is correct.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Debugging sporadic crashes

2010-06-07 Thread Paul Sanders
On 7 Jun 2010, at 15:39, Gabriel Zachmann wrote:

 
 All kinds of suggestions, insights, and tips will be highly appreciated.
 

A quick and easy way to find out where an app is hung is to sample it in 
Activity Monitor.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: setting tab stops in a document

2010-06-05 Thread Paul Sanders
 When my application opens a text file, the insertion point is blinking 
 immediately after the last character on the last line.  If I then hit the tab 
 key, the insertion point moves over the correct distance.  However, if I hit 
 the return key when the file is first opened, the insertion point moves to 
 the start of the next line; if I then hit the tab key the insertion point 
 moves it over too few spaces (presumably the default distance rather than 
 what I tried to set in the above code).  

 What am I missing?

[NSTextView setTypingAttributes:] is what you are looking for.  Setting them is 
an all-or-nothing affair so, typically, you get them, change what you want to 
change in a mutable copy of the NSDictionary returned and and then set them.

Regards,

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-24 Thread Paul Sanders
 The docs don't really *have to* say, though, because it's the only choice 
 that makes any sense.

Of course they do.  Ambiguity like this just leads to confusion.  And I know 
it's off topic, but I can't let your assertion that Windows actually bases 
everything off local time pass without comment.  The Win32 'native' file API's 
(and the internals of Windows) are all UTC based.  It's the implementation of 
stat in the Visual C runtime library that explicitly converts file times 
retrieved from the OS to local time.  You can see this in the runtime library 
source code.  It's easy once you know where to look. You can even step through 
it in the debugger.

It's true that Windows runs the CMOS clock in local time, but that is a detail. 
 It has nothing to do with the behaviour of stat, however flawed that might be.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-24 Thread Paul Sanders
 Let's take it off list then, rather than posting off-topic 
 stuff to cocoa-dev?

What for?  As far as I'm concerned, we are done.  I just don't 
like ill-informed 'Windows bashing', any more than you would 
like it if I took a pop at something I didn't understand on the 
Mac.  I am not a Windows fan boy.  I just have a foot in both 
camps.

Paul Sanders.



___

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

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

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

This email sent to arch...@mail-archive.com


Re: [Moderator] Re: getting file creation date from NTFS

2010-05-24 Thread Paul Sanders
What I meant was, let's not prolong the discussion, period.  The 
snippet quoted below is incomplete.

Nevermind.

Paul Sanders.

- Original Message - 
From: Scott Anguish sc...@cocoadoc.com
To: Paul Sanders p.sand...@alpinesoft.co.uk
Cc: Alastair Houghton alast...@alastairs-place.net; 
cocoa-dev@lists.apple.com
Sent: Monday, May 24, 2010 5:49 PM
Subject: [Moderator] Re: getting file creation date from NTFS

On May 24, 2010, at 5:52 AM, Paul Sanders wrote:

 Let's take it off list then, rather than posting off-topic
 stuff to cocoa-dev?

 What for?

The list is for the discussion of cocoa development issues of a 
technical issue. At this point, it isn’t.

Alastair is correct in asking that this be taken off-line.

Scott
[Moderator] 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-23 Thread Paul Sanders
Assuming that these figures come from stat (man -S 2 stat for details), it 
should be in something called st_birthtime.  st_atime refers to the last time 
the file was accessed. So, either call stat yourself or, better perhaps, go via 
the file manager:

http://developer.apple.com/mac/library/DOCUMENTATION/Carbon/Reference/File_Manager/Reference/reference.html

I would also fire up Windows to see what values it reports for the file(s) in 
question.  Note that viewing the properties for a file in Windows Explorer 
updates the last access time (!).  Like HFS, file dates on NTFS volumes are 
stored in UTC.  These are converted to local time by the Finder / Windows 
Explorer before display but I observe some differences depending on the date 
being reported (i.e. whether or not DST was in effect on that date).

Looking at a few of my own files (on Windows), the creation date doesn't seem 
to be very reliable.  I have several files where it post-dates the last 
modification date.

Paul Sanders.

- Original Message - 
From: Angelo Chen 
To: Ken Thomases ; Paul Sanders 
Cc: cocoa-dev@lists.apple.com 
Sent: Sunday, May 23, 2010 3:05 AM
Subject: Re: getting file creation date from NTFS


  As suggested by Ken, I tried FSMegaInfo on NOTEPAD.EXE in a bootcamp 
volume:
  if I compared it with Finder's display, Finder listed March 30, 2010 
6:48PM as 'Created'
  looks like, st_atime is the creation date?


  'NOTEPAD.EXE'
  st_dev = 0x0e03 (major=14, minor=3, disk0s3)
  st_ino = 2469
  st_mode= 0x81ed (-rwxr-xr-x)
  st_nlink   = 1
  st_uid = 501 (user1)
  st_gid = 20 (staff)
  st_rdev= 0x (major=0, minor=0, console)
  st_atime   = 1269957274.686875000 (Tue Mar 30 13:54:34 2010)
  st_mtime   = 1091595416.0 (Wed Aug  4 04:56:56 2004)
  st_ctime   = 1274540319.708286000 (Sat May 22 14:58:39 2010)
  st_size= 69120 (67 KB)
  st_blocks  = 136
  st_blksize = 33554432
  st_flags   = 0x
  st_gen = 0



  --- 2010年5月23日 星期日,Paul Sanders p.sand...@alpinesoft.co.uk 寫道﹕


寄件人: Paul Sanders p.sand...@alpinesoft.co.uk
主題: Re: getting file creation date from NTFS
收件人: Ken Thomases k...@codeweavers.com, Angelo Chen 
angelochen...@yahoo.com.hk
副本(CC): cocoa-dev@lists.apple.com
日期: 2010年5月23日,星期日,上午1:14


 Also be aware that not all file systems support the notion of 
 creation dates of their objects.  I don't know off-hand if 
 NTFS does.

It does.

Paul Sanders. 



 


___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-23 Thread Paul Sanders
 Yes, although the stat structure only has the st_birthtimespec field if you 
 build with 64-bit inodes enabled.  This is the default on Snow Leopard or
 for 64-bit, but not for 32-bit on Leopard or earlier.

I'm not certain, but I think you have to use stat64 in 32 bit Leopard builds to 
get st_birthtimespec.  stat64 is deprecated in Snow Leopard, but seems unlikely 
to go away.  I guess a belt-and-braces type of person would test the system 
version and weak link.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-23 Thread Paul Sanders
 At the BSD layer, getattrlist() is the way to go here, with the 
 ATTR_CMN_CRTIME attribute.

From 
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man2/getattrlist.2.html:

Not all volumes support getattrlist().  The best way to test whether a volume 
supports this function is to simply call it and check the error result.  
getattrlist() will return ENOTSUP if it is not supported
on a particular volume.

I would hazard a guess that NTFS volumes don't support this.  It's also a 
complicated API just to get a file time!  The more I see of this, the more I 
think that the Carbon File Manager is the best option.  I plan to review my own 
code in the light of this thread.  I'm not sure whether stat returns local 
times or UTC (it returns local times on Windows).  I am often on UTC here so 
it's not always possible to tell.  But, luckily, it is summer :)

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-23 Thread Paul Sanders
 BTW, why hazard a guess rather than either (a) testing this, or (b) looking 
 at the kernel sources to find out?

Because I thought it might be a useful heads-up for the OP.  I am not planning 
on using this API myself and I am not familiar with the kernel sources.

 On sensible platforms, stat() returns UTC, as you'd expect.

That statement I can now verify by experiment (which is good as I assumed that 
when I wrote the code).  The docs do not say.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: getting file creation date from NTFS

2010-05-22 Thread Paul Sanders
 Also be aware that not all file systems support the notion of 
 creation dates of their objects.  I don't know off-hand if 
 NTFS does.

It does.

Paul Sanders. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Calling allObjects memory allocation problem

2010-05-21 Thread Paul Sanders
 Also be aware that just because memory is released, doesn't mean it is 
 returned to the system (e.g. you will not
 see your apps memory usage go down in Activity Monitor). In fact,  AFAIK, it 
 is never returned to the system,
 except perhaps in low memory situations.

I don't actually think that's true.  At least, it's not what I observe.  I 
think it's more accurate to say that you cannot predict when memory which has 
been allocated and then freed will be returned to the operating system, nor how 
much.  It happens, I believe, in 4k pages, but probably not one at a time and 
will be heavily dependent on fragmentation of the process's heap.  No doubt 
there is much more to know.

I agree with the sentiment of keeping an eye on your peak memory usage.  I use 
Instruments for this, and it found one instance where memory usage was creeping 
steadily up when the app was playing audio but otherwise idle.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Simulating Text Input

2010-05-19 Thread Paul Sanders
 I am working on a remote-controller, i.e. take one device (be it a Mac or a 
 mobile client) and control another
 Mac. So the application runs in background and the events should be delivered 
 to the front-most application.

 Moving the mouse around works by posting the corresponding events, but I have 
 a hard time to simulate key strokes.

...

I would take a look at the source code for VNC:

http://sourceforge.net/projects/osxvnc/

Indeed, if you write a client that can talk to a VNC server you don't need to 
write your own server at all.

Paul Sanders
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Simulating Text Input

2010-05-19 Thread Paul Sanders
 I am interested in simulating text input (maybe via generating keystrokes), 
 but never found an example for that.

Well VNC must simulate keystrokes somewhere along the line, although finding it 
may take a bit of digging around in the sources.  As you say, mapping all the 
various keycodes is likely to be painful.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: UI blocking

2010-05-17 Thread Paul Sanders
On May 16, 2010, at 3:37 PM, Tobias Jordan wrote:

 Hey guys,
 
 I have a CA transition running which obviously doesn't support any blocking 
 modes (CABasicAnimation). I must block the UI during the transition so the 
 user can't click somewhere and something unexpected happens. I think all 
 animations in OS X are blocking the UI, for example minimizing a window going 
 into the dock. Question, is there a way to block the UI / main thread or 
 maybe just a window? I tried using usleep but looks like the animation and 
 its drawing view don't like that. I can't believe there's no 
 'setBlockingMode' or something like that for CAAnimation.
 
 Thanks in advance!

The approach I use is to subclass NSApplication and throw awat mouse, keyboard 
and gesture events in -[MySubclassedNSApplication sendEvent:] instead of 
calling super.  For added style, beep.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Posix error 24

2010-05-15 Thread Paul Sanders
Use lsof from the command line.

Paul Sanders.

- Original Message - 
From: The Geezer gee...@ix.netcom.com
To: cocoa-dev@lists.apple.com
Sent: Saturday, May 15, 2010 3:24 PM
Subject: Posix error 24


I wrote a cocoa application that periodically gets a posix error 
24.
I know this means my app's number of open files has exceeded
kern.maxfilesperproc, however, I can't figure out when and where 
I'm
leaving files open. This appears to be happening after accessing
several hundred web pages.

I would like to be able to keep track of what the system 
considers to
be the number of files open at any given time to help debug my
program. I assume it is the fields kern.openfiles and
kern.maxfilesperproc that I need to access.

Could someone show me how to access these fields in a cocoa 
application?

Thanks,
-geezer



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Figuring out what's causing redrawing

2010-05-15 Thread Paul Sanders
 Right, but how do I catch what is causing the views on top to redisplay? I 
 already tried breaking on the usual suspects and caught one view that was 
 doing unnecessary redisplays, but even after fixing that I'm still getting a 
 view in a completely different place that is constantly getting redrawn for 
 no apparent reason.

Just a longshot: did you override one of the 'display...' methods and fail to 
call super?  If so, that might cause trouble.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: TUTORIAL: Generating Unique ID Strings

2010-05-14 Thread Paul Sanders
 I tried a page on, but it didn't do the color highlighting

You could try pastebin. It seems to be popular with the folks 
round here.

Pau Sanders. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Utility/Floating window with titlebar on left side

2010-05-06 Thread Paul Sanders
 Already tried NSBorderlessWindowMask, but that doesn't supports the close
 button functionality, which is required in my case.

You can create a close button via +[NSWindow standardWindowButton:forStyleMask:]

I think NSBorderlessWindowMask is the only game in town here.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Help with text input

2010-04-30 Thread Paul Sanders
 what is the best way on cocoa to determin raw key (physical key) input?

http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html#//apple_ref/doc/uid/2016-keyCode

and:

http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html#//apple_ref/doc/uid/2016-SW136

To detect a keypress for a modifier key, you need to look for an NSFlagsChanged 
event.  The documentation for NSEvent covers all this.  I imagine you are 
already familiar with the key codes generated by an Apple keyboard.  There's a 
nifty little app out there called Ukelele which will display them.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-28 Thread Paul Sanders
 this problem must be because i am using core graphics

I don't know if this is relevant, but I noticed that there is a Core Graphics 
function called CGContextFlush.  The docs say you shouldn't need to call this 
but maybe in your case you do.  There's also a flushGraphics method of 
NSGraphicsContext.  If you are mixing Cocoa and Quartz drawing calls, these 
might help solve any timing issues.

Another possibility would be to use Cocoa drawing calls throughout, rather than 
calling Quartz directly.  I do that and it works OK for me.  I was attracted by 
the relative simplicity of doing things this way and Apple engineers have been 
nudging you in that direction.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-28 Thread Paul Sanders
If you want to draw outside of drawRect:, try calling lockFocus on your content 
view first.  Then, to get an NSGraphicsContext, call [NSGraphicsContext 
currentContext].  When you are done drawing, call unlockFocus, again on your 
content view.  Also, in my experience, if you draw outside of drawRect: you 
need to call flushWindow yourself after calling unlockFocus to get reliable 
screen updates.

Paul Sanders.

- Original Message - 
From: Bill Appleton 
To: vincent habchi 
Cc: Paul Sanders ; cocoa-dev list 
Sent: Wednesday, April 28, 2010 7:29 PM
Subject: Re: white screen windows at first


hi all,

i have been working on this a lot  have some new information

previously i was using carbon and core graphics

when i draw to the screen, sometimes it is in the update event but sometimes it 
was in response to a mouse click, or some other event

this always worked:


QDBeginCGContext(grafptr, cgContext);
CGContextSaveGState(cgContext);

draw with core graphics here...

CGContextRestoreGState(cgContext);
QDEndCGContext(grafptr, cgContext);


but when i switched to cocoa, i started doing this:


cgcontext = [[myNSWindowPtr graphicsContext] graphicsPort];
CGContextSaveGState(cgContext);

draw with core graphics here...

CGContextRestoreGState(cgContext);


this appears to only work from inside the drawRect routine, if i get here from 
some other event it doesn't work

so is it legal to draw on an NSWindow from some other event? 

if not, what the heck does QDEndCGContext do that makes it work?



thanks,

bill
___

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

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

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

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-28 Thread Paul Sanders
 Paul outlined a way to draw outside of drawRect: however I 
 think it
 would be better to use lockFocusIfCanDraw instead of 
 lockFocus.

Yes, I agree, although it begs the question of what to do if 
lockFocusIfCanDraw returns NO.  In my experience, that only 
happens when the view (or any of its ancestor views) is hidden 
so you can just give up in that case.  I agree also that drawing 
within drawRect: is much the best way, but it occurs to me that 
you might have a ton of existing code that doesn't see life in 
those terms.  I'd head in that direction though, if you can.

Paul Sanders.



___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-27 Thread Paul Sanders
 Um, actually the menu bar is on the primary display.  That's 
 the definition of the primary display
 -- it's the one with the menu bar.  Did you perhaps mean the 
 built-in display?

I was speaking from memory.  My recollection is that after I 
moved the menu bar the primary display, as reported by NSScreen, 
did not change.  But it was a while ago so I could be wrong and 
the docs agree with you.  This implies that the primary display 
can change at run time.

Paul Sanders. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-27 Thread Paul Sanders
 are you saying there is a way to set the min, max and value on 
 an
 nsscroller? sorry, not clear on that

Why do you need min and max anyway?  The current position is set 
as / returned as a float (or a double) between 0 and 1.  That 
represents the range of the scroller.  Interpret it however you 
like.

Paul Sanders.





___

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

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

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

This email sent to arch...@mail-archive.com


Re: why doesn't the compiler complain?

2010-04-27 Thread Paul Sanders
 So I guess the compiler treats the *first* declaration of a 
 method
 name-and-signature that it encounters as the real one.

 Now, that's okay ...

Not really.  Without the warning flag it means that the type 
checking you would hope to get from the compiler is subverted. 
In your example it might let you pass an NSString to a method 
expecting an NSArray, which is likely to have unfortunate 
results.  Other, more insidious examples, are possible, 
including cases that could lead to a memory overwrite.  I think 
the fact that the warning is off by default is probably for 
historical reasons.  I'd like to see that changed. 
Unfortunately, setting it project-wide generates a warning 
(something like 'this flag pertains only to Objective-C') for .c 
and .cpp files, which is a bit of a pain, but one can probably 
set it with a #pragma.

Paul Sanders.



___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-27 Thread Paul Sanders
Actually, I think I was just plain wrong but what I meant was 
[[NSScreen screens] objectAtIndex: 0].

Paul Sanders.

- Original Message - 
From: Uli Kusterer witness.of.teacht...@gmx.net
To: Paul Sanders p.sand...@alpinesoft.co.uk
Cc: Cocoa-Dev (Apple) cocoa-dev@lists.apple.com
Sent: Tuesday, April 27, 2010 10:34 PM
Subject: Re: NSApplicationMain question


On 27.04.2010, at 11:53, Paul Sanders wrote:
 I was speaking from memory.  My recollection is that after I
 moved the menu bar the primary display, as reported by 
 NSScreen,
 did not change.  But it was a while ago so I could be wrong 
 and
 the docs agree with you.  This implies that the primary 
 display
 can change at run time.

 Maybe you were asking for the -mainScreen? In Carbon and some 
other documentation, the screen with the menu bar is called the 
main screen. But in Cocoa, the -mainScreen method actually 
returns the screen on which the window that is currently main 
is placed. Tricks many people.

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




___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-26 Thread Paul Sanders
 did anyone have some more color on question (2)  the need to create a raw
 NSScroller and control it like a NSSlider  (min, max, value, proportion) is
 that possible?

Yes, just instantiate it and call initWithFrame.  Then add it to your window's 
content view, which will retain it so you can release it.  Other than that, 
consult the NSScroller docs (and read up on the target/action mechanism for 
NSControls so that you can catch events generated by the scroller).

Addendum to my earlier post: requests to draw come though your content view's 
drawRect: method (or said method of any subviews thereof), so yu can use that 
to trigger the drawing of any 'bare metal' widgets.  To force a redraw, call 
setNeedsDisplay or setNeedsDisplayInRect: on your content view.

I learnt all this stuff by reading about it and by experimenting with my toy 
Cocoa app...  It's a method that works.  Apple's Cocoa framework docs are 
actually very good.  They should all have been installed with Xcode.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-26 Thread Paul Sanders
 so in the NSScroler docs there is no way to set the min, max, and value -- 
 that is the problem

http://developer.apple.com/Mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSScroller_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/NSScroller/setFloatValue:knobProportion:

If you want to support Tiger, you will have to use the deprecated method.  If 
not, don't.

Note that to learn all about class X, you may need to read up on its 
superclass(es).  In this particular instance, NSScroller is a subclass of 
NSControl and many of the things it can do are defined there.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-26 Thread Paul Sanders
It sounds like [NSWindow flushWindow] isn't getting called. 
Nothing is sent to the window server until that happens.  In a 
'normal' Cocoa app, this is taken care of in the event loop but 
in your case that evidently isn't happening.  It might be good 
enough just to call it at the end of your drawRect: method, but 
calling it too often hurts performance and, depending on exactly 
what is being drawn when, can cause 'screen flash'.

Paul Sanders.

- Original Message - 
From: Bill Appleton billapple...@dreamfactory.com
To: cocoa-dev list cocoa-dev@lists.apple.com
Sent: Monday, April 26, 2010 10:35 PM
Subject: white screen windows at first


hi all,

when my windows are first shown there is no drawing inside, they 
are white

but when i slowly move the mouse over to the close box and the 
close box
responds to the mouse hover suddenly they draw their content 
properly

does this ring any bells with people? i'm not sure where to look 
in the docs
for this one

i have properly subclassed the NSView and the drawRect message 
is working...
do i need to do something else when I first show a window?

thanks,

bill appleton



___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-25 Thread Paul Sanders
 1) how do i get that nifty application/preferences/services menu? i create my 
 menus dynamically (not nibs)

I did this by starting out with a menu created from a NIB (and which contained 
the Application menu, File menu, Edit menu and so forth) and then modifying 
this to add the additional elements I wanted.  The NIB I started with was 
created by Xcode, using the generic 'Cocoa Application' template.

 3) are there window styles for palettes / document windows? there seems to be 
 only one style...

Have a look at the style masks for NSPanel.  In particular, NSUtilityWindowMask 
will give you a floating pallette (with the smaller title bar).

 4) ... when i delete a menu... do i have to delete the individual items?

Apart from the answer already given, no.  NSMenu retains its submenus and menu 
items so when the parent is deleted (or, rather, released for the last time) 
then all the children will go away too, unless they have been retained 
somewhere else.  This is generally true of collection objects.

To look for leaks, I too use the 'Leaks' tool in Instruments and it did 
discover few things.  It's not foolproof though - there is a chance of a false 
negative - so another simple trick is to watch the memory usage of your app in 
Activity Monitor.  If this keeps on creeping up over time, you still have a 
leak.  I found one or two things this way as well, including a situation where 
an autorelease pool was not being drained for long periods of time resulting in 
excessive peak memory usage.

 5) is my screen flipping code below going to work on multiple monitors?

Yes, that is essentially what I do to map from and to 'top down' coordinates.  
In fact, I just do:

// Map a screen Y coordinate between Windows (top-down) and Mac (bottom-up) 
coordinate systems (works either way round)
float WCLMapScreenY (float y)
{
NSRect r = [[NSScreen mainScreen] frame];
y = r.size.height + r.origin.y - y;
return y;
}

I tested my multiple-monitor support by plugging an external monitor into the 
back of my 2009 MacBook.  Note that the menu isn't necessary located on the 
primary screen; ditto the dock.

 NSMenu *newmenu(unsigned char *menuname)
 {
 NSMenu *themenu;
 NSString *mystring;
 char tempstring[256];
 
 pstr2cstr(menuname, tempstring);
 mystring = [NSString stringWithUTF8String:tempstring];
 themenu = [[NSMenu alloc] initWithTitle:mystring];
 [themenu setAutoenablesItems:NO];
 [mystring release];
 return(themenu);
 }

You should not be releasing mystring. [NSString stringWithUTF8String:] will 
autorelease it, as the memory management guidelines make clear.  You are doing 
the right thing with themenu (i.e. not autoreleasing it) because your method 
has 'new' in the name.  The caller of this method is therefore responsible for 
the object's ultimate disposal.  setmenuitemtext contains a similar error.  To 
catch problems like this early, enable 'zombies' (but not when checking for 
leaks!!):

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

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Wave form graph through Core Audio?

2010-04-23 Thread Paul Sanders
 I'm working on generating a wave form for a sound bite, but I'm stuck in Core 
 Audio, which seems
 to be not over-documented, so to speak. All I need for now is an array of 
 integers, based on some
 sample rate, for a given sound file, but most of Core Audio seems to target 
 more complex functionality.
 Are there any code snippets around for sampling a sound file?

Apart from this being the wrong list as already mentioned, you are looking for 
ExtAudioFile.  This can read a variety of sound file formats and is very easy 
to use.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-23 Thread Paul Sanders
I had a vaguely similar requirement in that I wanted to port my Windows app to 
Cocoa and I wanted to do it (and indeed did do it) by writing a 'Windows 
emulation library' on top of Cocoa.  This took about a year.

To get started, I wrote a very simple one-window Cocoa program ('Cocoa 
Testbench') using the 'Cocoa application' template in Xcode.  While this 
involves getting to grips with Interface Builder it provides a shortcut to 
having something you can experiment with on an ongoing basis, and knowing IB is 
a useful skill anyway.  And I have a bit of good news for you: Cocoa is very 
hackable, once you get into it.  My initial fear that it was just a high-level 
RAD tool went away quite quickly.

I also found reading up on Objective-C very valuable.  It is more subtle than 
at first appears.  I found Apple's online documents more than adequate for 
this.  Other than that, I can only echo the advice given by others: buy a 
couple of 'get you started' books (Hillegass is very readable) and be prepared 
to invest quality time in learning the Cocoa framework.  You can probably 
ignore Core Data and KVO though, at least at first.  I did, and, for what I am 
doing, I do not miss them.  Tell you what though; taking in so much new 
material is very tiring, mentally.  Get plenty of sleep and forget everything 
you know about Carbon.

Paul Sanders.

- Original Message - 
From: Bill Appleton billapple...@dreamfactory.com
To: Michael Ash michael@gmail.com
Cc: cocoa-dev cocoa-dev@lists.apple.com
Sent: Friday, April 23, 2010 3:08 PM
Subject: Re: NSApplicationMain question


hi all,

wow thanks for the advice. i agree i will need to ultimately know a lot
about cocoa to make the transition

i don't have a lot of choices, in that the engine i am porting is about 1/2
million lines of C, and about 10,000 enterprise companies depend on it,
mainly on windows, although a significant number of them have macs

so i have made a lot of efforts to learn cocoa, but our product is an NPAPI
browser plugin, so we have to switch from carbon windowrefs to cocoa
nswindows because that is what the NPAPI interface provides. in fact much of
the architecture is dictated by this interface which runs under WebKit /
Safari / Firefox.

so its a real world scenario instead off the best of all possible worlds

but its great to meet so many knowledgeable people, i'll have some more
tangible questions as this progresses

thanks,

bill appleton
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Reason for menuNeedsUpdate notification?

2010-04-23 Thread Paul Sanders
NSMenuDidBeginTrackingNotification might do what you want.  Note that, despite 
what the docs say, this is not sent on Tiger.

Paul Sanders

- Original Message - 
From: David Reitter david.reit...@gmail.com
To: cocoa-dev@lists.apple.com
Sent: Friday, April 23, 2010 4:31 PM
Subject: Reason for menuNeedsUpdate notification?

How would I go about determining the reason for a menuNeedsUpdate notification?

My app gets these both for key presses and clicks on the menu.  I would like to 
only update it for clicks, because updating the menu is slow (and will be even 
slower when done separately for each menu item, via numberOfItemsInMenu: and 
menu:updateItem:atIndex:shouldCancel).

Looking at the event type is not reliable.  While clicks are normally 
SysDefined events, they become AppDefined as soon as VNC/ARD or even mouse 
enhancement utilities such as BetterTouchTool are used.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-23 Thread Paul Sanders
 (i'm the guy who wrote supercard if that explains anything to the old-timers)

It does.  Respect.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: overwriting own bundle

2010-04-23 Thread Paul Sanders
  Is it acceptable for an application to overwrite its own bundle, say as part 
 of an update? Assuming of course that it can get any necessary elevated 
 privileges? Or should I spawn a task that waits for the app to quit and then 
 overwrite it?

Do you install from an mpkg?  I just download that (well, the dmg), tell the 
user what's going to happen next and then mount the dmg (via hdiutil) and quit 
the App.  Installer.app then does it's usual stuff.  The welcome screen in my 
package says something like 'if you have an existing installation it will be 
upgraded'.

This makes the whole procedure very simple.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-23 Thread Paul Sanders
 you [Jens] are right about all of that except we also run in stand alone
 application mode, and we also have floating palettes and scripting windows
 (etc) in developer mode in the browser

I would think, then, that mastering the anatomy of a standard Cocoa application 
would be well worthwhile.  You might want to re-do your palettes and suchlike 
as nibs, for example, and at the very least you should know how to do this, 
otherwise how can you make an informed decision on which is the right approach? 
 A 'Cocoa Testbench' app will also let you experiment with event handling in an 
NSWindow - presumably events will turn up through in the normal way through 
your NSWindow's sendEvent: method under NSAPI so you can take a look at that.

But NSWindows are simple beasts.  You will need to learn all about NSViews and 
the rich set of subclasses (like NSButton) that constitute the Aqua 'widget 
set'.  These are right at the heart of the way a Cocoa app interacts with the 
user and it's unlikely that you will be able to (or indeed want to) avoid them.

Presumably, your existing code has a way to layout widgets in a window and some 
kind of platform-independent event model. Once you know enough about how Cocoa 
works, you might be able to constuct your window layouts on the fly from 
whatever code or data structures currently build your UI, and you might be able 
to feed Cocoa events (e.g. a button press, to pick a very simple example) back 
through your existing event model.

That's essentially what I do - I build the NSView hierarchy for a window from a 
Windows .res file and I have a reasonably convincing facsimile of the Windows 
messaging model to handle events.  But then I graduated from the school of the 
terminally weird.  It works though, although as I say it took a while to put it 
all together, and I now have common code across the two platforms with a 
reasonably native look-and-feel, which is what I wanted.  Tough luck about 
Linux, but then that's not important to me.

Looks like you have an interesting journey ahead of you.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-23 Thread Paul Sanders
 I build the NSView hierarchy for a window from a Windows .res 
 file ...

It's worth adding that I started with a substantial base of 
working, well-tested Windows code.  My approach would not 
otherwise be justified.  But with 1/2 million lines of code, you 
must be in an analogous situation.  It's a bit like the old 
Irish joke that goes 'What's the best way to get to Dublin?' --  
'Well I wouldn't start from here'.  No offence intended to any 
Irish readers BTW, it's a terrific place.

Paul Sanders. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSApplicationMain question

2010-04-23 Thread Paul Sanders
 I build the NSView hierarchy for a window from a Windows .res 
 file ...

Or do you have your own 'bare metal' widget set?  If you are already 
cross-platform, I guess you probably do.  In which case [NSWindow sendEvent:] 
is what you're looking for - everything comes through there -  plus the NS or 
CG Graphics context you can get by locking focus on the Window's content view 
for drawing in.

I knew I'd get there in the end!

Paul Sanders. 
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 Yep, it's a big win.  Even if the default allocator does something  
 similar (and I think you're right that a linked list of free blocks of  
 a given size is maintained by the malloc code, or something of that  
 sort), this scheme avoids a fair handful of method calls and function  
 calls per object, and so it wins big even just with that.  I can't  
 remember what the degree of speedup was (I put this scheme in several  
 months ago now), but it was quite substantial.

http://www.mikeash.com/pyblog/performance-comparisons-of-common-operations.html

According to which, alloc + init + release costs about the same as 35-40 method 
calls.

The code I posted could cache [MyClass class] if (as I do) you like to leave 
the asserts in your release code.  And it works, of course, because the isA 
pointer in all instances of a particular class is the same.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 As I mentioned in my post to Graham just now, doesn't your
 implementation assume that NSObject's only ivar is the isa 
 pointer,
 though?

Actually, no.  Because it makes a bitwise copy of a clean, 
properly init'ed object it should work whatever trickery 
NSObject (or any other parent class) does behind your back with 
hidden iVars.  Something I've never been clear about though is 
where an object's retain count is stored.  This obviously 
requires an iVar somewhere (in addition to isA), so there might 
be a trap for the unwary there, but if you ensure (or better 
still assert) that a to-be-recycled object has a retain count of 
1 you should be OK.  And I'm also not sure if it's valid to make 
a bitwise copy of a Core Foundation object, which is what we are 
doing here.  Thinking about it, probably not.

As Ken said, these tricks are probably easier to pull off in 
C++, but no doubt you have an existing obj-C code base.

Paul Sanders.



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 To be clear (for the archives), the above byte-wise copy of the object is 
 only safe if the class has no pointers with ownership
 semantics among its instance variables.  See the discussion of object copying 
 in the Memory Management Guide.

Yes, of course. I took that as a given, based on the way that Ben is recycling 
his objects.

 The init method has nothing to do with zeroing out instance variables.  
 Object allocation is responsible for that.

Indeed.  That's what lies behind the OP's predicament.  If init did it, he 
would not have to hack around like this.  Pity us poor C++ folks.  One of the 
worst design decisions in C++, IMO, is that objects are not zeroed on 
allocation by default.  It leads to constructors like this:

ivar1 = 0;
ivar2 = 0;
ivar3 = 0;
ivar_p1 = NULL;
ivar_p2 = NULL;
...

Which is tedious and error prone.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 My understanding, which is vague and for which I have no references, is that 
 it's handled in a manner similar to
 what was recently exposed via the associated references API (i.e. 
 objc_setAssociatedObject and friends).

 That is, retain counts are stored outside of the instance.

In that case there is a danger that a pointer to whatever is referenced would 
be transferred to the copy of the object, which is not what you want.  One 
could test it like this:

NSObject *a = [[NSObject alloc] init];
printf (%d\n, [a retainCount]);// 1
NSObject *b = [[[NSObject alloc] init] retain];
printf (%d\n, [b retainCount]);// 2
*b = *a;
printf (%d\n, [b retainCount]);// 1
[b retain];
printf (%d\n, [b retainCount]);// 2
printf (%d\n, [a retainCount]);// ?

If the last printf prints 2, my scheme doesn't work as a and b must now be 
referring to the same object at the Core Foundation object level.  I am, of 
course, far too lazy to test this or read up on it.

 Would be an interesting subject for Mr. Bumgarner to expound upon on his blog.

Yes it would.  We're lucky it's Saturday or he would probably have already 
poured cold water on the whole idea :).

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 AFAIK, CF objects store the retain count in an ivar (or a struct field to 
 be exact) and
 standard Obj-C objects ref count is stored in an external hash collection 
 (CFBasicHash on 10.6). 

One might get away with it then, as presumably the hash key is the address of 
the object and that is constant for the lifetime of the object.  Weird 
implementation.  Expensive, in terms of CPU cycles, for retain and release.  
The retain count should be an iVar of NSObject, seems to me.

This post also makes interesting reading:

http://www.mikeash.com/pyblog/friday-qa-2010-01-22-toll-free-bridging-internals.html

I see that my assumption that Toll-Free bridged CF and Obj-C types have the 
same internal layout was false.  Instead, it's all smoke and mirrors.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 No, you misunderstand.  There is (in the scheme I'm vaguely recalling) 
 _nothing_ inside the instances
 which holds or points to something which holds the retain count.

 There is another data structure entirely which maps from object addresses to 
 a retain count.

Yes I see, that's also what Jean-Daniel is saying.  In which case, my bytewise 
copy scheme should work, since if a and b are (or derive from) NSObject then if 
I do this:

*b = *a;

the retain count of (b) will be unaffected (which is what you want) and remains 
independent of (a) since retain counts are tied to object addresses, not 
content.  The code I posted before should therefore produce the following 
results (prediction, untested, fingers crossed):

NSObject *a = [[NSObject alloc] init];
printf (%d\n, [a retainCount]);// 1
NSObject *b = [[[NSObject alloc] init] retain];
printf (%d\n, [b retainCount]);// 2
*b = *a;
printf (%d\n, [b retainCount]);// 2
[b retain];
printf (%d\n, [b retainCount]);// 3
printf (%d\n, [a retainCount]);// 1

I reckon my scheme might actually be faster Ben, if you benchmark it.  Without 
the assert it's just a method call and a memcpy, which the compiler knows the 
size of and can therefore optimise.  Only you can decide whether either 
approach is worth the risk.

Paul 'quick and dirty' Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 The question is: Is it documented as a fact you can rely on that this is 
 the case? If not, I at least wouldn't rely on it for shipping code. Even 
 if it was for an at home project I'd think about it long and hard. 
 Tracking down subtle memory bugs caused by Apple deciding to move the 
 reference count into an NSObject instance variable after all doesn't 
 sound like a fun occupation.

That wouldn't matter if you ensure that, when you execute *b = *a, the retain 
counts of the two objects are the same.  What would cause a problem would be if 
NSObject contained a hidden iVar pointing to something else containing the 
retain count.  Then, when you copy this pointer, the retain counts of a and b 
become 'linked' and ultimately, all instances of the object end up sharing the 
retain count of the 'clean instance' one is copying from when zeroing out the 
object for reuse.

Even then, all is not lost.  Override retain and release to do nothing.  
Presumably, Ben, you have your own scheme for managing the lifecycle of these 
objects which is not based on retain counts.

I must stop with this!  I'm supposed to be working!

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-17 Thread Paul Sanders
 I think my approach, with the excellent modifications suggested by  
 Ken Thomases, makes me less nervous than the others proposed, since it  
 touches only my own ivars and makes no assumptions about the nature of  
 the rest of the bits in the object.

OK, best of luck.  I think that 64-bit Obj-C's support for non-fragile instance 
variables might break the bitwise copy idea anyway, I'm not sure.  Other than 
that I think it would be OK, especially if you knock out retain and release 
(i.e. override them to do nothing).

It might be wise to start zeroing you iVars at offset 
class_getInstanceSize([NSObject class]).  That way you don't care how many 
'hidden' iVars NSObject has or what size they are.  I think, in fact, that was 
Ken's intention.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: method caller mixup

2010-04-17 Thread Paul Sanders
 It's not particularly tricky. +alloc returns an id, and Objective-C doesn't 
 have operand-overloaded methods.
 There is nothing in your alloc/init expression that tells the _compiler_ 
 which of the differently-defined initWithParent:
 methods you intend to use, so it picks one in some undefined way. In this 
 case, it picked the one you didn't intend.

 You can force the choice by casting the result of +alloc to the intended type:

 [ (HSMM_TrieNode *)[HSMM_TrieNode alloc] initWithParent: aNode ]

-Wstrict-selector-match would have reported the ambiguity.  Otherwise, the 
following code compiles without complaint (this is on gcc 4.0; on gcc 4.2 the 
warning flag might be on by default):

@interface Class1 : NSObject
- (id) initWithScalar: (int) i;
@end

@interface Class2 : NSObject
- (id) initWithScalar: (float) f;
@end

void test (void)
{
Class1 *o1 = [[Class1 alloc] initWithScalar: 1];
Class1 *o2 = [[Class1 alloc] initWithScalar: 1.0f];
Class2 *o3 = [[Class2 alloc] initWithScalar: 1];
Class2 *o4 = [[Class2 alloc] initWithScalar: 1.0f];
}

However, two of these four init method invocations will get a parameter in a 
form (int vs float) they don't expect since the compiler doesn't have enough 
information to perform the expected implicit type conversion across the call, 
and that is not good.

As for the scope and interpretation of method names, this might be worth a look 
if you haven't already:

http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocSelectors.html#//apple_ref/doc/uid/TP30001163-CH23-SW1

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to find all clipping siblings for a view?

2010-04-16 Thread Paul Sanders
 Historically Cocoa did not support overlapping sibling views at all, so there 
 was no concept of z-order
 (other than a child view being in front of its parent.) There is some support 
 for it now, but I’m not
 sure how extensive it is, e.g. whether it only applies to layer-backed views 
 or not.

It works OK with non layer-backed views in my experience, but you do get a 
build warning if sibling views overlap in a nib.  Sibling views are drawn in 
the order they appear in the parent's list of subviews (or possibly the inverse 
order, I don't precisely recall).  The exact effect you get depends on whether 
they erase the background first and suchlike.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to empty the Trash programmatically?

2010-04-16 Thread Paul Sanders
 But emptying the trash will delete files on *other mounted volumes* as well, 
 not just the disk being examined.

rm -rf ~/.Trash/*

For volumes other than the startup volume it is a little more complicated:

rm -rf /Volumes/volume_name/.Trashes/uid/*

The Finder seems to notice when you do this and keeps in sync.

Looking in these folders will also allow you to give the user some idea of what 
he is about to permanently delete.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to find all clipping siblings for a view?

2010-04-16 Thread Paul Sanders
 Also, IB had (has?) a bug where it would unarchive views in the
 reverse order from which they were stored in the nib. IB does allow
 you to reorder subviews, so if you are still being bitten by this you
 could build your interface and then reorder the views such that they
 are backwards. Then they should unarchive correctly at runtime.

You're not gonna believe this, but I'm using neither IB nor nibs :)
___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to empty the Trash programmatically?

2010-04-16 Thread Paul Sanders
 Please don't hardcode those paths. Use system APIs like 
 FindFolder
 instead to locate the trash directory for a given volume.

Well, OK, but you get the idea.

Paul Sanders.



___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to empty the Trash programmatically?

2010-04-16 Thread Paul Sanders
 As long as it is obvious that this empties the system-wide trash. After
 all, Mail.app and other programs have their own trashes, and you
 wouldn't want a user to think they're emptying a local trash and
 suddenly delete a file they meant to recover.

In case it wasn't obvious, my earlier rm -rf post was intended 
to show how to empty the trash for a particular volume only.  I 
believe that might be what the OP was looking for.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Zeroing out instance variables

2010-04-16 Thread Paul Sanders
Another way might be to provide a method in each class or subclass called, say, 
zeroIVars and code it as (typed in mail):

- (void) zeroIVars
{
static ThisClass *clean_instance_of_this_class;

assert ([self isMemberOfClass: [ThisClass class]);
if (clean_instance_of_this_class == nil)
clean_instance_of_this_class = [[ThisClass alloc] init];
*self = *clean_instance_of_this_class;
}

Note that this should correctly preserve the object's isA pointer.

Although not strictly threadsafe, this should be good enough in practise - in 
the worst case it just leaks an object or two.  The biggest danger, of course, 
would be to forget to implement zeroIVars for a subclass.  That would be 
lethal, hence the assert.

This approach gives you the opportunity to end up with an object that is not 
just all zeroes (by way of the init method), and if a class needs some kind of 
cleanup that could be catered for too (perhaps by calling a method called, say, 
cleanup, which, unlike zeroIVars, is allowed to call super).  But then it's not 
quite so lightweight...

If you declare zeroIVars as part a protocol, I believe the compiler will check 
that you have implemented it for all subclasses that adopt that protocol (can 
someone please confirm this):

@protocol MyLightweightReusableObjectProtocol

- (void) zeroIVars;

@end


@interface MyClass : NSObject MyLightweightReusableObjectProtocol

...

Paul Sanders.

- Original Message - 
From: Ben Haller bhcocoa...@sticksoftware.com
To: Cocoa List cocoa-dev@lists.apple.com
Sent: Friday, April 16, 2010 10:29 PM
Subject: Re: Zeroing out instance variables


 3. bzero(individual + individualIvarsOffset, individualIvarsSize);

   This should cast individual to void* before doing the pointer  
arithmetic, of course.

  So, thoughts?  Am I insane?  Is the above scheme safe?  Is there a  
 better way?  Thanks for any feedback!

   I should note that the scheme described does appear to work  
correctly on 10.5, at least.

Ben Haller
McGill University
___

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

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

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

This email sent to arch...@mail-archive.com


Re: How does Finder determine when a file is busy being written to the disk?

2010-04-08 Thread Paul Sanders
Maybe poll the file size when you get your event and wait for it 
to stop changing.

Paul Sanders.

- Original Message - 
From: Lee Gillen lee.gil...@gmail.com
To: Jens Alfke j...@mooseyard.com
Cc: Apple Developer Mailing List Cocoa-dev@lists.apple.com
Sent: Thursday, April 08, 2010 7:08 PM
Subject: Re: How does Finder determine when a file is busy being 
written to the disk?


My app watches a folder using FSEvents to see when files are 
added to
it and then uploads those files to a server. It's kind of like a 
hot
folder. The issue is that when users are copying large files,
especially from a network drive, the upload will begin before 
the file
has been completely written to the disk.

'fuser' is a command line utility that tell you what app PID has 
the
file open. I see that if I pass 'fuser' the file path I see that
Finder has the file open.



___

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

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

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

This email sent to arch...@mail-archive.com


Mysterious 'QLPreviewView ' crashes.

2010-04-04 Thread Paul Sanders
Anyone ever seen crashes like this before?

http://www.alpinesoft.co.uk/private/crash1.txt
http://www.alpinesoft.co.uk/private/crash2.txt
http://www.alpinesoft.co.uk/private/crash3.txt

These (just these 3) have been reported by customers over the last month or so. 
 We have only seen them on Snow Leopard, but we hardly have a statistical 
sample.  I have never seen it during development or testing.  It seems to be 
connected with disposal of a QLPreviewView by NSOpenPanel when it is closed.  
Note that it's not the main thread that crashes, but it looks like it's doing 
something that whipped the rug out from under the thread that did.  Note also 
that in all cases the faulting address appears to be part of an ASCII string 
(and not one I recognise).

I have raised a bug report about this (7826287) but I thought I'd see if 
anybody here has seen something similar.  I don't think it's us.  I like to 
think that we see these weird, rare crashes because of the reporting facility 
(based on Uli Kusterer's UKCrashReporter) built into our software, rather than 
the fact that we have lots of bugs in our own code.  AFAIK, we are good 
citizens when it comes to respecting other people's memory, but you can never 
be 100% sure.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSWindow subclass VERY slow to resize

2010-03-26 Thread Paul Sanders
Have a look at -[NSBezierPath setFlatness:].  A larger value 
might be faster (but might also look ugly).  There's also a bit 
of code floating around in the web-o-sphere that might be faster 
than what you are using:

http://lists.apple.com/archives/Cocoa-dev/2006/Mar/msg01940.html

Paul Sanders

- Original Message - 
From: Daniel Weber dan.j.we...@gmail.com
To: cocoa-dev@lists.apple.com
Sent: Friday, March 26, 2010 6:08 PM
Subject: Re: NSWindow subclass VERY slow to resize


It appears that drawing the rounded rect vs. a regular rect is 
slow.
Also, I am filling using a pattern image vs. a solid color. 
These
things add up to a pretty slow redraw at large sizes. I can set 
the
max size to something relative low, but does anyone have any 
other
suggestions?



___

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

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

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

This email sent to arch...@mail-archive.com


Re: The fastest way to render bitmaps to screen in Cocoa on Snow Leopard?

2010-03-25 Thread Paul Sanders
 I need to open a bitmap file, perhaps do some filtering, and 
 render it
 to the screen with the maximum possible performance.

Try it the easy way, see if it's fast enough.  NSImage can load 
most common bitmap file formats and draw itself.

Paul Sanders.




___

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

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

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

This email sent to arch...@mail-archive.com


Re: Odd crash

2010-03-22 Thread Paul Sanders
And I have seen something similar (including once here), always, I see, on 
10.6.2:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0018
Crashed Thread:  2

...

Thread 2 Crashed:
0   com.apple.DesktopServices 0x9873dd1b 
TNode::FSVolumeObserverCallback(short, __CFString const*, void const*, void*) + 
1069
1   ...ple.CoreServices.CarbonCore 0x918be381 _FSVolumeObserverCallback + 
214
2   com.apple.CoreFoundation  0x91ca7b72 __CFMachPortPerform + 338
3   com.apple.CoreFoundation  0x91ca38db __CFRunLoopRun + 6523
4   com.apple.CoreFoundation  0x91ca1864 CFRunLoopRunSpecific + 452
5   com.apple.CoreFoundation  0x91ca77a4 CFRunLoopRun + 84
6   com.apple.DesktopServices 0x986e363f 
TSystemNotificationTask::SystemNotificationTaskProc(void*) + 643
7   ...ple.CoreServices.CarbonCore 0x918d87ae PrivateMPEntryPoint + 68
8   libSystem.B.dylib 0x922f4fbd _pthread_start + 345
9   libSystem.B.dylib 0x922f4e42 thread_start + 34

I have submitted a bug report (#7753826).

Paul Sanders.

- Original Message - 
From: Kevin Wojniak kain...@kainjow.com
To: Kyle Sluder kyle.slu...@gmail.com
Cc: Cocoa-Dev List cocoa-dev@lists.apple.com
Sent: Monday, March 22, 2010 3:31 PM
Subject: Re: Odd crash


I've seen this crash plenty of times as well. Hopefully it'll be fixed in 
10.6.3.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Save As core data question

2010-03-21 Thread Paul Sanders
From errno.h:

#define ENOTEMPTY   66  /* Directory not empty */

If that helps at all...

Paul Sanders.

- Original Message - 
From: Gideon King gid...@novamind.com
To: Cocoa Dev cocoa-dev@lists.apple.com
Sent: Sunday, March 21, 2010 5:48 PM
Subject: Re: Save As core data question


...

AppKit called 
rmdir(/private/var/folders/nl/nlcXN-oPHJiAXXc1Z0R5VE+++TI/TemporaryItems/(A 
Document Being Saved By NovaMind5TP 116)), it didn't return 0, and errno was 
set to 66.

...
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Key-Value Observing speed

2010-03-13 Thread Paul Sanders
 As people often seem to do with such things, I was 
 misinterpreting what it [Instruments] was telling me.

A really really simple way of getting a handle on where a 
program is spending its time is to take a few samples in 
Activity Monitor while it is busy.  You'd be amazed at how well 
this works.  Breaking into the debugger is another good trick. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Better sorting using threads?

2010-03-13 Thread Paul Sanders
Yes, that's what I mean.  But it worked fine on Leopard and 
Tiger...  It's all academic now anyway, I rewrote it around my 
own, STL-based collection classes.  I just thought I'd mention 
it in case it bit anybody else.  I didn't keep a copy of the 
code, sorry.

And I know about the difference between copy and mutableCopy Ken 
so it wasn't that, but it was a nice idea to suggest it.

Paul Sanders.

- Original Message - 
From: Greg Parker gpar...@apple.com
To: Paul Sanders p.sand...@alpinesoft.co.uk
Cc: Cocoa-Dev List cocoa-dev@lists.apple.com
Sent: Saturday, March 13, 2010 12:01 AM
Subject: Re: Better sorting using threads?


mutating method sent to immutable object, you mean? That 
suggests your NSMutableDictionary object isn't as mutable as you 
thought. It might not be a thread-related bug.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler





___

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

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

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

This email sent to arch...@mail-archive.com


Re: Private ivars, not marked as IBOutlet, visible in IB

2010-03-13 Thread Paul Sanders
Try:

#define PRIVATE_ID id

...

PRIVATE_ID myPrivateiVar;

Paul Sanders.


___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSTimer never being deallocated

2010-03-13 Thread Paul Sanders
For the benefit of the OP, according to the docs (and this fits in with my own 
experience), calling [NSTimer invalidate] will release the timer at some future 
point in the run loop and is in fact the only way to get rid of it.  So there 
is really nothing to worrry about.  Trust in Papa Cocoa, all will be well.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSTimer never being deallocated

2010-03-13 Thread Paul Sanders
I don't understand all the confusion on this issue.  The NSTimer 
documentation makes the life-cycle of this object very clear. 
Until it goes away, it is probably retained by the runloop.

As Joar says, you often can't make any concrete predictions 
about when an object you don't manage yourself might be released 
for the last time, but if you put a breakpoint on [NSTimer 
dealloc] you will be able to see it when it happens.

Paul Sanders. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Switching methods in private classes in Apple frameworks

2010-03-12 Thread Paul Sanders
*Why* is there no supported way to replace (or, rather, augment) methods in a 
class which one cannot override because one does not create instances of that 
class oneself?  It seems to me that this is just as legitimate as putting a 
category method on that class , but the latter approach is often useless as one 
cannot call 'super' (and again, why not?)

As for something like this breaking after a software update, it seems to me 
that this is likely only when a major new release comes out and, since there 
are _always_ issues with major new releases of OS X it doesn't actually worry 
me all that much. 

Paul Sanders.

- Original Message - 
From: Bill Bumgarner b...@mac.com
To: Gideon King gid...@novamind.com
Cc: Cocoa Dev cocoa-dev@lists.apple.com
Sent: Friday, March 12, 2010 6:36 AM
Subject: Re: Switching methods in private classes in Apple 
frameworks


Where careful about what you do includes only use this in debugging code or 
non-production instrumentation, sure

Do *not* ship such shenanigans in production code.   One software update later 
and suddenly the presumptions made about that internal method you are 
replacing/overriding/augmenting are no longer true and *boom*.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: performSelector doesn't work for modal window

2010-03-12 Thread Paul Sanders
Try using:

performSelector:withObject:afterDelay:inModes:

passing:

[NSArray arrayWithObjects: NSDefaultRunLoopMode, NSModalPanelRunLoopMode, 
nil]

to inModes:

Paul Sanders

- Original Message - 
From: Alexander Bokovikov openwo...@uralweb.ru
To: cocoa-dev@lists.apple.com
Sent: Friday, March 12, 2010 4:34 PM
Subject: performSelector doesn't work for modal window

...

I've decided to use performSelector:withObject:afterDelay: message. This  
approach works OK for main window, but it doesn't work for a modal  popup panel.

...
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Better sorting using threads?

2010-03-12 Thread Paul Sanders
Just a heads-up to say that when I created an NSMutableDictionary on the main 
thread and then tried to mutate it in a subthread, Snow Leopard threw an 
exception (trying to mutate a non-mutable object, or somesuch).  I was, of 
course, protecting the mutable dictionary against reentrancy problems and the 
same code worked fine on Leopard and Tiger.  I guess Apple think it's dangerous 
to let us play with the sharp toys...

Paul Sanders
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Custom View in Toolbar

2010-03-09 Thread Paul Sanders
Gregory Weston wrote:

 I just sat down and attempted to accomplish what you're describing. It took 
 15 minutes and well under a dozen lines of code.

Care to share your code?  As someone who develops on both Windows and Mac, I 
know how hard the transition can be.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: EventLoop

2010-03-08 Thread Paul Sanders
Calling -[NSView displayIfNeeded] on the NSMatrix before you 
display the modal sheet might do what you want.  You might also 
need to call -[NSWindow flushWindow] on the window containing 
the NSMatrix, but try it first without.  Unnecessary flushes 
hurt performance.

Paul Sanders.

- Original Message - 
From: Tony Romano tony...@hotmail.com
To: Cocoa Developers Cocoa-dev@lists.apple.com
Sent: Monday, March 08, 2010 10:49 PM
Subject: EventLoop


I have an application that updates the image on a cell. 
Sometimes I present a modal sheet right after I setImage.  This 
code is executing in an action sent from the NSMatrix containing 
the cells.  The behavior I am seeing is the sheet rendering 
occurs then the image is updated.  I suspect since the event 
loop hasn't run prior to my call to beginSheetModalForWindow, 
the messages to update the cell image are not being processed.

I've done a fair bit of research looking into the event loop and 
nothing pops out as the best method.  Any thoughts?

TIA,
-tony



___

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

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

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

This email sent to arch...@mail-archive.com


Re: reading text rom Pages doc

2010-03-06 Thread Paul Sanders
On 6 Mar 2010, at 1:59 AM, Ruedi Heimlicher wrote:
 
 I am reading text  from Word docs without problems using the NSTextView 
 method readRTFDFromFile. 
 Trying to read text  from Pages documents with file extension .pages fail an 
 returns empty strings. The same document
 saved in Word format works fine.
 I was trying the NSString method stringWithContentsOfFile with various 
 encodings but I get only garbage.
 What is going wrong? I think it must be a simple way in Apple's Xcode to read 
 Docs written with Apples Pages application.

With a bit of detective work, you can probably use AppleScript to persuade 
Pages to save a copy of the document in RTF format which you can then read into 
your NSTextView.  Asking Pages to put a copy of the document on the pasteboard 
might also work.  Of course, Pages would need to be installed on the target 
machine for this approach to work, and I doubt if all the document formatting 
(and, in particular, embedded images) would be preserved in the RTF version.

Paul Sanders.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Looking for info on anti-piracy and trial-mode techniques for my app . . .

2010-02-25 Thread Paul Sanders
No, I didn't really mean that, but obviously the less they have to go on the 
harder it is for them to hack your code.  Stripping the symbols out of your 
binaries is a good start (but then you get lousy stack traces...)

I also use another, slightly more devious scheme alongside all the technical 
stuff.  I let them (the hackers) think they've won.  Then, a month later, the 
app stops working.  But the hackers never see that because they don't wait that 
long before they move on.  This means that the hacked copies of my app for sale 
at bargain prices on so-called 'oem' software sites (which are actually run, 
according to whois, by small-time russian criminals) don't actually work for 
long on the purchaser's machine.  Which serves them right, it's obvious that 
these sites are just selling ripped-off copies.

Is any of this worth doing?  Well in my case (shareware) it makes me feel a lot 
more comfortable because otherwise you leave yourself wide open.  My webserver 
logs show a number of pirate keys in use (but only for a month!), although 
whether any of those naughty people have a genuine interest in buying the 
software I don't know.  The thing to consider is how much work do the hackers 
have to put in to break the copy protection.  If it's more work to crack the 
software than it is worth to them financially, they will give up and go 
elsewhere.  And anyway, it's a matter of principle.  I don't like people 
stealing my stuff.

Paul Sanders.

- Original Message - 
From: Michael A. Crawford 
To: Cocoa-dev@lists.apple.com 
Cc: Paul Sanders 
Sent: Wednesday, February 24, 2010 10:57 PM
Subject: Re: Looking for info on anti-piracy and trial-mode techniques for my 
app . . .


 Part of your response suggests that if there was an existing framework that 
 was openly available, it wouldn't do me any good because the bad guys would 
 have the source code.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Looking for info on anti-piracy and trial-mode techniques for my app . . .

2010-02-24 Thread Paul Sanders
I rolled my own.  I was not about to put all that effort into developing the 
app and have someone steal my work from under my nose.

For validating the license key, I would recommend some form of digital 
signature rather than just a simple checksum.  I used a checksum first time 
around and it was quickly hacked.  My current scheme also ties the key to the 
machine it's installed on so that it can't be handed around, but it's probably 
sufficient to prominently display the customer's name and email address on 
startup and make it such that a key cannot be forged.

The other thing you have to do is to find some way to stop the hackers from 
patching your app to bypass the check.  Again, I use a DIY form of code 
signature to protect the app as a whole and I then check that the signature is 
valid from here, there and everywhere at run time to make it difficult for the 
hackers to patch the code in just one place.  There are still probably weak 
spots but my software is not exactly expensive so I think it's adequate.

I originally used codesign to validate the integrity of the application but I 
ran into some problems with it.  Something (I have never figured out quite 
what) occasionally adds or changes a file in my bundle after it has been 
installed, thus rendering the code signature invalid.  So I switched to my own 
scheme where I calculate a digital signature for the critical files that make 
up the app and store that in a separate file which I can check at runtime.  
Again, this signature cannot be forged.

If you're hazy about the concepts behind public / private key encryption and 
digital signatures, this might help (I have never been known for my modesty :)

http://www.codeproject.com/KB/security/EZRSA.aspx

As might be apparent, I have put quite a lot of work into this, but I don't 
have anything in a form that can be packaged up and given away.  Nor do I want 
to do that, in fact, but I hope this at least gives you some ideas.

Not really a Cocoa question...  Don't know where else you'd ask it though.

Paul Sanders.
http://www.alpinesoft.co.uk

- Original Message - 
From: Michael A. Crawford michaelacrawf...@me.com
To: Cocoa-dev@lists.apple.com
Sent: Wednesday, February 24, 2010 9:54 PM
Subject: Looking for info on anti-piracy and trial-mode techniques for my app . 
. .


I've purchased apps from other developers on this forum, which have mechanisms 
for limiting functionality until a valid registration code has been provided.  
I'd like to include this functionality in my own app but don't want to create 
it from scratch if I don't have to.  To that end, I'm looking for existing 
libraries, techniques, blogs, and/or suggestions.

Thanks.

-Michael
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Deprecated APIs

2010-02-23 Thread Paul Sanders
Test the framework version at runtime.  I use the Gestalt functions, personally.

http://cocoadevcentral.com/articles/67.php

From the desk of the great Nick Zitzmann himself :)

Paul Sanders.

- Original Message - 
From: charisse napeÿf1as cnape...@yahoo.com
To: cocoa-dev@lists.apple.com
Sent: Tuesday, February 23, 2010 10:09 AM
Subject: Deprecated APIs


Hello,

I am not sure if this problem has already been submitted but how do I define 
two APIs, one that is supported from Leopard down and
another that is only supported in Snow Leopard if I only have one binary for 
all OSes?

...
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Deprecated APIs

2010-02-23 Thread Paul Sanders
I would say that if you have gone to the trouble to code it both 
ways I would keep that code and just add the runtime check 
people have recommended.

I think the issue of deprecated API's is a tricky one.  When 
they might go away seems to depend on whom you ask, and there's 
always the chance that an old, seldom used, deprecated method 
will not be thoroughly tested by Apple in new releases and 
therefore, potentially, become unreliable.

Paul Sanders.

- Original Message - 
From: charisse napeÿf1as cnape...@yahoo.com
To: Andreas Mayer andr...@harmless.de; 
cocoa-dev@lists.apple.com
Sent: Tuesday, February 23, 2010 1:41 PM
Subject: Re: Deprecated APIs


 But is it still safe to use depracated APIs? 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Removing quit button from dock menu

2010-02-23 Thread Paul Sanders
I don't think he meant it to be taken literally!  I took it as a 
tongue-in-cheek way to ask why the OP wants to do this.  I found it rather 
amusing.

However, to answer the question, one can subclass NSApplication, override 
[NSApplication terminate] and not call super.  That doesn't get rid of the menu 
item, but it does prevent it from quitting the app.  And I guess you might 
beep, too.

Paul Sanders.

- Original Message - 
From: Alex Kac a...@webis.net
To: Dave Carrigan d...@rudedog.org
Cc: cocoa-dev@lists.apple.com
Sent: Tuesday, February 23, 2010 2:39 PM
Subject: Re: Removing quit button from dock menu


No offense but that type of attitude and comment is unhelpful and one  
reason cocoa devs sometimes have a not-so-nice reputation.  I can  
think of several types of apps that need this. Kiosk apps, security  
apps, corporate apps, and so forth.

I beg of you to stick to the technical on this list.

-- 
Sent from my mobile phone
(please excuse any mistakes or short response I might have made)

On Feb 23, 2010, at 8:15 AM, Dave Carrigan d...@rudedog.org wrote:


 On Feb 22, 2010, at 10:33 PM, yogin bhargava wrote:

 I dont want to allow the user to quit my application except from the
 activity monitor. I have removed the controls for apple+Q button  
 and menu

 You need to explain to us why you hate your users so much.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Uncaught exceptions not terminating my app

2010-02-19 Thread Paul Sanders
Just a quick update on this for anyone still interested.  To the list of 
exceptions to explicitly ignore in your uncaught exception handler, include 
NSPortTimeoutExceptions.  These happen (rarely) when the spell checking service 
is busy or slow to start up (I'm not sure which, it's happening on a customer's 
machine).  There are also probably other cases, although we haven't seen any.  
Other than that, and a one-off crash on Tiger that actually looks like a Tiger 
bug, the scheme is working well, in the sense that one learns interesting 
things without inconveniencing users unduly.

Paul Sanders.
http://www.alpinesoft.co.uk


- Original Message - 
From: Paul Sanders p.sand...@alpinesoft.co.uk
To: cocoa-dev@lists.apple.com
Sent: Wednesday, January 27, 2010 7:01 PM
Subject: Re: Uncaught exceptions not terminating my app


Here's the list of exceptions I silently ignore in my NSExceptionHandler 
delegate:

---

NSString *nss_exception_name = [exception name];
NSString *nss_reason = [exception reason];

if ([nss_exception_name isEqualToString: NSAccessibilityException])
return YES;

if ([nss_exception_name isEqualToString: NSInternalInconsistencyException])
{
if (gIsTiger) // Happens on startup, apparently a Tiger bug
{
// __T (lockFocus sent to a view whose window is )
// __T (deferred and does not yet have a corresponding platform 
window)
if ([nss_reason hasPrefix: @lockFocus sent to a view whose window is 
deferred])
return YES;
}

// Happens occasionally during testing (on 10.5.8), plus one crash reported 
in the field
if ([nss_reason hasPrefix: @Invalid message sent to event \NSEvent: 
type=LMouseUp])
return YES;
if ([nss_reason hasPrefix: @Invalid message sent to event \NSEvent: 
type=RMouseUp])
return YES;

// Seen this once in the field:
if ([nss_reason hasPrefix: @Failed to get KeyCode from EventRef])
return YES;
}

// Display bye-bye message to the user, maybe offer to save her work if U R 
feeling brave.

* (int *) 1 = 0;
___

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

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

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

This email sent to arch...@mail-archive.com


Strange 'DrawTheMenu' crash

2010-02-19 Thread Paul Sanders
Has anyone ever experienced a crash like the one below?  It is happening 
sporadically in the field (I have, I think, 5 crash logs, spread across all 3 
major versions of OS X, i.e. 10.4, 10.5 and 10.6) but I have never seen it 
here.  Examination of the object code reveals that NSCarbonMenuImpl+527 is a 
call to [NSMenu _enableItems].

All I have to work from is the crash log, but I'm as confident as one can ever 
be that our NSMenu object has not been released or corrupted.  It is pretty 
much static for the life of the app.  The only thing we do which might be a bit 
unusual is to call [NSApplication setMainMenu] whenever the app comes to the 
front.  That's not actually necessary and I plan to change it, but I thought it 
worth mentioning.

Any clues anybody?

Many thanks,

Paul Sanders
http://www.alpinesoft.co.uk



Date/Time:   2010-02-15 14:36:38.032 -0600
OS Version:  Mac OS X 10.6.2 (10C540)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x7364618f
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
objc_msgSend() selector name: respondsToSelector:

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib   0x94ca9ed7 objc_msgSend + 23
1   com.apple.AppKit  0x95b333a0 -[menu 
_carbonUpdateStatusEvent:handlerCallRef:] + 527
2   com.apple.AppKit  0x95b30f79 NSSLMMenuEventHandler + 404
3   com.apple.HIToolbox   0x9009ee29 
DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 
1567
4   com.apple.HIToolbox   0x9009e0f0 
SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, 
HandlerCallRec*) + 411
5   com.apple.HIToolbox   0x900c0981 SendEventToEventTarget + 52
6   com.apple.HIToolbox   0x900ece3b SendHICommandEvent(unsigned long, 
HICommand const*, unsigned long, unsigned long, unsigned char, void const*, 
OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 448
7   com.apple.HIToolbox   0x900ecc78 
UpdateHICommandStatusWithCachedEvent + 66
8   com.apple.HIToolbox   0x9009a619 
HIApplication::EventHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) 
+ 1287
9   com.apple.HIToolbox   0x9009ee29 
DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 
1567
10  com.apple.HIToolbox   0x9009e0f0 
SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, 
HandlerCallRec*) + 411
11  com.apple.HIToolbox   0x900c0981 SendEventToEventTarget + 52
12  com.apple.HIToolbox   0x900ea735 SendMenuOpening(MenuSelectData*, 
MenuData*, double, unsigned long, __CFDictionary*, unsigned char, unsigned 
char*) + 826
13  com.apple.HIToolbox   0x902903b2 _SimulateMenuOpening + 75
14  com.apple.shortcut0x92a688c8 -[SCTGRLIndex 
indexCarbonMenu:withParentMenu:resultGRLs:isRootMenu:systemHelpMenu:withDepth:] 
+ 871
15  com.apple.shortcut0x92a68476 -[SCTGRLIndex indexMenuBar:] + 192
16  com.apple.shortcut0x92a683ae -[SCTGRLIndex 
indexMenuBarDynamically] + 283
17  com.apple.shortcut0x92a2 SCTHelpMenuHandler + 326
18  com.apple.HIToolbox   0x9009ee29 
DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 
1567
19  com.apple.HIToolbox   0x9009e0f0 
SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, 
HandlerCallRec*) + 411
20  com.apple.HIToolbox   0x9009df4f SendEventToEventTargetWithOptions 
+ 58
21  com.apple.HIToolbox   0x900eac42 SendMenuPopulate(MenuData*, 
OpaqueEventTargetRef*, unsigned long, double, unsigned long, OpaqueEventRef*, 
unsigned char*) + 356
22  com.apple.HIToolbox   0x900ea505 SendMenuOpening(MenuSelectData*, 
MenuData*, double, unsigned long, __CFDictionary*, unsigned char, unsigned 
char*) + 266
23  com.apple.HIToolbox   0x900ea010 DrawTheMenu(MenuSelectData*, 
__CFArray**, unsigned char, unsigned char*) + 260
24  com.apple.HIToolbox   0x900e9dda MenuChanged(MenuSelectData*, 
unsigned char, unsigned char) + 467
25  com.apple.HIToolbox   0x900e8b55 TrackMenuCommon(MenuSelectData, 
unsigned char*) + 1481
26  com.apple.HIToolbox   0x900e1195 MenuSelectCore(MenuData*, Point, 
double, unsigned long, OpaqueMenuRef**, unsigned short*) + 315
27  com.apple.HIToolbox   0x900e09a9 _HandleMenuSelection2 + 465
28  com.apple.HIToolbox   0x900e07c7 _HandleMenuSelection + 53
29  com.apple.AppKit  0x95b2a4ba _NSHandleCarbonMenuEvent + 285
30  com.apple.AppKit  0x95aff076 _DPSNextEvent + 2304
31  com.apple.AppKit  0x95afe306 -[NSApplication

Re: NSData category

2010-02-16 Thread Paul Sanders
 Why NSConcreteData? Does it create a different object under 
 the hood

Yes, NSData is a class cluster (see Google).  NSString, NSArray 
and NSDictionary are too, and no doubt others.  But I don't see 
why you shouldn't put a category on NSConcreteData, other than 
the fact that the sand might shift under your feet in a future 
release of the OS.

Paul Sanders. 



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Perform additional action when window receives any mouse- or keyDown

2010-02-16 Thread Paul Sanders
-[NSWindow mouseDown:]? (inherited from NSResponder).

Paul Sanders.

- Original Message - 
From: Jerry Krinock je...@ieee.org
To: Cocoa Developers cocoa-dev@lists.apple.com
Sent: Tuesday, February 16, 2010 5:48 PM
Subject: Perform additional action when window receives any 
mouse- or keyDown


At times, I attach an attached window to a document window.  I 
would like this window to go away whenever the user clicks 
anything in the window, kind of like a tooltip.

So I subclassed the window, overrode -sendEvent:, invoke super 
and post a notification for which my window controller 
registers, and in the notification handler I examine the event 
type.  It works, but this seems quite heavy-handed to get 
something so simple.  Did I miss a more lightweight way to do 
this?

Thanks,

Jerry Krinock



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Perform additional action when window receives any mouse- orkeyDown

2010-02-16 Thread Paul Sanders
I guess so, yes.

Paul Sanders.

- Original Message - 
From: Jerry Krinock je...@ieee.org
To: Cocoa Developers cocoa-dev@lists.apple.com
Sent: Tuesday, February 16, 2010 9:05 PM
Subject: Re: Perform additional action when window receives any 
mouse- orkeyDown



On 2010 Feb 16, at 10:58, Paul Sanders wrote:

 -[NSWindow mouseDown:]? (inherited from NSResponder).

Thanks, Paul.  I hadn't realized that inheritance.

Also, I'd need -rightMouseDown:, -keyDown:, -otherMouseDown:, 
???

At least, no notification needed.




___

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

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

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

This email sent to arch...@mail-archive.com


  1   2   3   >