Re: 30x faster JSON date parsing

2013-09-09 Thread Dave Keck
I’m not sure if you meant that ironically, but it’s absolutely not premature. I’ve run into major NSDateFormatter bottlenecks — as in “hm, over half the time to open this file is spent inside NSDateFormatter” — at least twice, and the author of the blog post I linked to says that he also

Re: How to use NSManagedObjectContext, NSManagedObjectModel, NSEntityDescription, NSManagedObject

2013-02-15 Thread Dave Keck
NSManagedObjectContext, NSManagedObjectModel, NSEntityDescription, NSManagedObject I want to use these classes in my app but I don't want to use it in Core Data. These classes *are* Core Data; I'm afraid you're not making much sense. ___ Cocoa-dev

Re: new to Cocoa/Objective-c: many points of confusion

2013-02-03 Thread Dave Keck
*delegates: my understanding is that these take the place of subclasses (though why this is useful is beyond me), overriding methods they are designed to handle rather than letting the base class take those methods. However, I not only don't see why this is so great, but I don't understand

Re: Mysterious crash report

2012-11-14 Thread Dave Keck
Apparently this occurred when cancelling a document save, though it might have nothing directly to do with that. At the time of the crash, NSToolbar was doing something on the main thread... Since it was during document save and there's mention of XPC in the stack trace, I suspect the crash

Re: static void declaration in apple example code

2012-10-12 Thread Dave Keck
staticvoid *AVSPPlayerItemStatusContext = AVSPPlayerItemStatusContext; This declares a unique pointer, whose value is defined as the address in memory where the pointer lives. This technique can be useful when you need a value that's reasonably assured to be unique -- i.e., this technique

Re: Self contained command line tool

2012-10-12 Thread Dave Keck
I would create a new Cocoa application using Xcode's template, delete all the .m files (except main.m), and put your code in main.m. You should be able to delete most of the resources as well, such as MainMenu.xib and InfoPlist.strings. Your app will of course not have any interface or menu

Re: Proper KVO with NSTreeController + NSOutlineView

2012-09-28 Thread Dave Keck
I'd like to observe a notification when a user edits (renames) an item in the outline view that tells me the old and new values. I'm getting notifications, but the old and new values are always null. For what it's worth, I'm currently observing the content.name key path of the

Re: Is QuickLook implemented upon CGImage or CGImageSource under the hood?

2012-09-07 Thread Dave Keck
In my experience I've found that QLThumbnailImageCreate() significantly outperforms CGImageSourceCreateThumbnailAtIndex(). I speculate that this is because QLThumbnailImageCreate() talks to a daemon process that keeps thumbnails cached in memory even after your process exits, rather than

NSView -backingAlignedRect:

2012-08-24 Thread Dave Keck
Regarding the NSRect returned from -backingAlignedRect:options:, the NSView documentation states: The rectangle is in window coordinates. Is this a documentation error? I would expect the returned rect to be in local view coordinates. ___

Re: 10.8 copiesOnScroll, -setNeedsDisplayInRect: ignored during scrolling

2012-08-06 Thread Dave Keck
Right, so what you actually want to do is change how you’re messaging the main thread. Use something like -performSelectorOnMainThread:withObject:waitUntilDone:modes: so you can specify NSDefaultRunLoopMode and NSScrollEventCoallescing. NSScrollEventCoallescing is a private run loop mode

Re: 10.8 copiesOnScroll, -setNeedsDisplayInRect: ignored during scrolling

2012-08-06 Thread Dave Keck
But Mike is still right; you're probably better served by using -performSelectorOnMainThread::: rather than waking the run loop up yourself. I tend to disagree -- invoking CFRunLoopPerformBlock() and CFRunLoopWakeUp() is likely more performant since they're at the CF level (which

10.8 copiesOnScroll, -setNeedsDisplayInRect: ignored during scrolling

2012-08-04 Thread Dave Keck
I'm working on a scrollable grid view and noticed that its appearance during scrolling has regressed since installing 10.8. This grid view loads content in the background and calls -setNeedsDisplayInRect: (thread-safely) as content becomes available. With copy-on-scroll enabled,

Re: 10.8 copiesOnScroll, -setNeedsDisplayInRect: ignored during scrolling

2012-08-04 Thread Dave Keck
Hi Quincey, For the latter, it seems hardly surprising that the content wouldn't appear until you stop scrolling, since by setting the copy-on-scroll flag you've promised that the old view contents don't change during scrolling. The docs don't say one way or another, but on both 10.7 and

Re: 10.8 copiesOnScroll, -setNeedsDisplayInRect: ignored during scrolling

2012-08-04 Thread Dave Keck
I'm unsure of the wisdom of this approach. Presumably the scroll view is intentionally blocking the runloop, and thus assuming that the runloop will not fire its event sources until after the scrolling is complete. By waking up the runloop, you're violating that assumption and could be

-layout not called after invoking -setNeedsLayout:YES

2012-07-10 Thread Dave Keck
I'm overriding NSView's -layout method to arrange a grid of subviews. I call [gridView setNeedsLayout: YES] when a new subview is added, which usually results in -layout being called on gridView, but intermittently -layout is not called (resulting in incorrect subview positioning.) In contrast, I

ARC and CFType release callback

2012-06-19 Thread Dave Keck
I have a CFType (specifically a CGPattern) that uses a release callback to free resources, and the void* pointer passed to the callback is the object to be released. What's the correct way to release this void* pointer (that's really an NSObject subclass) under ARC? Casting it using

Re: ARC and CFType release callback

2012-06-19 Thread Dave Keck
   Clean up the void* context with CFRelease(context) or (ObjectType *)CFBridgingRelease(context) I see -- I was under the impression that CFBridgingRetain/Release was meant for converting to/from CFTypes rather than arbitrary pointers, but it works as expected. Thanks! David

Re: ARC and CFType release callback

2012-06-19 Thread Dave Keck
Once you have a CFTypeRef via CFBridgingRetain(), ARC doesn't care what you do with it. Convert it to and from uintptr_t, pass it through a void*, send it around via IPC, whatever. That makes sense. I'm also looking for a pattern similar to this RR code, so that I can leave out explicit

Re: OSAtomic built-in operations

2012-05-06 Thread Dave Keck
   union {        int32_t s;        uint32_t u;    } atomicvar;    atomicvar.u = 0;    OSAtomicCompareAndSwap32(0, 1, atomicvar.s);    OSAtomicOr32Orig(0, atomicvar.u); I've seen this technique in other places. Why is that better than just casting pointer types? Like this: int32_t    

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Dave Keck
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; Running the runloop recursively in the default mode is almost always a bad idea; doing so triggers callouts that parent stack frames almost certainly weren't designed to handle when they occur from within the method you're writing. It's

Re: Unclear on -initWithBytesNoCopy:

2012-03-03 Thread Dave Keck
The documentation of -[NSData initWithBytesNoCopy:length:freeWhenDone:] and of -[NSString initWithBytesNoCopy:length:encoding:freeWhenDone:] is unclear about the case where freeWhenDone is NO. The data/string object then does not take ownership of the memory buffer, so the question is: How

Re: Unclear on -initWithBytesNoCopy:

2012-03-03 Thread Dave Keck
Hit send too soon... The documentation of -[NSData initWithBytesNoCopy:length:freeWhenDone:] and of -[NSString initWithBytesNoCopy:length:encoding:freeWhenDone:] is unclear about the case where freeWhenDone is NO. The data/string object then does not take ownership of the memory buffer, so

Re: Xcode - An Apple Embarrassment

2012-03-01 Thread Dave Keck
*No*. I've said it before (right here) and I'll say it again; this is *not* jumping to the documentation, and it is *not* doing what Xcode 3 did. It switches to the documentation window and it enters the double-clicked word into the search field, and it does the search, but it doesn't

Re: My runloop-based async code breaks with GCD

2012-02-17 Thread Dave Keck
The root of your problem seems to be your assumption that GCD runs the run loop. NSURLConnection case: the delegate methods aren't called because NSURLConnection machinery requires the run loop to be run, which GCD isn't going to do for you. (Calling -setDelegateQueue: fixes this because

Re: How to get the dispatch queue for the current thread's runloop?

2012-01-27 Thread Dave Keck
Hi Jens, My understanding is that dispatch queues are tied to threads that are managed by the system and are separate from run loops. It's therefore non-sensical to ask for a runloop's queue. Regardless though, I think a better solution for you is a category on NSTimer. I use something like the

Re: afterDelay not working?

2012-01-26 Thread Dave Keck
I imagine your run loop isn't being allowed to run in the default mode (NSDefaultRunLoopMode). I'd check this by pausing your program at the time that you would expect -endFlash to be called; your stack trace will might indicate that the run loop's being run recursively. Perhaps this occurring

Re: CFRunLoopObserver causes crash on NSView drag.

2011-10-22 Thread Dave Keck
I only glanced over the details of your problem, so forgive me if this is way off. I solved the memory ballooning issue in a background app by posting an NSApplicationDefined NSEvent (with zeros for all the arguments), which causes the NSApplication loop to return from -nextEventMatchingMask

Re: CALayer memory management [was: Tracking down CALayer problem in iTunes plug-in]

2011-08-01 Thread Dave Keck
I've narrowed this error down to a very simple test case. Could you post you test case? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at

Re: NSMapTable on iOS?

2011-07-08 Thread Dave Keck
Kind of surprised to discover that NSMapTable doesn’t exist on iOS (even the older procedural form of the API). I need a non-retaining dictionary — do I need to drop down to CFDictionary or is there some higher-level alternative? I was surprised by this too, but found the CFDictionary

Re: Dispatch queues and autorelease pools

2011-07-02 Thread Dave Keck
From http://developer.apple.com/library/mac/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html: Although GCD dispatch queues have their own autorelease pools, they make no guarantees as to when those pools are drained. However, if your

Re: DO independentConversationQueueing, invocation from callback

2011-06-26 Thread Dave Keck
I wrote a small test case that exhibits the problem: http://pastie.org/2124066 It can be compiled and run like this: killall -KILL dotest; gcc -framework Foundation dotest.m -o dotest; ./dotest When independentConversationQueueing is disabled (see EnableICQ()), ProcessC receives the

DO independentConversationQueueing, invocation from callback

2011-06-24 Thread Dave Keck
Hey list, I use independentConversationQueueing to make my DO invocations block, but doing so causes incorrect behavior in the following scenario: 1. ProcessA sends -handleMessage to ProcessB 2. ProcessB's -handleMessage executes, which sends -doSomething to ProcessC In Step 2, the DO

Re: Properly comparing file NSURLs for equality?

2011-05-27 Thread Dave Keck
What is the correct way to test if two NSURLs refer to the same file system object? I would lstat() the file paths and compare their inodes (st_ino) and residing device inodes (st_dev). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please

Re: Seeding random() randomly

2011-05-26 Thread Dave Keck
I'm using random(), but every time I run my app I get the same sequence, despite having this code in my app delegate's -appDidFinishLaunching method. Clearly I'm not seeding it right, though I can't see why - I get a different value for seed every time. What gives?        unsigned seed =

Re: Is a file open in another application?

2011-03-19 Thread Dave Keck
Is there a way for me to tell if a particular file is open in another application? The following thread offers one solution: http://www.cocoabuilder.com/archive/cocoa/288040-notification-of-file-system-modification-arrives-too-early.html which might be worth using if proc_listpidspath()

Re: Debugging a sleepless Mac

2011-03-16 Thread Dave Keck
Apart from user interactions, what other sorts of activity automatically prevent idle sleep? I seem to recall an issue where a program's logging was preventing sleep, which I believe was simply due to the file activity. fs_usage may help there. ___

Re: kqueue and kevent

2011-03-13 Thread Dave Keck
I have used kqueue and kevents for event triggering. However i am not sure if it is possible to send events to a kqueue? Googling didnt  helped. I was thinking as its kernel que and kernel notifies. Does it mean that users can not send events to a queue other than signals? The kernel is the

Re: Problem with garbage collection in server application

2011-01-22 Thread Dave Keck
I'm pretty sure I'm not leaking the memory with an unintended reference, as the datasets *are* collected (albeit not very quickly) after I run a set of five operations and the server returns to be waiting for user input.  I'm wondering if it could be because collection will not happen until

Re: Problem with garbage collection in server application

2011-01-22 Thread Dave Keck
I worked up a version of our app that uses retain/release style memory management, and was surprised to note that a similar thing was happening (although the memory use did not get as big).  Running a script that would send five sequential processing requests to the server, with a 'close

Re: Parental Controls altering binary

2011-01-16 Thread Dave Keck
From TN2206 (http://developer.apple.com/library/mac/#technotes/tn2007/tn2206.html): The Parental Controls, MCX, and Application Firewall subsystems in Leopard, when encountering an unsigned program, will ad hoc sign the program in order to track its identity from launch to launch. This will

Re: Troubleshooting CFMessagePort

2011-01-06 Thread Dave Keck
I don't see anything obviously wrong with your code after a cursory glance. I assume you're familiar with the bootstrap context issues mentioned in TN2083 and elsewhere? If you can post a complete example that exhibits the problem, I'd be happy to investigate further. However, consider using

Re: Troubleshooting CFMessagePort

2011-01-06 Thread Dave Keck
Is there any utility to maybe probe the Mach ports that my app has open?  I can't find anything like that. top(1) and Activity Monitor can list the number of ports a process has open, but I'm not aware of any utilities that go into any more detail. Oh, `sudo launchctl bstree` might also be

Re: Context in GCD source cancel handler?

2011-01-05 Thread Dave Keck
Q: When a context object is set with dispatch_set_context(), is it retained? Or do I need to retain it first, set it, and then in the cancel handler release it? The 'context' argument is not retained. You can infer this primarily by the declaration of dispatch_set_context(), and also the

Re: Synchronizing to screen refresh rate

2010-12-17 Thread Dave Keck
It sounds like CVDisplayLink might be of use? From CVDisplayLink.h: The main purpose of the CoreVideo DisplayLink API is to provide a worker thread to the VideoUnit subsystem that is clocked based on the refresh rate of a CGDirectDisplay device. ___

Re: App Will Not Terminate After Uncaught Excpetion

2010-12-16 Thread Dave Keck
Look up NSExceptionHandler. NSExceptionHandler (and NSSetUncaughtExceptionHandler for that matter) can't help because the exception is being caught by AppKit. Furthermore, the NSApplication subclass technique mentioned earlier won't work in all cases either, since some AppKit/Foundation wrap

Re: App Will Not Terminate After Uncaught Excpetion

2010-12-16 Thread Dave Keck
Presumably it is more functionally similar to: On my system, the exception is being caught from within -[NSApplication run]. So it would look like the implementation of -run shown here: http://cocoawithlove.com/2009/01/demystifying-nsapplication-by.html with a @try around the calls to

Re: assign property behaves differently from simple instance variable???

2010-12-14 Thread Dave Keck
Hmm, also, it appears that UIResponder has some undocumented methods -firstResponder and -_firstResponder, which your synthesized property would also interfere with. Doubtless. But how would I have discovered this? I would have implemented -firstResponder and set a breakpoint to see who was

Re: Image Processing

2010-12-12 Thread Dave Keck
See the CoreImage docs: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments

Re: NSUnarchiver / Data.archive Extract all Keys

2010-12-10 Thread Dave Keck
Note I no longer have the source code that saved this file, hence my desire to extract the keys information stored there. Have you tried opening your archive in Property List Editor or TextEdit? It's just a plist. ___ Cocoa-dev mailing list

Re: NSUnarchiver / Data.archive Extract all Keys

2010-12-10 Thread Dave Keck
yes, it's noise... Also it's not just one, they're save files for an old program I made - I'd like to be able to extract the data so I can save it in the format used for more recent versions NSPropertyListSerialization could probably help too. If Property List Editor can't parse it though

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
CFRunLoop 0x1a2ac80 [0xa032cec0]{locked = false, wakeup port = 0x5a03, stopped = false, current mode = (none), common modes = CFBasicHash 0x1a23f70 [0xa032cec0]{type = mutable set, count = 1, entries = 1 : CFString 0xa0321c48 [0xa032cec0]{contents = kCFRunLoopDefaultMode} } , common mode

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
Did you edit the above quoted output at all? First, I would expect a lot more information to be printed for the main run loop, and second, I would expect to see NSEventTrackingRunLoopMode and NSModalPanelRunLoopMode as part of the common modes set. That is, are you sure you entered: po

Re: iOS when is my app launched

2010-12-08 Thread Dave Keck
How do I find the date and time when my application launched? I've done this before on OS X, but it was a while ago and I've forgotten how. :) I'm not sure what you mean exactly, but [NSDate date] will return the current date/time. Tuck that instance in memory when your application launches

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
That was the output for $rdi at the CGRunLoopWakeUp breakpoint immediately after the call to performSelectorOnMainThread... Sorry, realized that after I sent. The output still isn't what I would expect though: on my system, the run loop supplied to CFRunLoopWakeUp() from within the

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
You are correct. They are two different things: Alright, does the following assertion fail when placed before the -performSelectorOnMainThread line? (Ignore the warning - using private APIs.) id a = (id)[[[NSThread mainThread] runLoop] getCFRunLoop]; id b = (id)CFRunLoopGetMain();

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
FYI, I do not create any run loops explicitly in my application That's good, because run loops can't be created explicitly. :) and can't think of anything I am doing which would create one implicitly. A run loop is automatically created for every thread that's spawned. (I believe this happens

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
So could this issue be something to do with the timing of the first time the threaded operation is run? I'd imagine it involves NSThread making an assumption about the initial invocation of one of its APIs, and the run loop that it expects to exist at the time of that invocation. Assuming your

Re: performSelectorOnMainThread fails second time through

2010-12-08 Thread Dave Keck
Hey, this sounds very familiar! http://lists.apple.com/archives/cocoa-dev/2010/Sep/msg00426.html That seems like a distinct issue. The problem Gideon is seeing is that [NSThread mainThread] holds a (private) reference to a run loop that isn't the main thread's run loop. Since

Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
Any ideas? Post your code! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your

Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
Some thoughts: 1. What happens if you specify a different object to receive the message? For example, try [NSApp performSelectorOnMainThread: @selector(terminate:) ... waitUntilDone: YES]. Does your app terminate? 2. Specify waitUntilDone: NO, and after the call to -performSelectorOnMainThread:,

Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
Also: a quick peek at the assembly of -performSelectorOnMainThread: reveals that it calls _CFExecutableLinkedOnOrAfter(). Presumably this is to modify its behavior based on what SDK your app links against; perhaps changing your Base SDK has an effect?

Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
Now I thought it would be interesting to try those calls before the thread was dispatched, and the terminate one worked, but the run loop stop didn't. I also tried the runloop stop one in my mini test application, and it didn't work there either, so am a bit suspicious of that. Should that

Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
3. Stop your program, and set a breakpoint on the -performSelectorOnMainThread line. Run your program again. When this breakpoint is hit, before continuing your program, set a breakpoint at CFRunLoopSourceSignal(). Continue your program. The CFRunLoopSourceSignal breakpoint should be hit

Re: Foundation vs Core Foundation

2010-11-29 Thread Dave Keck
Before I start down the wrong path: What is the difference between a Foundation tool and a Core Foundation tool? Primarily I will be needing to use TCP/IP sockets, file I/O, and multithreading, so is one a better fit than the other? I believe OSX calls this type of GUI-less background

Re: Help diagnosing networking/internet performance issues

2010-11-22 Thread Dave Keck
Perhaps the bandwidth has been limited using ipfw or a similar utility? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at

Re: Notification of CD-ROM inserted

2010-11-21 Thread Dave Keck
I'd use either NSWorkspaceDidMountNotification or DARegisterDiskAppearedCallback() of the DiskArbitration framework. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the

Re: Problem with redirecting stdout

2010-11-09 Thread Dave Keck
I think the problem is that the pipe buffer is not being flushed/read when it's full; when the pipe is full, the script interpreter then is blocked because it's waiting for the pipe to empty so that it can write. I don't fully understand the structure of your program, but indeed it sounds like

Re: Switching app type from background only to full UI, and back?

2010-11-06 Thread Dave Keck
I'm sure you're dreading this question, but can you elaborate on why you can't separate your processing code from your UI code? It sounds like you're mainly avoiding it due to the amount of work involved, but you also mentioned that there might be technical limitations; if you're able to elaborate

Re: Few binaries in one application's Bundle

2010-10-25 Thread Dave Keck
The problem is, when either one of binaries is started, no one else from this bundle can be launched. The bundle itself is LSUIElement=TRUE. I was wondering, if i could use some technique/non-evil hack to keep my appliations in a neat one bundle (counting that the user should be able to

DO over unnamed sockets

2010-10-23 Thread Dave Keck
Hey list, I'm attempting to use distributed objects over an unnamed socket pair created via socketpair(). I've tried every permutation of the following code that I can think of, but it always throws an exception when the client calls -rootProxy: http://pastie.org/pastes/1242749 Can DO work

Re: Multiple instances of [NSUserDefaults standardUserDefaults]

2010-10-23 Thread Dave Keck
Has anyone got any thoughts? I wouldn't be surprised if there's a separate NSUserDefaults instance for each thread. Regardless though, it's an implementation detail that shouldn't be relied on unless the docs guarantee certain behavior. Could you explain why you need to rely on NSUserDefaults

Re: Multiple instances of [NSUserDefaults standardUserDefaults]

2010-10-23 Thread Dave Keck
Well, I've got some code, which I presume used to work, which relies on observing a value in the user defaults. The observer isn't getting triggered, so I am guessing it is because they are separate instances. Both should be on the main thread. Are you observing an instance of

Re: DO over unnamed sockets

2010-10-23 Thread Dave Keck
You can verify this by breaking on connect() or using dtruss or the like.   It's actually getting ENOENT.  It appears be using getsockname() on the send port's socket to figure out where to connect, and that's giving a sockaddr_un with an empty sun_path. Moments after sending my original

Re: NSScanner Failing with EXC_BAD_ACCESS

2010-10-15 Thread Dave Keck
The problem is probably that theScannedString has never been initialize it. Always initialize when you declare, because otherwise your value could be nonsense and can't be logged. So, minimally, you'd say this: Good advice regarding initialization, but... NSString *theScannedString = nil;

Re: ivars and fundamental types

2010-10-11 Thread Dave Keck
Don't do that. object_getInstanceVariable() and object_setInstanceVariable() still assume the ivar is of an object pointer type. As the documentation and prototypes stand, one would think that object_getInstanceVariable() could be used like this: double *doublePointer = nil;

Re: ivars and fundamental types

2010-10-08 Thread Dave Keck
object_setIvar() takes type id. object_getInstanceVariable()? outValue: On return, contains a pointer to the value of the instance variable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator

Re: Let the runloop process its queue during a long operation

2010-10-07 Thread Dave Keck
But this is for Carbon application, isn't it? I have a cocoa one... No – NSRunLoop is built atop of CFRunLoop, just as many Foundation classes are built atop CoreFoundation classes. Carbon has nothing to do with it. Does this call operate with the core foundation run loop, bypassing cocoa's

Re: Let the runloop process its queue during a long operation

2010-10-06 Thread Dave Keck
Can i make a runloop run only one time through the queue, and then return back to processing of that big file? See CFRunLoopRunInMode(), specifically the returnAfterSourceHandled argument. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Re: Checking for nil-return

2010-10-05 Thread Dave Keck
Because it throws exceptions if anything bad happens at runtime (i.e out of memory, invalid parameters etc) If memory truly becomes exhausted (as opposed to attempting to allocate a huge object), you'll crash due to a stack overflow since the code path of throwing an exception allocates

Re: Continuously running daemon process CFConstantStringRefs build up over time

2010-10-01 Thread Dave Keck
Since you're writing a daemon, you'll need to handle autorelease-pool creation and draining manually (something that's normally handled by NSApplication in standard AppKit apps.) Perhaps objects are autoreleased and placed in the root autorelease pool (that you might be creating in main() or the

Re: Continuously running daemon process CFConstantStringRefs build up over time

2010-10-01 Thread Dave Keck
       CFStringRef hexStringRef = CFStringCreateWithFormat( NULL, NULL, CFSTR(%x), versionValue );   - Instruments is hi-lighting this line as an allocation. It sounds like you found the cause of your persisting string objects so the details of CFSTR is irrelevant, but to clarify anyway:

Re: NSTimer memory management

2010-09-22 Thread Dave Keck
Is this an over-release? timer = [ [NSTimer scheduledTimerWithTimeInterval: ...] retain]; ... [timer invalidate]; [timer release]; No, you're not over-releasing the timer. I've seen this pattern so many times I figured it was correct, although it doesn't seem to comply with the memory

Re: Scripting Bridge Strange Pauses

2010-09-16 Thread Dave Keck
Have you profiled the thread that's stopped/paused? What does its stack trace look like? Have you verified that the problem isn't that 'GEDitCOMII' isn't responding? Also, if you're not using GC, consider profiling your loop with and without each iteration allocating/releasing an autorelease

Re: Scripting Bridge Strange Pauses

2010-09-16 Thread Dave Keck
It is running on main thread. I am not sure how to profile. I tried Thread State in Instruments and it output data, but nothing unusual when the pause occurred. Is that the right tool? (Sorry, I meant 'sample' instead of 'profile.') When the loop gets hung up, pause the program in the Xcode

Re: delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?

2010-09-08 Thread Dave Keck
After the release of Snow Leopard, it seems that [iTunes isRunning] returns YES for a short while even after the application has quit (I believe this applies to all apps, not just iTunes, but I haven't confirmed this yet). As a result, my app would relaunch iTunes, assuming it was still

Re: delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?

2010-09-08 Thread Dave Keck
Anyway, I ended up using the Process Manager APIs to check whether the app in question was running before executing an AppleScript to issue commands to it. It's worth a try. But I'm afraid it will put a heavy load on the CPU for a timer firing every second, no? You'll have to profile it

Re: Folders and file system organization instead of just XCode

2010-09-06 Thread Dave Keck
2º Why most of projects that I found on the internet don't use folders or groups to separate classes (for example, controllers, views, categories and models). What is the good pratice for code organization? If somebody could point links or guidelines would help a lot. I think anyone would

Re: sharing file descriptors to an NSTask

2010-09-01 Thread Dave Keck
descriptors are open. On OS X, you could read the contents of /dev/fd/ to accomplish the same thing. It appears that NSTask uses the uglier getdbtablesize() loop though. Neat, I wasn't aware of /dev/fd. Are the necessary APIs async-signal-safe so they can be used between fork()/exec()?

Re: sharing file descriptors to an NSTask

2010-08-31 Thread Dave Keck
Indeed NSTask closes open descriptors in the child. I could have sworn this was documented somewhere, but I can't seem to find the relevant text at the moment. To get around this behavior (and other NSTask bugs and shortcomings), I chose to write my own NSTask equivalent. Alternatively, you could

Re: How to fastly get the active window's title?

2010-07-27 Thread Dave Keck
CGWindowListCreate() and CGWindowListCreateDescriptionFromArray() are probably your best bet, with the accessibility APIs being another option. Note that that UI controls are sometimes implemented as separate windows, but from the user's perspective they belong to a parent window; this is

Re: Screen pixels changed notification?

2010-07-26 Thread Dave Keck
You're probably interested in CGRegisterScreenRefreshCallback(). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Re: Flipping coordinate system of a CALayer

2010-07-16 Thread Dave Keck
The only workaround I was able to get working was to call a private AppKit method to fix up the layer geometry. Which is a no-no, and shouldn’t be done. Bad Kyle. No biscuit. Forgive me for raising such a taboo topic, but I've encountered situations where I had to choose between A) using a

Re: File descriptors not freed up without a -closeFile call

2010-06-23 Thread Dave Keck
 Ah, interesting.  I missed that in the docs.  It still seems bad to me that the file handle will actually dealloc without closing its associated file descriptor, but perhaps you are right that that is the documented behavior.  I'll just stop worrying about it and move on, then.  Thanks!

Re: Process executes an AppleScript, then disappears. Why/How?

2010-06-13 Thread Dave Keck
What might cause this process to exit?  Where can I look for clues? (I've been guessing for two hours, so any suggestion will be welcome.)  Does the system log the exit states of processes anywhere? I would attach to the process while it's executing (in Xcode, Run Attach to Process) and set

Re: Notification of file system modification arrives too early?

2010-05-31 Thread Dave Keck
Really ? I find the first comment in libproc.h pretty clear about it. If it was private in the strictest sense, the header wouldn't exist. Certainly since the header has existed since 10.5, Apple intends for someone to use it? ___ Cocoa-dev mailing

Re: Notification of file system modification arrives too early?

2010-05-30 Thread Dave Keck
Unfortunately you probably can’t do any better than that, since there’s no cheap way to find out if another process has the file open. proc_listpidspath() is meant for this, but it is indeed quite expensive. In my testing, it takes about a second to complete this call; furthermore, its status as

Re: Regarding MVC design pattern

2010-05-20 Thread Dave Keck
I'll give you a concrete example. We have an NSController-like class that lives in a framework. Its designated intializer is -initWithContent:. In one of our apps, we have a subclass of this whose initializer is -initWithDocument:, and which uses the document to figure out its content. It

Re: Regarding MVC design pattern

2010-05-20 Thread Dave Keck
You can get away with a lot of things if you don't care about writing subclass-tolerant code. But since I don't have a crystal ball, I don't write code which I know will require hacky isInitialized flags to be correct. I'm not a fan of isInitialized either, but even less enthralled by

Re: My program causes MacBook Pro to use NVidia graphics processor

2010-05-17 Thread Dave Keck
I'm in rather the opposite boat -- my app does NOT trigger the switch to NVIDIA, and my OpenGL calls fail (actually, it's more complicated that this as it's a screensaver and a helper app) but it sounds like if I simply link my bundle to one of the GL frameworks (even if I don't need it?)

Re: Authenticate NSFileManager Operations

2010-05-05 Thread Dave Keck
Which makes me wonder why Apple doesn't make an API for doing it the right way easily? :-) I'd be disappointed if this didn't happen in 10.7. I'm hoping for a kind of AEWP that handles all of the launchd shenanigans for you, and only exec()s if the codesigning bits check out.

  1   2   3   4   >