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
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
*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
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
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
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
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
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
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.
___
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
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
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,
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
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
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
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
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
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
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
[[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
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
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
*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
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
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
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
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
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
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
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
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
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
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
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 =
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()
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.
___
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
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
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
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
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
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
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
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.
___
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
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
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
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
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
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
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
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
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
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
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();
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
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
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
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
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:,
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?
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
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
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
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
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
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
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
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
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
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
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
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
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;
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;
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
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
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)
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
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
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:
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
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
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
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
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
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
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()?
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
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
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
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
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!
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
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
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
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
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
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?)
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 - 100 of 316 matches
Mail list logo