The relevant docs make it clear how to send an NSApplicationDefined NSEvent,
e.g., to NSApp, but I cannot find anything, esp. no examples, about how to
handle events of this type.
I was assuming that it could be done in AppDelegate. Perhaps not -- but I'd
really like to see a description and one
Quincey Morris wrote:
>It's straightforward. Subclass NSApplication and override sendEvent:
>to test for NSApplicationDefined.
>
>Don't forget to specify your subclass as the "Principal Class" in your
>target's properties.
The one example I found like that passed the event on even though it had
b
I downloaded the sample code
http://developer.apple.com/mac/library/samplecode/GLSLBasicsCocoaDL/index.ht
ml
It built and "ran" under Mac OS 10.5.8 and Xcode 3.1.3. However, the result
showed a *black*, rotating object on a not-quite-so-black background.
I'm guessing that it should not look lik
I have an NSArray (2 x 3) of NSButtonCell in IB. The style is Checkbox. I
made the Mode = list so that all might be unchecked.
The problem is that my array is behaving like a Radio Group. If I check one
any other that is checked turns off. This is not what I want. [No other
Mode seems to fix
Don't know if I did something wrong or this is a bug. [Leopard + Xcode
3.1.3]
I thought I would make a (modal) sheet textured because it provided a nice
contrast with its non-textured parent window. The sheet contains one
tabview and an OK button. Each of four tabs contains a radio group (matri
I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks
(since threads are not sufficient in this case). Currently, I terminate
these subtasks via the app-delegate method
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
*)sender
This works provided one
How does WatchForTermination() do its watching? Is it constantly polling?
That would be a performance-killer.
On 3/30/10 11:18 PM, "John Harte" wrote:
On Mar 30, 2010, at 4:01 PM, McLaughlin, Michael P. wrote:
> I have a Cocoa app (Leopard) which launches several Foundation
In a Cocoa app targeting Leopard, I am getting a malloc error when using the
NSData method
- (void)getBytes:(void *)buffer
My function is as follows:
-(void)getDataSz:(void*)data ofSize:(NSUInteger)sz
{
NSData *theData = [input readDataOfLength:sz];
[theData getBytes:data]; // <-- no e
I may be off on an island by myself here but I thought I'd add some more
info just in case someone recognizes it and has a useful thought.
The error described below occurs because the data I sent through
NSFileHandle to NSData (in the subtask) was actually the elements of a
vector
[just the array,
In a Leopard app, I declare an NSPipe with an NSFileHandle attached to it
for writing.
I have found, by trial and error, that I cannot write more than 65,536 bytes
to this pipe which goes to an NSTask. Below that limit works fine.
I thought that the limit was supposed to be the unsigned long max
I am not getting an error; it just hangs.
*** code ***
@interface Subtask : NSObject {
NSTask *aTask;
NSPipe *inPipe, *outPipe;
NSFileHandle *sendEnd, *readEnd;
NSString *myID;
}
-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag:(NSString*)tag;
...
@end
// in implementatio
I would have bet on #2 as well but everything is typed NSUInteger (same as the
docs) and, when I NSLog the relevant sizes, sending and receiving, they all
come back as 4 bytes.
I do not know how to "attach" to the producing process. When NSFileHandle
writeData takes off, the Xcode debugger goe
This is turning out to be a lot trickier than I had expected. [I note that
there is currently another thread in this list with a similar concern but
I'm not sure if our problems are identical.]
In my case, I have a main app with an NSArray of subtasks (inheriting from
NSObject), initialized then
>Greg Guerin wrote
>The fundamental design is "send all data before looking for any
>results". This is inherently synchronous, even though two or more
>processes are involved. If the subtask is designed to "read all data
>before producting any results", then it shouldn't deadlock. However,
>if
Is there a recommended way of determining that the currentRunLoop in a
subordinate task (executable) is, in fact, running and ready to receive a
distributed notification?
I have one subtask for each CPU, all launched during the init method of my
app. Each subtask responds with a "ready" message e
On 5/6/10 1:57 PM, "Jens Alfke" wrote:
>
>
> On May 6, 2010, at 10:34 AM, McLaughlin, Michael P. wrote:
>
>> Is there a recommended way of determining that the currentRunLoop in a
>> subordinate task (executable) is, in fact, running and ready to
>&g
I have, in the past, used standard (Carbon) documents and windows to find
and replace text. Right now, in Cocoa, I do the following:
1. Create an NSXMLDocument from a URL (and show it in a window).
2. Change/replace the string value of one or more nodes.
I am looking for a simple code fragment s
I have a window showing a custom NSView that I move off and on the screen at
different times via
orderOut
and
makeKeyAndOrderFront.
The window, created in Xcode 4, is set to be fixed from top and left. However,
every time it is reshown, it is staggered a bit down and to the right.
Is t
g>>
Cc: "cocoa-dev@lists.apple.com<mailto:cocoa-dev@lists.apple.com>"
mailto:cocoa-dev@lists.apple.com>>
Subject: Re: Strange window behavior
On Aug 11, 2011, at 7:51 AM, McLaughlin, Michael P. wrote:
The window, created in Xcode 4, is set to be fixed from top and
I have a Cocoa document app targeting Snow Leopard. It is, in most respects, a
standard document app except that, given an input file, it launches a long,
multi-threaded computation. Consequently, it can handle only one input file at
a time.
For the obvious reasons, I would very much like to
I managed to find this solution shortly after sending a request to this list
for help. I show the code below so that future programmers might find this
more easily that I did. This solution has not been tested with Lion. [Note:
This app does not have a File/New command and does not open an un
I have a Cocoa "dialog" with several textfields for numerical input. When the
user enters a bad value, I want to select that view programatically along with
an NSBeep() so that the user can fix it.
What is the best way to select that subview given that I know its tag?
Thanks.
--
Michael P. Mc
In Xcode 4.2 (Snow Leopard), I have a window with several tab views. Inside
each tab view is a matrix of radio buttons with one preselected as default.
I am seeing a problem in which I select a radio button in a view, flip to
another tab then back again. When I do this for one of the tabbed vi
I am writing the drawRect routine for a custom view in which I need to draw
a simple X-Y graph, given the data. Desiring to be elegant and up-to-date,
I decided that the best (Cocoa) way to do this was to construct a scaling
affine transform to change x,y coordinates into view coordinates using
C
With Xcode 3.2.6, I am getting the (well-discussed) error
The OutType type doesn't map to any NSDocumentClass.
after
theOutDoc = [[NSDocumentController sharedDocumentController]
makeUntitledDocumentOfType:@"OutType" error:outError];
I cannot see where I went wrong. My AppDelegate plist sho
I have a Cocoa app (Xcode 3.2.6) which displays text output in a window. This
is pure output not meant to be edited by the user. Accordingly, the textfield
is marked as not editable or selectable in IB.
When the window appears, all of the Edit menu items are disabled except Special
Characters
Could anyone point me to sample code that shows how to implement a
persistent NSOperation that could be enqueued repeatedly?
Currently, I initialize NSOps just prior to launching but this involves
copying large datasets (to avoid R/W contention) and it would be more
efficient if I could initialize
Notification Programming Topics for Cocoa states
"A notification center delivers notifications to observers synchronously. In
other words, when posting a notification, control does not return to the
poster until all observers have received *and processed* the notification."
[my emphasis]
I was wo
In a multithreaded app using NSOperationQueue and targeting Leopard, I am
having an inordinate amount of trouble communicating the results of the
thread computations to the main thread which acts as an overall coordinator.
Specifically, I am getting obscure and sporadic crashes (about 10 percent o
My (Leopard) app needs to create a sequence of NSOperations, often thousands
of them, a few at a time. The relevant code is in a setup function that
ends with
for (k = 0;k < numOps;k++) {
solverOp *thisOp = [solverOp new];
[thisOp initWithData:Data];
[opQueue addOperation:thisOp];
}
at
This is just a minor glitch but I hate loose ends.
I have a Cocoa app as a resource in my MainBundle. If I try to get its
executable via the obvious
NSString * linrgPath = [myBundle pathForResource:
@"linrg2.app/Contents/MacOS/linrg2" ofType: @""];
then linrgPath is nil;
However, if I split th
Thank you to all who responded.
I like this solution. I also replaced
myBundle
with [NSBundle mainBundle] directly.
On 2/24/10 3:06 PM, "Sherm Pendley" wrote:
On Wed, Feb 24, 2010 at 2:30 PM, McLaughlin, Michael P. wrote:
> This is just a minor glitch but I hate loose ends.
In an Xcode (3.1.2) Cocoa document app targeting 10.5, I read an NSString
from an XML file and store it, eventually, in a C++ struct as
NSString *fname;
This works most of the time but, sporadically, I get a BAD_ACCESS crash with
an indication that fname has become invalid. The only explanation
I know this is supposed to be trivial but none of the permutations I've
tried have worked [Xcode 3.1.3]. My current incarnation is as follows:
-(void)doShowHide:(BOOL)show time:(short)t
{
NSWindow *dispWindow = [dispDoc windowForSheet];
NSString *suffix = [NSString stringWithFormat:@": t =
Found the problem. It did not reside in the code below.
Sorry for the waste of bandwidth :-(
*
I know this is supposed to be trivial but none of the permutations I've
tried have worked [Xcode 3.1.3]. My current incarnation is as follows:
-(void)doShowHide:(BOOL)show time:(short)t
{
NSW
I am converting a Carbon app to Cocoa (where I'm a newbie). The Carbon app
was multithreaded and heavily dependent on cblas and clapack. It worked
well and was fully twice as fast with 2 CPUs as with 1. However, the code
was becoming increasingly obsolete.
I now have a Cocoa [ObjectiveC++] vers
On 8/18/09 1:46 PM, "Bill Bumgarner" wrote:
> On Aug 18, 2009, at 10:19 AM, McLaughlin, Michael P. wrote:
>
>> On 8/18/09 11:34 AM, "Bill Bumgarner" wrote:
>>
>>> On Aug 18, 2009, at 7:25 AM, McLaughlin, Michael P. wrote:
>>>
>>
I have an NSOperation app (simulation) executing one timestep at a time.
The threads are working fairly well but the running output is supposed to be
drawn as a color-coded map every 10 timesteps.
It seems that a window update is a low priority task because my threads are
running and continually s
I'm wondering about the timing of NSOperationQueue emptying.
In my Objective-C++ (Leopard) app, I have one opQueue of operations and the
very last thing each operation does is enqueue the results of a computation
back to the main thread.
NSPointerArray *ptr = [NSPointerArray pointerArrayWithStron
I have a new Mac Pro which is perfectly OK except that the NSBeep() function
in my code (OS 10.6.4, Xcode 3.2.3) produces a beep (the default) that is
almost too soft to hear. Other sounds through the internal speaker are
fine.
Is this a bug or a feature?
Thanks.
--
Mike McLaughlin
__
Is there any standard way for a Cocoa app to test whether it was launched
from a script, esp. AppleScript? I would like to set a flag to disable
dialogs so that users could run the app in (faceless) batch mode.
Thanks.
--
Mike McLaughlin
___
Cocoa-d
> On 10 Nov 2010, Mitchell, Jonathan wrote:
>> On 10 Nov 2010, at 18:34, McLaughlin, Michael P. wrote:
>>
>> Is there any standard way for a Cocoa app to test whether it was launched
>> from a script, esp. AppleScript? I would like to set a flag to disable
>> di
In my app, I read an XML file, init an NSXMLDocument and also display the
file contents in an NSTextField in a document window. The user can then
change parts of the XML via several dialogs. The XML data is eventually
sent to subprocesses for computation.
The NSTextField is set to non-editable b
This past weekend I tried compiling my Snow Leopard Cocoa app in Lion (Xcode
4.3) just to make sure all was OK. I got two warnings stating that
MPProcessorsScheduled and MPCreateCriticalRegion were deprecated in Lion but
the relevant Lion docs did not say what they should to be replaced with.
I have a Mac OS app that worked fine in Snow Leopard. In moving up recently to
Lion, I also moved up to Xcode 4.4 and recompiled the app, targeting 10.6 but
without otherwise changing the source code. I got two problems when running
the resulting app under Lion.
I fixed the first problem by
My app, created in Lion but targeting SL seems to work fine except that, when
actually run in Snow Leopard, it crashes whenever Open or Open Recent is
selected. The crash log gives
0 com.apple.AppKit 0x7fff885e49de -[NSImage
_allocAuxiliaryStorage] + 158
1 com.apple.AppKi
I have been using notifications in a simple document app that processes data
from a datafile. This app has a document window and an appDelegate, both of
which appear in IB with the proper connections. The document can
successfully send notifications to the appDelegate and the latter can send
noti
Error was of the typo variety. Too embarrassing to describe further :-(
--
Mike McLaughlin
___
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-d
I have a "global" gFlags variable (unsigned long long) and several objects
that need a pointer to it. I fill one such pointer, and reinit gFlags, via
the following code:
if (flags == nil) {
flagPtr *flgH = &flags;
NSData *flgsDatum =
[[NSData alloc] initWithBytesNoCopy:flgH length:siz
In a custom NSBezierView, I fill the view with a background color then set a
clip path that will eventually be drawn as a map. I do this so that I can
color-code the map (in a complicated way) without "going outside the lines".
If I then draw the map, external boundaries are drawn as half-width l
Naturally, I came up with a solution two minutes after posting my query to
this list :-(
My solution is
[[NSBezierPath bezierPathWithRect:rect] setClip];
where rect is the viewRect. This works for me. It might not be the best
solution in all cases.
*** Original post ***
In a custom NSBezierV
In a Cocoa Document project (latest Xcode), I want to have only one document
open at a time. I thought that I could do this by subclassing
NSDocumentController but I have been only partially successful. For
instance, just as a test, the subclass code contains
-(BOOL)validateUserInterfaceItem:(id
s menu event although I was aware that openRecentDocument: was
not in the corresponding API.
openRecentDocument: is so far the only method I have seen that comes close
to being what I was looking for.
I'm still looking.
> On 15 May 2009, at 16:01, McLaughlin, Michael P. wrote:
>
>
In reviewing the NSXML documents, I found no really simple way to traverse a
subtree of an NSXMLDocument. That is, traverse from the root until you hit
the node with the right name then pretend that that node is the root of a
smaller tree and traverse just the latter. [Everything I found talked o
On 5/27/09 5:02 PM, "Keith Duncan" wrote:
>> Could someone clue me in as to the preferred method to do a
>> subtraversal?
>
> Have you looked at XPath, it will save you from having to enumerate
> and perform element-name string comparisons.
>
> Keith
>
Yes. I looked at that but
1. My tree is
On 5/27/09 6:42 PM, "Greg Guerin wrote:
>> In reviewing the NSXML documents, I found no really simple way to
>> traverse a
>> subtree of an NSXMLDocument. That is, traverse from the root until
>> you hit
>> the node with the right name then pretend that that node is the
>> root of a
>> smaller t
Using Xcode 5.0.2 in Mac OS 10.9.1, I created a Cocoa document app, replacing
the templated text field with a textview. After making the necessary
connections, everything worked as intended.
I then went into Document.xib and checked Show Horizontal Scroller in the
Bordered scroll view (in addi
Is there a sure-fire way to know when it is necessary to call super in an
override?
Sample code shows that calling super is necessary for methods such as
-(id)init
- (void)windowControllerDidLoadNib
but not for
(NSData *)dataOfType
(BOOL)readFromData
How can you know for sure?
This q
58 matches
Mail list logo