Re: NSTask launcing executable inside a bundle

2009-09-14 Thread Dave Keck
> using NSTask, or something else? Woops, missed your subject line; NSTask, got it. But yes, I would see if you're able to read the executable as plain data, using NSData's dataWithContentsOfFile: to make sure the path is in fact accessible. ___ Cocoa-d

Re: NSTask launcing executable inside a bundle

2009-09-14 Thread Dave Keck
The current recommendation is to store helper executables in the MacOS directory, rather than the Resources directory of your main bundle. That said, I'm unaware of any enforcement of this that would actually prevent you from executing it. How are you sure that the path is correct? Are you able to

Re: NSArray EXEC_BAD_ACCESS when initalized with strings

2009-09-09 Thread Dave Keck
If you enable the -Wformat warning, the compiler will warn you if you omit the trailing nil. Never understood why it's not enabled by default... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator commen

Re: KVO can be unsafe in -init?

2009-09-09 Thread Dave Keck
> What do I use. Normally a class static, provided that's granular enough, > always has been for me thus far. Either just make some static thing like a > character array and take the address of it or, as I've been doing recently, > use the address of the class object which I grab in a +initialize()

Re: @property (retain) - Do I need to release in dealloc?

2009-09-09 Thread Dave Keck
> It is not however clear, and I haven't found it in the guide, whether > it's still my responsibility to call [_myProp release] in > -(void)dealloc    ? There are varying opinions on how you go about it, but yes, you still need to make sure _myProp is released in dealloc. I prefer 'self.myProp =

Re: usb notification

2009-09-08 Thread Dave Keck
Not really a Cocoa question, and it's answered in the docs on IOServiceAddMatchingNotification :) "The notification is armed when the iterator is emptied by calls to IOIteratorNext - when no more objects are returned, the notification is armed. Note that the notification is not armed when firs

Re: Turn on zombies in user environment?

2009-09-06 Thread Dave Keck
To enable zombies and run your app: 1. Open terminal 2. export NSZombieEnabled=YES 3. /path/to/program.app/Contents/MacOS/program ... and stdout will of course go to the terminal window. Or, if the user is more technically apt, #3 can be 'gdb ', 'run', and when it crashes, 'bt' to get a backtrac

Re: NSString width

2009-09-06 Thread Dave Keck
> -[NSString boundingRectWithSize:...] might do this, especially with the > NSStringDrawingUsesDeviceMetrics flag ("Uses image glyph bounds instead of > typographic bounds"). Indeed. When I tried that method in the past, I got it working half-way with italicized text (the width was correct, but th

Re: How to stop NSImage from resizing while calling 'drawInRect' ?

2009-09-06 Thread Dave Keck
I'm not clear on which method is giving you issues, -drawInRect: or -drawAtPoint:? If it's -drawAtPoint: then it sounds like you may be hitting a bug in the frameworks on Leopard: http://developer.apple.com/mac/library/releasenotes/Cocoa/AppKit.html, search for "NSImage: Breaking change to drawAtPo

Re: Code Signing

2009-09-06 Thread Dave Keck
These files are certainly meant to be there. (If you happen to look in the bundles of any number of the standard Mac apps, these two resources are present.) Signing your code should happen at the very last stage of development; deleting something from your bundle after it's been signed is wrong. Y

Re: Should we release a CGImage created from NSBitmapImageRep ?

2009-09-06 Thread Dave Keck
>From the docs on -CGImage "Returns an autoreleased CGImage object (an opaque type) from the receiver’s current bitmap data." ... if you expect it to stick around, you need to retain it. Otherwise, you needn't do anything: you shouldn't CGImageRelease() it, because you don't own it. _

Re: NSString width

2009-09-06 Thread Dave Keck
> Also, keep in mind that character shapes may stick out of either edge by a > few pixels, especially with italics or script fonts. It's usually safest to > pad your bounding box by some fraction of the point-size. I've noticed this too. If you need the absolute precise pixel-size of some text, th

Re: NSString width

2009-09-05 Thread Dave Keck
http://lists.apple.com/archives/Cocoa-dev/2001/Nov/msg01347.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com H

Re: Termination notifications in foundation tool?

2009-09-04 Thread Dave Keck
> What I've done in the past is install a signal handler which tells the OS to > ignore the signal, but also schedules a future callback on the main thread > (via the runloop) that will then cleanly shut down the process. You probably > want to catch the signals generated by Ctrl-C or a 'kill' comm

Re: Custom Window not receiving "full" shadow

2009-09-04 Thread Dave Keck
> However, at least in my attempts, this did not seem to change my shadow, > regardless the value I passed in. It only appears to affect borderless windows; I just tested with a normal, titled window and it didn't change at all. But with borderless windows, it seems to toggle between two shadow s

Re: Custom Window not receiving "full" shadow

2009-09-04 Thread Dave Keck
I seem to recall that the opacity of the window affects the intensity of its shadow. Is your borderless window partially transparent? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the l

Re: NSTask flaky about posting terminate notification, in 10.6

2009-09-02 Thread Dave Keck
In the past I've also had some issues with NSTask, its 'isRunning' property and NSTaskDidTerminateNotification, albeit on 10.5. Here's two notes based on what I've experienced: o Recently I've found myself rolling my own solutions to problems such as yours, in order to guarantee its level of robus

Re: Finder contextual menu plugin 10.6

2009-09-02 Thread Dave Keck
http://www.cocoabuilder.com/archive/message/cocoa/2009/8/20/243101 http://lists.apple.com/archives/cocoa-dev/2009/Sep/msg00055.html ...etc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to

Re: Drawing over a transparent background

2009-09-01 Thread Dave Keck
For the record... It's considered best practice to limit your drawRect: methods to strictly drawing. Often it's handy to take advantage of drawRect: for testing, but in production code, my original suggestion isn't a good idea. 8) In the past I've seen some nasty misuses of drawRect: (setting the

Re: Drawing over a transparent background

2009-09-01 Thread Dave Keck
> Probably wherever you do the -setNeedsDisplay: for the view would be about > right... ;-) Unfortunately that's not a good place either - the window's shadow needs to be invalidated after the drawing actually occurs, not just when the dirty flag is set. Instead of -setNeedsDisplay:, I think you

Re: Drawing over a transparent background

2009-09-01 Thread Dave Keck
I believe you need to tell the window to invalidate its shadow. The end of ClockView's drawRect: is a bad place to do it, but as a proof of concept: - (void)drawRect: (NSRect)rect { ... lots of drawing code ... [[self window] invalidateShadow]; }

Re: Cross-user and cross-process shared settings

2009-08-26 Thread Dave Keck
> I've tried reading and writing an XML file directly, and I can get this to > work fine with multiple threads (via a simple NSLock), but when I attempt to > apply an O_EXLOCK to the file to prevent one process from writing to the > file while the other is, but it doesn't seem to be working. How d

Re: Bindings & Reverting Properties

2009-08-23 Thread Dave Keck
For the archives... The cleanest way I've found to get around my problem is best illustrated with some example code: = - (void)setHappy: (BOOL)newHappy { BOOL oldHappy = happy; happy = newHappy; if (![self save]) { // Do the revert now happy = o

Re: Bindings & Reverting Properties

2009-08-22 Thread Dave Keck
> not the correct effect. Attempting to nest willChange/didChange is a Bad > Idea because KVO notifications aren't nestable.) Is that documented? I would have thought that a nested willChange/didChange pair would have simply been ignored. > The immediate problem here is the presence of willChange

Re: Bindings & Reverting Properties

2009-08-22 Thread Dave Keck
> What led you to believe you needed to call the setter recursively? All you > need is: The only reason I did that was to show that the correct KVO notifications would be invoked by reverting the happy property from within the setter. It was a gross oversimplification, and I'm sorry. :) I realize

Re: Bindings & Reverting Properties

2009-08-22 Thread Dave Keck
>  Someone has to say it: Why?! :-) > >  I can't imagine any possible reason why any design should make it possible > for prefs saving to fail. Just because I can't imagine it doesn't make it > impossible, but it sounds very, very wrong. Well it seems my attempt to over-simplify the situation has

Re: persistentDomainNames

2009-08-21 Thread Dave Keck
> i have come across this method in NSUserDefaults and it appears to be a list of identifiers located on the current system. my question is if an app is deleted does its identifier eventually get removed from the persistentDomainNames list? Not unless your app's preferences file is deleted, and t

Bindings & Reverting Properties

2009-08-21 Thread Dave Keck
Hey list, I've implemented a custom bindings-compatible preferences controller object - let's call it MyPrefsController. It's similar to NSUserDefaultsController, but has lots of different functionality, and inherits directly from NSObject. As the user is changing the preferences in the UI, the p

Re: Authorization Question (Possibly a simple POSIX question?)

2009-08-20 Thread Dave Keck
File descriptors can be passed between processes using the sendmsg() API. If you have further questions about that, I'd suggest taking this question to darwin-dev. Here's some links: http://devworld.apple.com/qa/qa2007/qa1541.html http://topiks.org/mac-os-x/0321278542/ch09lev1sec11.html

Re: looking for System APIs for load monitoring

2009-08-17 Thread Dave Keck
> P.S.: My apologies if this question is not exactly Cocoa-related... You're probably better off taking this to darwin-dev. There was also a discussion related to this a few weeks ago on darwin-kernel: http://lists.apple.com/archives/darwin-kernel/2009/Jul/msg00080.html __

Re: Aqua animations drawing from separate thread

2009-08-14 Thread Dave Keck
Before your post, I knew that some AppKit drawing was done in secondary threads, but it never occurred to me that this could cause one's own NSView subclasses to be drawn in a separate thread, too. Presumably, if one's custom drawRect: method can be called in a separate thread due to a pulsing NSB

Re: Releasing ivars in -didTurnIntoFault. Should set to nil?

2009-08-12 Thread Dave Keck
> > >Now I understand that if nilling an instance variable after releasing > >it is done in -dealloc, it is papering over other memory management > >problems and is therefore bad programming practice. But I believe > >that this practice is OK in -didTurnIntoFault because, particularly > >when Undo

Re: Trouble with event taps...

2009-08-10 Thread Dave Keck
> >Event taps receive key up and key down events if one of the following > conditions is true: The current process is running as the root user. Access > for assistive devices is enabled. Woops, I forgot that you said you enabled access for assistive device. I just made a quick test project an

Re: Trouble with event taps...

2009-08-10 Thread Dave Keck
> James is exactly right, you're releasing the Event Tap before you enable it. > You should not release the event tap if you want to use it, it needs to hang > around for as long as you need it. It's not mentioned in the docs, but the CFRunLoopSource created by the call to CFMachPortCreateRunLoopS

Re: Trouble with event taps...

2009-08-10 Thread Dave Keck
> also show that no bits in the eventMask are cleared away.  Also, I do have > 'Enable Assistive Devices' checked (or else I wouldn't even get the mouse > events I'd imagine), so I don't think thats the problem. I seem to remember a discrepancy between the documentation on event taps, and what act

Re: [myNSWindow setDocumentEdited:dirtyB] fail ??

2009-08-07 Thread Dave Keck
Works for me: http://themha.com/bfegewfvd.zip So the obvious things to check: 1. Is myNSWindow nil, or the wrong window? 2. Is myNSWindow an NSWindow, or a subclass that might mess with this behavior? 3. Is setDocumentEdited: being called from more than one place? Break on setDocumentEdited: and

Re: Garbage Collection, Core Foundation, and toll-free bridging

2009-08-05 Thread Dave Keck
> Is that correct? Yes. A note though: since you're using NSMakeCollectable() (instead of CFMakeCollectable()), the cast to (NSDictionary *) is unnecessary - which is one of the main benefits of using the NS* version. ___ Cocoa-dev mailing list (Cocoa-d

Re: Main Event queue

2009-08-04 Thread Dave Keck
> (active filter) and after (passive filter) they're handled by the Sorry - that should read 'passive listener', meaning you can either actively wait for and manipulate events as they occur, or you can relax and wait for events to be reported after they've already been dealt with. Of course it sou

Re: Main Event queue

2009-08-04 Thread Dave Keck
> Will this enable me to trap "drag begin" "drag end" a window moving around > messages ? Event taps allow you to intercept, block, and manipulate events before (active filter) and after (passive filter) they're handled by the window server. My limited experience with them suggests that, yes, you

Re: Main Event queue

2009-08-04 Thread Dave Keck
It sounds like an event tap might help: http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventTapCreate http://prefabsoftware.com/eventtapstestbench/ ___ Cocoa-dev mailing lis

Re: Memory efficient way to get image metadata?

2009-08-03 Thread Dave Keck
> P.S. I very rarely use the C interfaces, do I have to also run CFRelease on > the result of the CGImageSourceCopyProperties call? Yes, you should. See 'The Create Rule': http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/

Re: NSURL fileURLWithPath doesn't produce a valid URL

2009-07-31 Thread Dave Keck
I'm confused: NSLog(@"%@", CFURLCreateStringByAddingPercentEscapes(nil, CFSTR("http://www.example.com?a+b & c = d"), nil, CFSTR("+=&"), kCFStringEncodingUTF8)); That doesn't do what you want? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Plea

Re: NSURL fileURLWithPath doesn't produce a valid URL

2009-07-30 Thread Dave Keck
Check out CFURLCreateStringByAddingPercentEscapes(), and note that CFURL is toll-free bridged with NSURL. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators

Re: Listening to Eject command

2009-07-29 Thread Dave Keck
I believe you can use even taps for this. Check out: http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventTapCreate ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Pl

Re: NSRulerView

2009-07-28 Thread Dave Keck
Hmm, us Americans spell it 'centimeter,' and according to the mentioned docs, NSRulerView does too. The docs also say it supports four different units by default (in, cm, pt, pc). Not sure what 'default' means in this case, but I'd assume it means calling +registerUnitWithName:... is redundant for

Re: NSScrollView Not Updating

2009-07-26 Thread Dave Keck
> seems to come down.  Is there some way to stop this from happening, in other > words, is there a way to "nail" an element in place. As Kyle suggested: http://devworld.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/WorkingWithAViewHierarchy.html "Repositioning

Re: How to use NSTimer correctly?

2009-07-25 Thread Dave Keck
First off, your object's -dealloc is never going to get called, because NSTimers retain their targets. (If your -dealloc is getting called, then you've got some memory management issues.) A breakpoint or an NSLog in -dealloc will tell you if it's getting called. > I'm not sure, if I must invalidat

Re: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Dave Keck
>> The notifications don't cross threads; they are delivered in the thread >> where they are posted. > > Yes, I understand that.  There must be some quirk that allows it to work > when doing an NSTask Just a tidbit - I don't think there's any quirks involved. The general idea is this: NSTask creat

Re: missing vertical scroll bar

2009-07-18 Thread Dave Keck
The topic of creating a Cocoa app without using IB has come up many times since I've been on this list, and the general opinion is you should always use IB unless you've got a really good reason not to. IB's not a toy, it doesn't make you any less of a programmer, it's not going anywhere, and it's

Re: Process crash while using NSURLConnection

2009-07-16 Thread Dave Keck
Yeah, the NSURLConnection docs aren't too heavy on details when it comes to threads, and what it does say about its threading behavior seems purely consequential to the fact that NSURLConnection relies on NS/CFRunLoop facilities, rather than NSUC implementing its own thread-safe logic. So from the

Re: Creating methods with variable length arguments terminated by nil

2009-07-16 Thread Dave Keck
The other night I spent about three hours trying to figure out why some code I had was behaving so strangely. It got to the point where I was convinced I found a bug in gcc - but as always, it was the pilot at fault. It turns out I forgot to terminate several of my variable-argument lists with a ni

Re: How to prevent NSTableView from reordering rows when clicking at a header cell?

2009-07-12 Thread Dave Keck
You can configure this in IB. Put IB in the list-view mode (click the center button of the 3-part button in the upper-left of the project window). Find and select your table view in the list, and uncheck 'Reordering' and perhaps 'Column' in the inspector. ___

Re: Why Applespell.service fail to launch?

2009-07-02 Thread Dave Keck
This code works just fine for me: NSLog(@"%@", NSStringFromRange([[NSSpellChecker sharedSpellChecker] checkSpellingOfString: @"hello, hwo are you today?" startingAt: 0])); Which prints '{7, 3}', as expected. I'll go out on a limb and guess that you're trying to access the spell checker from a

Re: How can I get rid of this message?

2009-07-01 Thread Dave Keck
'NutArray' must be declared as an NSMutableArray to respond to -addObject. NSArray is immutable, and thus doesn't respond to -addObject:. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to t

Re: Programmatically adding to one big Finder selection ?

2009-06-30 Thread Dave Keck
I'd imagine the easiest way to do this is using an AppleScript, which can be embedded in your app using the NSAppleScript class. But I've got a whole lot of PTSD towards AppleScript, so if it were me, I would deal with the AppeEvents directly, much as it's done here: http://developer.apple.com/do

Re: Load File Faster.

2009-06-29 Thread Dave Keck
> Don't abuse property lists; if you need a database, use a database. Indeed. And if you can/aren't already, use a binary plist. And load the data in a background thread, to keep the UI snappy. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Ple

Re: linking error

2009-06-25 Thread Dave Keck
The link error is pretty self-explanatory. To solve issues like this, I'd first change the header like so: extern NSString *const someString; and create a SharedDefs.m: NSString *const someString = @"halla"; This way, any object file can reference someString, but only one object file wi

Re: Amount of Arguments per Method

2009-06-22 Thread Dave Keck
> clearly simplicity is important, but i'd like to know if there is a > limit for the amount of arguments which a method can handle? The C99 standard states that conforming compilers must support at least 127 function arguments. I don't know if GCC enforces a limit above this, but if it doesn't, t

Re: File-picker dialog?

2009-06-18 Thread Dave Keck
NSOpenPanel is what you're looking for. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update yo

Re: "Leaks" utility

2009-06-12 Thread Dave Keck
In Xcode: in the left column, under the "Executables" disclosure group, double-click your executable. Click the 'Arguments' tab at the top, and in the bottom section of that window, you can set environment variables for when your app is launched. ___ Coc

Re: Instruments and over released objects

2009-06-09 Thread Dave Keck
Personally, I've found zombies to be perfect in tracking down over-releases. Check out 'NSZombieEnabled'. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators

Re: launchd detecting when an application is running

2009-06-03 Thread Dave Keck
Your question is unclear and doesn't make much sense. Please give lots of clarification, and consider posting your question on a list where it's more on-topic, such as darwin-dev or launchd-dev (over at macosforge). David ___ Cocoa-dev mailing list (Co

Re: Send Keyboard Events

2009-05-28 Thread Dave Keck
Check out CGPostKeyboardEvent. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscr

Re: Fixing logged error that doesn't throw exception

2009-05-27 Thread Dave Keck
I see this error at least several times a week. Searching through this week's logs from my work computer: ibtool[6341]: -[NSConcreteAttributedString initWithString:] called with nil string argument... mdworker[422]: -[NSConcreteAttributedString initWithString:] called with nil string argument...

Re: Abstract class with single subclass

2009-05-27 Thread Dave Keck
> Actually, I accidently used [self class] in a class method two weeks ago, > and it was causing a crash. I forget the circumstances, but when I caught > that I was using [self class] and changed it to self, everything worked > fine. So I don't know what the difference is, but there apparently is a

Re: Filling a Bezier path with a texture

2009-05-26 Thread Dave Keck
I'd do something that would look vaguely like this: NSColor *color = [NSColor colorWithPatternImage: patternImage]; [[NSGraphicsContext currentContext] saveGraphicsState]; [path addClip]; [color set]; NSRectFill([self bounds]); [[NSGraphicsContext currentContext] restoreGraphicsState]; Disclaimer

Re: which temp dir to use?

2009-05-25 Thread Dave Keck
> It does? Last I checked, AEWP() used a temp file on disk to pass its > AuthorizationRef to the child process. Pipes, anyone? Hah. I wonder what temp directory it uses? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin re

Re: Removing delay for a menu in NSSegmentedControl?

2009-05-25 Thread Dave Keck
> Right now, there is about about a 1-second delay after a click on a > segment before its menu will appear. > > Is there a way to remove this delay in bringing up a menu attached to a > segment? This isn't typical - if you create a new project and just drop a NSSC in a window, you'll see there's

Re: NSScrollView, NSTableView and NSSplitView Glitch

2009-05-24 Thread Dave Keck
Nice. I spent an hour or two fiddling with your test project and eventually gave up. Good to see you solved it. David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact th

Re: which temp dir to use?

2009-05-24 Thread Dave Keck
> 1. Non-privileged process A running as user Alice creates a file > called /tmp/ipc. > 2. A signals to privileged process B, running as root, that the file exists. > 3. Malevolent process C, running as user Eve, notices the file, > unlinks it (which it can do due to the permissions on /tmp) and >

Re: which temp dir to use?

2009-05-24 Thread Dave Keck
I use /tmp. Works great for me - I use it to save temporary files that another privileged process then moves to a permanent location. Launchd uses it too, along with a host of other things. But yeah, where you put your temporary files really depends on the context and who needs to see the them. D

Re: NSScrollView, NSTableView and NSSplitView Glitch

2009-05-23 Thread Dave Keck
Hello, I would try creating a subclass of NSScrollView, and figure out under what conditions the NSScrollView feels that it needs to display the vertical scroller. Perhaps the solution is as simple as overriding -hasVerticalScroller to always return NO. So in your NSScrollView subclass, I would st

Re: CGImageSourceCreateWithData

2009-05-23 Thread Dave Keck
> I have no idea where this is coming from, none of my classes appear to call > any methods related to this. What issue would cause this error? Try setting a breakpoint in CGImageSourceCreateWithData()... ___ Cocoa-dev mailing list (Cocoa-dev@lists.appl

Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)

2009-05-22 Thread Dave Keck
> It would be great if we could get a reason as to why it seems to always > return NO. My guess would be that there could be a significant performance > overhead using the KVO mechanism for every layer's property? That was my first thought, too. But after thinking about it, it's my understanding t

Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)

2009-05-21 Thread Dave Keck
Hello, A few days ago I was having this same issue. The reason KVO doesn't work out-of-the-box with CALayer subclasses, I believe, is because CALayer overrides +automaticallyNotifiesObserversForKey: to return NO. My solution was to override +aNOFK: in my custom subclass to return YES for my custom

Re: Most efficient way of measuring text

2009-05-12 Thread Dave Keck
> text rects. Has anyone come up with a very fast way to estimate the size of > some text, more importantly the vertical size given a width. You didn't mention that you tried NSAttributedString (specifically, its -size method.) Does it suit your needs, or is it what you consider too slow? David _

Re: Discussion on how to draw text like that seen in toolbars

2009-05-04 Thread Dave Keck
While I'm not familiar with the original discussion, I will say that the effect you're going for can easily be created using a shadow. If it doesn't look right, the values you're using to create the shadow probably need tweaking. For the recessed look, I use a shadow offset of (0.0, 1.1) or (0.0, -

Re: sheets

2009-05-04 Thread Dave Keck
Check out NSAlert, specifically +alertWithMessageText:... and -beginSheetModalForWindow:... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-a

Re: Nested AutoRelease Pools Crash

2009-04-26 Thread Dave Keck
> - (void)threadMethod:(id)anObject > { >   NSAutoreleasePool* outterPool = [[NSAutoreleasePool alloc] init]; > >   NSDictionary*    userDefaults = [NSUserDefaults standardUserDefaults] >   importantValue = [[userDefaults objectForKey:@"myKey"] boolValue]; +standardUserDefaults don't return no dic

Re: Coca equivalent to NMInstall?

2009-04-26 Thread Dave Keck
> It's not Cocoa, but CFUserNotificiation is probably the closest in spirit to > NMInstall.  I don't know if the notification dialog persists if your process > exits. It does. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post ad

Re: Fill box with repeating text

2009-04-24 Thread Dave Keck
> Where does this go as it is drawing the image, not the text? The image is > drawn with a RectFill call?? Ah, sorry. I meant to say: NSRectFillUsingOperation(rect, NSCompositeSourceOver); Note that point here is that however the image is finally drawn, you have to make sure you're drawing it us

Re: Fill box with repeating text

2009-04-24 Thread Dave Keck
> Makes the text transparent, but I can't seem to make the background of the > NSImage transparent. I want to end up with white text on a transparent > background, but [[NSImage alloc] initWithSize:[theString size]] seems to set > the background to solid white. This is because you're drawing the i

Re: Fill box with repeating text

2009-04-24 Thread Dave Keck
There are several ways to accomplish this. (I'll note that you can get the size of an attributed string using its -size method.) Option 1: Create an NSImage with the size returned from the attributed string. Draw the attributed string into the image. Create an NSColor pattern from the image, usin

Re: ObjectAlloc and objects that should have been released

2009-04-23 Thread Dave Keck
I don't have an answer for you, but I'd like to mention that I've also experienced some strange issues with the ObjectAlloc tool. Last night I was seeing an NSWindow that was released to the point that it would have a retain count of -10 and I'm not sure how thats possible. It seems, to me at least

Re: NSOpenPanel listing .app's and Mac OS X executables

2009-04-22 Thread Dave Keck
- (void)setAllowedFileTypes:(NSArray *)types ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Upda

Re: Get the name of the method that called a method

2009-04-21 Thread Dave Keck
Hey, The first thing that comes to mind is throwing an exception, catching it, then accessing the NSException's -callStackReturnAddresses. From there, you'll need to turn the addresses into symbol names. I googled it a little bit and found these references: http://developer.apple.com/documentatio

Safe Signal Handling from the Run Loop

2009-04-19 Thread Dave Keck
Hey list, Earlier today I spent awhile trying to re-find some sample code that I discovered awhile ago. I eventually found it, and thought I would mention it here in hopes that it'll help someone in the future. It allows you to handle signals safely within your app's runloop, rather than trying t

Re: static vs non-static. Recommendation needed.

2009-04-13 Thread Dave Keck
> Is it all right to init an object just to dealloc it in the next line (or > create an autorelease object using a convenience method for that matter)? I > mean, if i made it non-static, i would have something like this in the class > that uses it: > > DatabaseCreator *dbc = [DatabaseCreator creato

Re: Build Settings for Release: App/Library is bloated

2009-04-12 Thread Dave Keck
You might be compiling for four architectures - PPC 32/64, Intel 32/64. Compiling for each of these can of course greatly increase your app's size, since you're essentially combining four versions of your app into one binary file. Check your release target to see what architectures it's compiling f

Re: NSString camel case

2009-04-11 Thread Dave Keck
Cocoa has always been lacking in the RegEx department (at least the 'built-in' Cocoa classes, there's a bunch of third-party regex frameworks), especially when compared to languages like Python. Since your situation isn't very complex, I would just use the bread-n-butter string APIs: NSString *ori

Re: Screen Savers

2009-04-10 Thread Dave Keck
> +bundleWithIdentifier: is also available if there's no obviously suitable > class to use with +bundleForClass:. ... and according to the docs: +bundleWithIdentifier: This method is typically used by frameworks and plug-ins to locate their own bundle at runtime. This method may be somewhat more

Re: Screen Savers

2009-04-10 Thread Dave Keck
To get the path to a bundle that's loaded inside an arbitrary process, I create a stub subclass of NSObject (let's call it MyStubClass) and simply call [NSBundle bundleForClass: [MyStubClass class]]; This technique is the most straightforward way I know of to accomplish what you're looking for - i

Re: NSLocalizedStringFromTableInBundle Questions

2009-04-10 Thread Dave Keck
> If I do a NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];  it > won't compile. I'm going to go out on a limb and say you're using the above line in a plain-C function rather than an Objective-C class. Is this correct? 'self' is meaningless/undefined outside of the Objective-C clas

Re: NSSegmentControl Image Scaling Problem

2009-04-10 Thread Dave Keck
You probably need to set the image scaling on the segments added at runtime. Use NSSegmentedControl's -setImageScaling: forSegment:. The values you can use are listed in NSCell.h: NSImageScaleProportionallyDown = 0, // Scale image down if it is too large for destination. Preserve aspect ratio

Re: Change view on resize

2009-04-10 Thread Dave Keck
Wow, look at that. -setShowsResizeIndicator:. And it's been there since 10.0, dunno how I missed it. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at co

Re: Send click to window

2009-04-09 Thread Dave Keck
I finally got clicks forwarding to another process. I made an example project, available here: http://www.docdave.com/clicktest.zip NOTE: You have to setup the project first - in the Globals.h file, define 'PID' to the process that you want clicks to be forwarded to, and 'WID' to the window ID of

Re: Send click to window

2009-04-09 Thread Dave Keck
> There are actually 2 NSEvent methods that aren't in my local docs here at > work, but are in the headers and on developer.apple.com: > > + (NSEvent *)eventWithCGEvent:(CGEventRef)cgEvent; > - (CGEventRef)CGEvent; Woops :) That could be why I wasn't able to send click events to other apps' window

Re: Change view on resize

2009-04-09 Thread Dave Keck
> How do I enable the resize button without enabling drag-resize? > - Do I use windowWillResize:toSize: to be notified?  How am I notified of > the user clicking clicking the button? To satisfy both these requirements, I would first disable window resizing for your window in IB. Then, somewhere in

Re: Send click to window

2009-04-09 Thread Dave Keck
> I quickly tested CGEventPostToPSN() and was able to click Safari's > menu bar from my test app, but was not able to click inside Safari's. Sorry, that was meant to say: ...but was not able to click inside Safari's windows. ___ Cocoa-dev mailing list

Re: Send click to window

2009-04-09 Thread Dave Keck
> Is it possible to send a simulated mouse click to a specific window, > overlapped by others? CGEventPostToPSN() is what you want - but unfortunately it looks like a little hackery will be involved to get it working. NSEvent has a 'windowNumber' property associated with it, but it doesn't look li

<    1   2   3   4   >