RE: IKImageBrowserView drag and drop/reordering when using core data [SOLVED]

2009-04-11 Thread jonat...@mugginsoft.com

Regarding this previous post of mine:
http://www.cocoabuilder.com/archive/message/cocoa/2009/1/13/227642

The code listed in that previous posting contains an error which  
results in insidious behaviour:
“EXC_BAD_ACCESS” sometimes generated when dragging within  
IKBrowserImageView


I had omitted to inform the NSPasteboard of the imminent data type.

/*

  write images to paste board

  need for dragging of non path represented images

  */
- (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser   
writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:  
(NSPasteboard *)pasteboard

{
   NSIntegerindex;

  // tell the pasteboard what to expect - required!
  [pasteboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType]  
owner:nil];	// amended 11-04-09


   for (index = [itemIndexes lastIndex]; index != NSNotFound; index  
=  [itemIndexes indexLessThanIndex:index])

   {
   GoodThing *goodThing = [[imageBrowserViewArrayController  
content]  objectAtIndex:index];
   [pasteboard setData:goodThing.imageRepresentation  
forType:NSTIFFPboardType];

   }

   return [itemIndexes count];
}

Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




___

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

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

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

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


Re: WebKit Caching

2009-04-11 Thread Adam Thorsen

Hi Greg,

I mistakenly posted to this list first, when I should have posted to  
the sdk list.


The client is not performing a conditional GET request based on  
examinations of the outgoing requests (from within the client).
The server is detecting date changes and sending the correct date  
(based on the requests as seen in the client).


I can't disable caching from the server because the client is intended  
to be a general purpose tool used for development (and is intended to  
save users the step of having to set this header field in their server  
responses).  There is a "Disable Caches" menu item under the "Develop"  
menu in Safari that I would basically like to emulate.  It appears to  
work flawlessly, so I know there must be a way.



On Apr 10, 2009, at 1:29 PM, Greg Guerin wrote:


Adam Thorsen wrote:


Load a page that includes a javascript file into a webview.
Now change the javascript file and reload the contents of the  
webview.

Any changes made to the javascript file will not be evident.


Basic questions:
 Is the client performing a conditional GET request?
 Is the server detecting the date change on the file?
 Is the server sending the resource with a different date?

Other questions:
 Why can't the server disable caching of the javascript resource?

It seems to me that if you don't want javascript resources cached,  
the most straightforward way to achieve that is to specify that the  
javascript resources not be cached.  Kluging it up on the client  
side seems like the wrong solution-space.



If you don't have a way to observe the actual network traffic, I  
recommend Interarchy.  It has a nice traffic-watching capability.


And I see you've now transferred to webkitsdk-dev, so no reply  
necessary.


http://lists.apple.com/archives/Webkitsdk-dev/2009/Apr/msg9.html

 -- GG

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adam.thorsen%40gmail.com

This email sent to adam.thor...@gmail.com


___

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

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

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

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


Re: Changing CAConstraint for a CALayer

2009-04-11 Thread Kevin Cathey
Constraints are immutable objects, once you create them, you cannot  
change them. This is a limitation of the constraint layout manager. If  
you need more fine-grain control, use a custom layout manager.


Kevin

--
Kevin Cathey


On 10 Apr 2009, at 12:15, Rama Krishna wrote:

I am using CALayoutManager for laying out Core Animation layers and  
it works
great. Now I have a requirement that I need to modify the layout of  
the sub

layers based on certain event. What this means is that the layout
constraints specified by CAConstraint of the sublayers need to be  
modified.


Unfortunately, I could not see any way of doing that. Can someone  
guide me
in the right direction on how to do this short of recreating the  
layers.


Thanks
Rama Krishna

___

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

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

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

This email sent to cat...@apple.com


___

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

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

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

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


Re: NSTextFieldCell text color issue in NSTableView with source list highlighting

2009-04-11 Thread jonat...@mugginsoft.com



On 13 Mar 2009, at 16:48, Corbin Dunn wrote:


Thank you!
corbin



Just to note, as should probably be expected, that monkeying with the  
cell's font within


- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell  
forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex


also seems to produce uneven text coloration of highlighted text cells.
Workaround is as before:

[aCell setStringValue:[aCell stringValue]];

Added a note to the radar on this.


On Mar 13, 2009, at 7:08 AM, jonat...@mugginsoft.com wrote:



On 12 Mar 2009, at 17:07, Corbin Dunn wrote:



On Mar 12, 2009, at 3:51 AM, jonat...@mugginsoft.com wrote:

The recommended way to override the text color in an NSTableView  
NSTextFieldCell is detailed here:

http://www.cocoabuilder.com/archive/message/cocoa/2008/11/5/222008.

However, there seems to be a problem setting the text color of a  
highlighted NSTextFieldCell when NSTableView - 
selectionHighlightStyle is set to  
NSTableViewSelectionHighlightStyleSourceList.


The following delegate method produces uneven text coloration of  
highlighted text cells.


The issue does not arise for non source list style NSTableViews.

/*

tableview will display cell

*/
- (void)tableView:(NSTableView *)aTableView willDisplayCell: 
(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row: 
(NSInteger)rowIndex

{
	// note that when the NSTableView Highlight mode is set to  
source list

// setting the text color of NSTextFieldCell seems to misbehave.
if ([aCell isKindOfClass:[NSTextFieldCell class]]) {
if ([aCell isHighlighted]) {
[aCell setTextColor: [NSColor lightGrayColor]];
} else {
[aCell setTextColor: [NSColor darkGrayColor]];
}
}
}

Has anyone else encountered this?

Work around solution is probably to use NSAttributedString.


That is the only solution at the time. Could you log a bug for this?


Bug logged.
Bug ID: 6679161

NSTableView attempts to apply "standard attributes" for the  
highlighted cell, if plain text is given to the cell via the  
datasource.


corbin





Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




___

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

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

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

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


NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell

I've got a strange problem.
I have a list of float constants that I need to compare to the result  
of a new calculation.


I derived the constants by performing the calculation, and printing  
using NSLog with %f, then just writing down the results in my array of  
constants.
So, the result of the calculation used to derive the float constants  
was run through NSLog, using the %f token.


Now, when I run the calculation "live" and try to compare to my stored  
constants, I'm not getting matches. I'm assuming this is because the  
result of the calculation *isn't* actually what I stored in my  
constants, since the constants were rounded during the NSLog. So, how  
do I make sure my "live" calculation returns a value that will be  
rounded in the same way as an NSLog(@"%f", aFloat)?


That's a confusing question, I know... I hope it makes sense to  
somebody.


J.

___

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

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

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

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


Re: Rendering OpenGL in timed loop (CoreVideo).

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 2:20 AM, Brian Bruinewoud  wrote:
> Ok. That "works". I was coming from an NSOpenGLView example where the view
> sets the context before the drawRect is sent.
>
> Any it, doesn't crash/hang/stop now, but it doesn't draw anything, either...
> :(

Does identical code placed in drawRect: (without the context setting
stuff, of course) draw? If so, it's probably a flushing problem. Be
sure to flush your GL context before you exit.

I thought of another possible approach. Since NSOpenGLView tries to
act like a regular NSView, it may be sufficient to wrap your calls in
a lockFocus/unlockFocus pair.

Mike
___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 12:46 PM, James Maxwell
 wrote:
> I've got a strange problem.
> I have a list of float constants that I need to compare to the result of a
> new calculation.
>
> I derived the constants by performing the calculation, and printing using
> NSLog with %f, then just writing down the results in my array of constants.
> So, the result of the calculation used to derive the float constants was run
> through NSLog, using the %f token.
>
> Now, when I run the calculation "live" and try to compare to my stored
> constants, I'm not getting matches. I'm assuming this is because the result
> of the calculation *isn't* actually what I stored in my constants, since the
> constants were rounded during the NSLog. So, how do I make sure my "live"
> calculation returns a value that will be rounded in the same way as an
> NSLog(@"%f", aFloat)?
>
> That's a confusing question, I know... I hope it makes sense to somebody.

Read "What Every Computer Scientist Should Know About Floating-Point
Arithmetic":

http://docs.sun.com/source/806-3568/ncg_goldberg.html

But basically, never depend on floating point calculations to be
exact. As a consequence, never compare floats or doubles for equality.
Instead, compute a delta from the desired value, and see if the delta
is within an acceptable range.

Mike
___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
oooh, damn... I was afraid someone was going to say that. I just hoped  
there might be some way to force a float to conform to what NSLog %f  
prints... That seems like it might be a useful function - something  
like pround(aFloat), for "print-round", to force any float number to  
round as the printf %f would round it. Anyway, that's obviously not  
available.


Is there any C function that can compare within a given margin of  
error? (I seem to remember seeing something like that, as some  
point...??)
If not, no big deal - I'll just calculate the comparison within a  
margin of error by hand.


thanks,

J.


On 11-Apr-09, at 10:15 AM, Michael Ash wrote:


On Sat, Apr 11, 2009 at 12:46 PM, James Maxwell
 wrote:

I've got a strange problem.
I have a list of float constants that I need to compare to the  
result of a

new calculation.

I derived the constants by performing the calculation, and printing  
using
NSLog with %f, then just writing down the results in my array of  
constants.
So, the result of the calculation used to derive the float  
constants was run

through NSLog, using the %f token.

Now, when I run the calculation "live" and try to compare to my  
stored
constants, I'm not getting matches. I'm assuming this is because  
the result
of the calculation *isn't* actually what I stored in my constants,  
since the
constants were rounded during the NSLog. So, how do I make sure my  
"live"
calculation returns a value that will be rounded in the same way as  
an

NSLog(@"%f", aFloat)?

That's a confusing question, I know... I hope it makes sense to  
somebody.


Read "What Every Computer Scientist Should Know About Floating-Point
Arithmetic":

http://docs.sun.com/source/806-3568/ncg_goldberg.html

But basically, never depend on floating point calculations to be
exact. As a consequence, never compare floats or doubles for equality.
Instead, compute a delta from the desired value, and see if the delta
is within an acceptable range.

Mike
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com

This email sent to jbmaxw...@rubato-music.com


___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Greg Titus
If what you really want is to see whether the result is the same as %f  
previously printed, then you could always make your array of constants  
an array of constant _strings_ and then compare the strings. Not  
terribly efficient, maybe, but straightforward.


- Greg

On Apr 11, 2009, at 10:26 AM, James Maxwell wrote:

oooh, damn... I was afraid someone was going to say that. I just  
hoped there might be some way to force a float to conform to what  
NSLog %f prints... That seems like it might be a useful function -  
something like pround(aFloat), for "print-round", to force any float  
number to round as the printf %f would round it. Anyway, that's  
obviously not available.


Is there any C function that can compare within a given margin of  
error? (I seem to remember seeing something like that, as some  
point...??)
If not, no big deal - I'll just calculate the comparison within a  
margin of error by hand.


thanks,

J.


On 11-Apr-09, at 10:15 AM, Michael Ash wrote:


On Sat, Apr 11, 2009 at 12:46 PM, James Maxwell
 wrote:

I've got a strange problem.
I have a list of float constants that I need to compare to the  
result of a

new calculation.

I derived the constants by performing the calculation, and  
printing using
NSLog with %f, then just writing down the results in my array of  
constants.
So, the result of the calculation used to derive the float  
constants was run

through NSLog, using the %f token.

Now, when I run the calculation "live" and try to compare to my  
stored
constants, I'm not getting matches. I'm assuming this is because  
the result
of the calculation *isn't* actually what I stored in my constants,  
since the
constants were rounded during the NSLog. So, how do I make sure my  
"live"
calculation returns a value that will be rounded in the same way  
as an

NSLog(@"%f", aFloat)?

That's a confusing question, I know... I hope it makes sense to  
somebody.


Read "What Every Computer Scientist Should Know About Floating-Point
Arithmetic":

http://docs.sun.com/source/806-3568/ncg_goldberg.html

But basically, never depend on floating point calculations to be
exact. As a consequence, never compare floats or doubles for  
equality.

Instead, compute a delta from the desired value, and see if the delta
is within an acceptable range.

Mike
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com

This email sent to jbmaxw...@rubato-music.com


___

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

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

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

This email sent to g...@omnigroup.com


___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell

Yeah, that's an idea... But I do need it to be fairly efficient.
I've solved the problem by calculating fabs(val1 - val2) and only  
allowing a very small margin of error (0.01). It seems to be  
working. If this is still going to be disaster-prone, I'd appreciate a  
quick heads-up. But keep in mind, the floats on the right-hand side of  
the comparison are constants, so I only need to deal with any  
imprecision on the left side...


cheers,

J.


On 11-Apr-09, at 10:38 AM, Greg Titus wrote:

If what you really want is to see whether the result is the same as  
%f previously printed, then you could always make your array of  
constants an array of constant _strings_ and then compare the  
strings. Not terribly efficient, maybe, but straightforward.


- Greg

On Apr 11, 2009, at 10:26 AM, James Maxwell wrote:

oooh, damn... I was afraid someone was going to say that. I just  
hoped there might be some way to force a float to conform to what  
NSLog %f prints... That seems like it might be a useful function -  
something like pround(aFloat), for "print-round", to force any  
float number to round as the printf %f would round it. Anyway,  
that's obviously not available.


Is there any C function that can compare within a given margin of  
error? (I seem to remember seeing something like that, as some  
point...??)
If not, no big deal - I'll just calculate the comparison within a  
margin of error by hand.


thanks,

J.


On 11-Apr-09, at 10:15 AM, Michael Ash wrote:


On Sat, Apr 11, 2009 at 12:46 PM, James Maxwell
 wrote:

I've got a strange problem.
I have a list of float constants that I need to compare to the  
result of a

new calculation.

I derived the constants by performing the calculation, and  
printing using
NSLog with %f, then just writing down the results in my array of  
constants.
So, the result of the calculation used to derive the float  
constants was run

through NSLog, using the %f token.

Now, when I run the calculation "live" and try to compare to my  
stored
constants, I'm not getting matches. I'm assuming this is because  
the result
of the calculation *isn't* actually what I stored in my  
constants, since the
constants were rounded during the NSLog. So, how do I make sure  
my "live"
calculation returns a value that will be rounded in the same way  
as an

NSLog(@"%f", aFloat)?

That's a confusing question, I know... I hope it makes sense to  
somebody.


Read "What Every Computer Scientist Should Know About Floating-Point
Arithmetic":

http://docs.sun.com/source/806-3568/ncg_goldberg.html

But basically, never depend on floating point calculations to be
exact. As a consequence, never compare floats or doubles for  
equality.
Instead, compute a delta from the desired value, and see if the  
delta

is within an acceptable range.

Mike
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com

This email sent to jbmaxw...@rubato-music.com


___

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

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

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

This email sent to g...@omnigroup.com




___

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

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

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

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


Re: Does waitUntilExit really mean that?

2009-04-11 Thread Michael Domino

Ken,

I ended up throwing out NSTask in favor of popen for running hdiutil,  
and my code seems much more stable now. Did I shoot myself in the foot  
some other way? I'm executing this in a pthread of its own. I also  
kept getting exceptions thrown for nil arguments to NSConreteTask,  
besides the problems getting the standard output either partially or  
not at all. This seems better:


FILE *instream = popen(cmdbuf, "r");
if(instream) {
// read the output, one line at a time.
string data;
int MAX_BUFFER = 512;
char buffer[MAX_BUFFER];
while (!feof(instream)){
if (fgets(buffer, MAX_BUFFER, 
instream) != NULL){
data.append(buffer);
}
}
// close the pipe.
status = pclose(instream);

-Michael

On Apr 8, 2009, at 5:11 PM, Michael Domino wrote:


Ken,

After all the discussion and hours of fun trying the various code  
permutations, this is the only thing that works reliably for me:


[task launch];
NSData* outData;
NSString* messageOutput = [[NSString new] autorelease];
			while ((outData=[readHandleOutput availableData]) && ([outData  
length])) {
NSString* theString=[[NSString alloc] initWithData:outData  
encoding:NSUTF8StringEncoding];

messageOutput = [messageOutput 
stringByAppendingString:theString];
[theString release];
}
[task waitUntilExit];

Using the notification methods, I often ended up with an empty or  
partial output string. This is running in a thread of its own, by  
the way, so there are no blocking issues with the main thread.


Thanks again,
Michael

On Apr 8, 2009, at 11:13 AM, Ken Thomases wrote:


On Apr 7, 2009, at 10:44 AM, Michael Domino wrote:


Thanks very much for the reply.


You're welcome.

I have two methods to handle the notifications for the error and  
output pipes (see below). Since we are supposed to be reading to  
EOF, do I really need to call readToEndOfFileInBackgroundAndNotify  
at the end of each call?


No, you should not.  The other asynchronous methods of NSFileHandle  
require that you re-issue the call during the notification handler  
if you want to keep reading/writing, but that's not necessary or  
desirable when reading to EOF.


To answer your question, after the code runs I get my error and  
output strings and parse them. If waitUntilExit is not going to  
wait long enough for the i/o process to complete, how would I go  
about ensuring that the run loop is run until both NSFileHandles  
have sent their notifications?


You'd use a loop something like this:

while (![msgTarget isEverythingCompleted])
		[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode  
beforeDate:[NSDate distantFuture]];


In your notification handlers, you'd set the "everything completed"  
flag after both file handles had reached EOF.  -runMode:beforeDate:  
returns after each input source fires, thus allowing the check of  
the flag.  (I repeat, just because it's an area that's prone to  
confusion: the sending of a notification doesn't have anything to  
do with the run loop, but in this case, where external resources/ 
events are being monitored, the sending of the notification is  
happening because a run loop input source has fired.)



Use NSTaskDidTerminateNotification instead of or in addition to  
waitUntilExit?


That doesn't help.  It's still the case that task termination may  
be detected before the file handles detect EOF.


You may, if you like, use a loop like the above in combination with  
NSTaskDidTerminateNotification instead of -waitUntilExit.  In that  
case, the "everything completed" flag should be set after all three  
notifications have been received.  Doesn't seem simpler to me, but  
I guess it's more symmetrical.



Is there some reason this has to be on a background thread?  If it  
were on the main thread, where you can rely on the run loop  
running, you could just set everything in motion and then handle  
all of the results in the notification handlers without having to  
bother with managing how long you run the run loop.  MsgTarget  
would just keep track of which things had completed (each of the  
two file handles and the task itself).  Inside whichever handler  
completed the last of those, just invoke the next step (processing  
the task results).


Although checking the task termination status is good practice, if 

Re: Does waitUntilExit really mean that?

2009-04-11 Thread Gwynne Raskind

On Apr 11, 2009, at 2:29 PM, Michael Domino wrote:
I ended up throwing out NSTask in favor of popen for running  
hdiutil, and my code seems much more stable now. Did I shoot myself  
in the foot some other way? I'm executing this in a pthread of its  
own. I also kept getting exceptions thrown for nil arguments to  
NSConreteTask, besides the problems getting the standard output  
either partially or not at all. This seems better:



FWIW, I was having some strange issues with NSTask and setuid child  
processes (not setuid root, mind you). I tried to peek at what NSTask  
was doing behind the scenes, and I found some rather confusing usages  
of CFFileDescriptor, kqueue(), and the like in the disassembly. My  
eventual solution was to roll my own version of NSTask which gave me  
full control over the way the child process was set up, from pre- 
fork() to to post-exec(). In particular, I use some of the lower-level  
UNIX calls directly (dup2()/close() instead of CFFileDescriptor,  
waitpid() on a separate thread instead of kqueue(), etc.). I was able  
to track down the issue I was having with the setuid process once I  
had the ability to trace the code running between fork() and execve().


The moral of the story is: Just because Apple provides a closed-source  
high-level Cocoa solution to a low-level UNIX problem, doesn't mean  
the Cocoa way is always the best.


-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."
___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Greg Guerin

James Maxwell wrote:


Yeah, that's an idea... But I do need it to be fairly efficient.
I've solved the problem by calculating fabs(val1 - val2) and only  
allowing a very small margin of error (0.01). It seems to be  
working. If this is still going to be disaster-prone, I'd  
appreciate a quick heads-up. But keep in mind, the floats on the  
right-hand side of the comparison are constants, so I only need to  
deal with any imprecision on the left side...


You haven't said what your range of values is.  Remember that floats  
are numbers with a floating decimal point, not numbers with a fixed  
decimal point.  If your margin of error is a fixed number like 1e-6  
(0.01), but the range of valid values goes as low as 1e-5, then  
that's a 10% margin of error.  Worse, if the valid values can be less  
than 1e-6 in magnitude, and 'float' can certainly represent those  
with its full precision, then your margin of error exceeds the  
magnitude of your value.


I highly recommend reading "What Every Computer Scientist Should Know  
About Floating-Point Arithmetic", or at least glancing through it.  I  
then recommend seeking out a reliable reference or code sample that  
explains exactly how to do a proper "within a margin of error"  
calculation.  Spending the time to find reliable tested code will  
likely pay off in the long run.


You also might want to post some of the actual constants you printed  
out and then re-entered manually.  One of the cardinal rules for  
getting good answers is to be specific.


Finally, it's unclear to me if you're using the 'float' type or the  
'double' type but referring to them both as "float", because %f  
actually formats a 'double'.  It's conceivable that simply increasing  
the precision or format of the NSLog'ed print-format string will  
improve things.  E.g. %.9e or %.19e instead of %f.


http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/ 
Articles/formatSpecifiers.html


http://www.opengroup.org/onlinepubs/009695399/functions/printf.html

  -- GG

___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Greg Guerin

James Maxwell wrote:

Now, when I run the calculation "live" and try to compare to my  
stored constants, I'm not getting matches. I'm assuming this is  
because the result of the calculation *isn't* actually what I  
stored in my constants, since the constants were rounded during the  
NSLog. So, how do I make sure my "live" calculation returns a value  
that will be rounded in the same way as an NSLog(@"%f", aFloat)?


Maybe you're trying to solve the wrong problem.

Just because you have a constant float doesn't mean it has to be:
  extern const float Foo;

It could also be:
 #define Foo (Foo_Value())
  extern float Foo_Value();

Then you run some initializing code that calculates your "constant"  
values and stores them in static variables to be returned by the  
functions.  E.g.:


  static float const_Foo;

  extern float Foo_Value() { return const_Foo;  }

  extern void initializeConstants()
  { const_Foo = calc_Foo();  ..calculate and store other results.. }

You could use inline functions, too, if that's your thing.

Whether an approach like this is sufficient to avoid problems with  
rounding error and precision loss, only you can say, because you  
haven't explained anything about the actual calculations.


  -- GG

___

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

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

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

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


displaying a screen saver on multiple displays

2009-04-11 Thread Development
I'm not seeing exactly how to go about running my screen save on both  
of my displays.


At least I'm not seeing an accessor that allows me to add the rendered  
screen saver to more than one display.  How would I go about doing that?


Thanks
___

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

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

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

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


Re: displaying a screen saver on multiple displays

2009-04-11 Thread Nick Zitzmann


On Apr 11, 2009, at 1:34 PM, Development wrote:

At least I'm not seeing an accessor that allows me to add the  
rendered screen saver to more than one display. How would I go about  
doing that?



ScreenSaverEngine will always create one instance of your saver view  
class per screen.


Nick Zitzmann




___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell
hmm... Well, this all sounds like a sledge-hammer approach to my  
immediate problem.


The actual explanation of what I'm doing is kind of long-winded, so  
I'll spare you that. For now, I know the calculated values will always  
come out the same, since there are a limited number of possible  
inputs, and I know they'll very nearly match my stored constants (and  
my constants are well separated, so %10 is more than enough).
In future, I may want to handle a more continuous range of inputs, in  
which case I'll have to look at the solutions you've provided, so I  
appreciate your tips. Mind you, if that does become necessary, then  
I'll probably have to approach the entire problem differently!


thanks,

J.


On 11-Apr-09, at 12:16 PM, Greg Guerin wrote:


James Maxwell wrote:

Now, when I run the calculation "live" and try to compare to my  
stored constants, I'm not getting matches. I'm assuming this is  
because the result of the calculation *isn't* actually what I  
stored in my constants, since the constants were rounded during the  
NSLog. So, how do I make sure my "live" calculation returns a value  
that will be rounded in the same way as an NSLog(@"%f", aFloat)?


Maybe you're trying to solve the wrong problem.

Just because you have a constant float doesn't mean it has to be:
 extern const float Foo;

It could also be:
#define Foo (Foo_Value())
 extern float Foo_Value();

Then you run some initializing code that calculates your "constant"  
values and stores them in static variables to be returned by the  
functions.  E.g.:


 static float const_Foo;

 extern float Foo_Value() { return const_Foo;  }

 extern void initializeConstants()
 { const_Foo = calc_Foo();  ..calculate and store other results.. }

You could use inline functions, too, if that's your thing.

Whether an approach like this is sufficient to avoid problems with  
rounding error and precision loss, only you can say, because you  
haven't explained anything about the actual calculations.


 -- GG

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com

This email sent to jbmaxw...@rubato-music.com


___

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

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

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

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


Re: Does waitUntilExit really mean that?

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 2:29 PM, Michael Domino
 wrote:
> Ken,
>
> I ended up throwing out NSTask in favor of popen for running hdiutil, and my
> code seems much more stable now. Did I shoot myself in the foot some other
> way? I'm executing this in a pthread of its own. I also kept getting
> exceptions thrown for nil arguments to NSConreteTask, besides the problems
> getting the standard output either partially or not at all. This seems
> better:
>
>                                FILE *instream = popen(cmdbuf, "r");

You should basically never use popen(). The reasons are the same for
why you should never use system(): it spawns a shell, and performs
shell processing on your argument, which adds about a zillion
different opportunities for things to go wrong if, for example, you
have unusual characters in your arguments.

Since apparently you don't need separate stderr and stdout, I'm
curious as to why you were using the big complicated two-pipe approach
with NSTask. Using a single output pipe with NSTask is vastly simpler
and doesn't require any runloop stuff, just a single call to
readDataToEndOfFile.

If you really can't use NSTask (if you gave up due to getting
exceptions about nil arguments, you should stop passing it nil
arguments) then you should spawn the subprocess using more manual
methods like fork/exec or posix_spawn. It's unfortunate that there are
no decent subprocess spawning APIs in libc, but there we are.

Mike
___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 4:45 PM, James Maxwell
 wrote:
> hmm... Well, this all sounds like a sledge-hammer approach to my immediate
> problem.
>
> The actual explanation of what I'm doing is kind of long-winded, so I'll
> spare you that. For now, I know the calculated values will always come out
> the same, since there are a limited number of possible inputs, and I know
> they'll very nearly match my stored constants (and my constants are well
> separated, so %10 is more than enough).

Are you always running these calculations on identical hardware?
Because unless you're doing that, there's no way you can know that
your calculated values will always come out the same.

Floating point isn't just imprecise because the variables are of
finite size and therefore finite precision. It's also imprecise
because the individual calculations are not always performed to the
full precision available in the finite representation, and the
variation from full precision is pretty much implementation defined.

Mike
___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread James Maxwell

oh, geez... Okay, you guys made your point! ;-)

One thing I love about this list; I *always* get useful info.

I'll find a better way to do this soon. In this particular case, the  
"match" could be specified as broadly as any value falling within a  
sort of "bin." The "bottoms" of each of these bins are defined by the  
constant float array. So, I could probably just say that any number  
that falls above the lower limit of a bin (i.e., half-way between  
float A and B), or below the upper limit of the bin (half-way between  
float B and C) is in the bin.


Anyway, these "bins" are fairly far apart so, as I said before, it  
seems pretty safe, for the time being.

I will clean it up soon.

thanks for all the valuable info!

J.


On 11-Apr-09, at 2:12 PM, Michael Ash wrote:


On Sat, Apr 11, 2009 at 4:45 PM, James Maxwell
 wrote:
hmm... Well, this all sounds like a sledge-hammer approach to my  
immediate

problem.

The actual explanation of what I'm doing is kind of long-winded, so  
I'll
spare you that. For now, I know the calculated values will always  
come out
the same, since there are a limited number of possible inputs, and  
I know
they'll very nearly match my stored constants (and my constants are  
well

separated, so %10 is more than enough).


Are you always running these calculations on identical hardware?
Because unless you're doing that, there's no way you can know that
your calculated values will always come out the same.

Floating point isn't just imprecise because the variables are of
finite size and therefore finite precision. It's also imprecise
because the individual calculations are not always performed to the
full precision available in the finite representation, and the
variation from full precision is pretty much implementation defined.

Mike
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com

This email sent to jbmaxw...@rubato-music.com


___

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

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

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

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


@selector not working with (id)anObject

2009-04-11 Thread Trygve Inda
[NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
withObject:@selector(myMethod)];


-(void)threadMethod:(id)anObject
{
  NSAutoreleasePool*pool = [[NSAutoreleasePool alloc] init];
  SEL   comp = (SEL)anObject;

... Do stuff ...

  [self performSelectorOnMainThread:comp withObject:nil waitUntilDone:NO];
  [pool release];
}


This crashes during detachNewThreadSelector. How can I pass a method to call
at the end of the thread processing as above?

Thanks,

Trygve


___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Bill Bumgarner

On Apr 11, 2009, at 5:20 PM, Trygve Inda wrote:

-(void)threadMethod:(id)anObject
{
 NSAutoreleasePool*pool = [[NSAutoreleasePool alloc] init];
 SEL   comp = (SEL)anObject;

   ... Do stuff ...

 [self performSelectorOnMainThread:comp withObject:nil  
waitUntilDone:NO];

 [pool release];
}

This crashes during detachNewThreadSelector. How can I pass a method  
to call

at the end of the thread processing as above?


There are a handful of issues here:

- a SEL is not an (id);   if anything tries to -retain the SEL it is  
going to crash


- in general, casting outside of casting up/down class hierarchies is  
an indication that your code is wrong


If you really want to pass a selector around in a slot that normally  
holds objects, use NSStringFromSelector() and NSSelectorFromString().


However, with that said, that is generally an atypical design  
pattern.   Not totally odd, but just not that typical.  Raises a the  
"what are you trying to do?" flag, though.


b.bum



___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Trygve Inda
> On Apr 11, 2009, at 5:20 PM, Trygve Inda wrote:
>> -(void)threadMethod:(id)anObject
>> {
>>  NSAutoreleasePool*pool = [[NSAutoreleasePool alloc] init];
>>  SEL   comp = (SEL)anObject;
>> 
>>... Do stuff ...
>> 
>>  [self performSelectorOnMainThread:comp withObject:nil
>> waitUntilDone:NO];
>>  [pool release];
>> }
>> 
>> This crashes during detachNewThreadSelector. How can I pass a method
>> to call
>> at the end of the thread processing as above?
> 
> There are a handful of issues here:
> 
> - a SEL is not an (id);   if anything tries to -retain the SEL it is
> going to crash
> 
> - in general, casting outside of casting up/down class hierarchies is
> an indication that your code is wrong
> 
> If you really want to pass a selector around in a slot that normally
> holds objects, use NSStringFromSelector() and NSSelectorFromString().
> 
> However, with that said, that is generally an atypical design
> pattern.   Not totally odd, but just not that typical.  Raises a the
> "what are you trying to do?" flag, though.

I have a thread. Depending on how it is called, I need to do something
different at the end of the main processing so I wanted to pass a selector
into the thread so it could call it when it was ready.

I could just pass an NSNumber and do case1, case2 etc, but thought it'd be
nice to just do the equivalent of passing a function pointer.

So one of these needs to be called:

[self performSelectorOnMainThread:@selector(cacheComplete) withObject:nil
waitUntilDone:NO];

[self performSelectorOnMainThread:@selector(initComlete) withObject:nil
waitUntilDone:NO];

Thoughts?


___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Bill Bumgarner

On Apr 11, 2009, at 5:32 PM, Trygve Inda wrote:

So one of these needs to be called:

[self performSelectorOnMainThread:@selector(cacheComplete)  
withObject:nil

waitUntilDone:NO];

[self performSelectorOnMainThread:@selector(initComlete)  
withObject:nil

waitUntilDone:NO];

Thoughts?



On Apr 11, 2009, at 5:20 PM, Bill Bumgarner wrote:


If you really want to pass a selector around in a slot that normally
holds objects, use NSStringFromSelector() and NSSelectorFromString().




___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Sherm Pendley
2009/4/11 Trygve Inda 

I have a thread. Depending on how it is called, I need to do something
> different at the end of the main processing so I wanted to pass a selector
> into the thread so it could call it when it was ready.
>
> I could just pass an NSNumber and do case1, case2 etc, but thought it'd be
> nice to just do the equivalent of passing a function pointer.


You could create an NSInvocation object and pass that.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Trygve Inda
> 2009/4/11 Trygve Inda 
> 
> I have a thread. Depending on how it is called, I need to do something
>> different at the end of the main processing so I wanted to pass a selector
>> into the thread so it could call it when it was ready.
>> 
>> I could just pass an NSNumber and do case1, case2 etc, but thought it'd be
>> nice to just do the equivalent of passing a function pointer.
> 
> 
> You could create an NSInvocation object and pass that.
> 
> sherm--

It does not seem I can invoke this on the main thread.

Basically I just need to use a function pointer. How does Cocoa do this?

I need to pass either someMethod or someOtherMethod and later call it with

[self performSelectorOnMainThread:theMethod withObject:nil
waitUntilDone:NO];

Is this normally done with NSStringFromSelector and NSSelectorFromString ?


___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Trygve Inda
>> It does not seem I can invoke this on the main thread.
> An NSInvocation?


>> Basically I just need to use a function pointer. How does Cocoa do
>> this?
>> 
>> I need to pass either someMethod or someOtherMethod and later call
>> it with
>> 
>> [self performSelectorOnMainThread:theMethod withObject:nil
>> waitUntilDone:NO];
>> 
>> Is this normally done with NSStringFromSelector and
>> NSSelectorFromString ?
> 


Yes, I am calling this from within a thread, but it needs to run on the main
thread, thus the use of performSelectorOnMainThread



___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Bill Bumgarner

Sigh.  Hit shift-cmd-D a bit too soon. :)


It does not seem I can invoke this on the main thread.

An NSInvocation?

[invocation performSelectorOnMainThread: @selector(invokeWithTarget:)  
withObject: ...whatever... waitUntilDone: NO];


Basically I just need to use a function pointer. How does Cocoa do  
this?


You can get the IMP if you want, but you don't need to for this.

I need to pass either someMethod or someOtherMethod and later call  
it with


[self performSelectorOnMainThread:theMethod withObject:nil
waitUntilDone:NO];

Is this normally done with NSStringFromSelector and  
NSSelectorFromString ?


This specific pattern?  Yes -- encapsulating the selector in a string  
works just fine.


In general?  No.

Generally, if you have something that is going to be doing  
calculations on another thread, you would create an instance of some  
class that encapsulates the calculation.   That class would also have  
the bits necessary to figure out if it needs to call someMethod or  
someOtherMethod on the main thread.


b.bum
___

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

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

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

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


NSWorkspace openURL does not launch application

2009-04-11 Thread Edward Chan
Hello,

It seems that NSWorkspace.openURL() is not launching my default application.
For example, if I try use openURL to open http://www.nhl.com,
Safari/Firefox/etc will not launch and ultimately fail to load the url.
However, if Safari/Firefox is already running, it will open the url in a new
window/tab.

Has anyone encountered a similar problem?

Ed
___

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

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

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

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


Re: NSLog with %f and comparisons using ==

2009-04-11 Thread Michael Ash
On Sat, Apr 11, 2009 at 7:47 PM, James Maxwell
 wrote:
> oh, geez... Okay, you guys made your point! ;-)
>
> One thing I love about this list; I *always* get useful info.
>
> I'll find a better way to do this soon. In this particular case, the "match"
> could be specified as broadly as any value falling within a sort of "bin."
> The "bottoms" of each of these bins are defined by the constant float array.
> So, I could probably just say that any number that falls above the lower
> limit of a bin (i.e., half-way between float A and B), or below the upper
> limit of the bin (half-way between float B and C) is in the bin.
>
> Anyway, these "bins" are fairly far apart so, as I said before, it seems
> pretty safe, for the time being.
> I will clean it up soon.

Sounds like a decent approach. Implementing it as "which of these
numbers is it closest to?" rather than "which of these numbers is it
exactly equal to?" makes everything much more reliable, as long as the
former question is actually useful to your code.

Keep in mind that the imprecisions aren't *arbitrary*, and you can
rely on the computer to do a good job of computing the result (most of
the time... some pathological code can produce radically different
results), it's just that two computers running the same code may not
produce absolutely *identical* results. But with typical float
calculations, the error will be a tiny fraction of a percent.

Mike
___

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

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

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

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


Re: @selector not working with (id)anObject

2009-04-11 Thread Michael Ash
2009/4/11 Trygve Inda :
> [NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
> withObject:@selector(myMethod)];

This should have produced a warning like this:

warning: passing argument 3 of
‘detachNewThreadSelector:toTarget:withObject:’ from incompatible
pointer type

If it didn't, you should find out why, and fix it. If it did, then you
should pay attention to them. Warnings are the compiler's way of
saying that you probably screwed something up. You should turn on
every sane warning available (I personally use -W -Wall
-Wno-unused-parameter as my warning flags) and then ensure that all of
your code compiles without producing any warnings.

Mike
___

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

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

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

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


NSString camel case

2009-04-11 Thread Devraj Mukherjee
Hi all,

My app receives strings from a web service that look like
"everything_else" (no quotes) I would like to convert these strings to
"Everything Else". My initial attempts were going to be using a loop
through the string inspecting it for occurances but I think that will
make the application slow as there are a lot of these strings.

Can I use regular expressions or certainly a better way? Any ideas?

Thanks.

-- 
"The secret impresses no-one, the trick you use it for is everything"
- Alfred Borden (The Prestiege)
___

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

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

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

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


Re: NSString camel case

2009-04-11 Thread Bill Bumgarner

On Apr 11, 2009, at 11:35 PM, Devraj Mukherjee wrote:

My app receives strings from a web service that look like
"everything_else" (no quotes) I would like to convert these strings to
"Everything Else". My initial attempts were going to be using a loop
through the string inspecting it for occurances but I think that will
make the application slow as there are a lot of these strings.

Can I use regular expressions or certainly a better way? Any ideas?


NSString *result = [[originalString  
stringByReplacingOccurrencesOfString:@"_" withString: @" "]  
capitalizedString];


This is about the fastest straightforward means of doing what you  
described, assuming that your strings are as simple as you describe in  
all cases.   There are faster ways, but they aren't nearly so simple.


Thinking something is going to be slow is very different from  
something actually being slow enough to impact your application's  
user's experience.


b.bum



___

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

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

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

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


Re: 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 *originalString = @"everything_else_is_my_name";
NSArray *originalStringComponents,
*resultingComponents;
NSMutableString *result = [NSMutableString string];

originalStringComponents = [originalString
componentsSeparatedByString: @"_"];

for (NSString *currentStringComponent in originalStringComponents)
[result appendString: [NSString stringWithFormat: @"%...@%@",
[currentStringComponent capitalizedString],

(currentStringComponent != [originalStringComponents lastObject] ? @"
" : @"")]];

NSLog(@"%@", result);

(Better-formatted version here: http://pastie.org/444173).

Note that this snippet isn't incredibly efficient, but should get the
point across...

David
___

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

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

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

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


Re: [SOLVED] Rendering OpenGL in timed loop (CoreVideo).

2009-04-11 Thread Brian Bruinewoud

That did it, adding
[[ self openGLContext ] flushBuffer ];
To the end of getFrameForTime: did the trick.

Thanks.

On 12/04/2009, at 03:13 , Michael Ash wrote:

On Sat, Apr 11, 2009 at 2:20 AM, Brian Bruinewoud  
 wrote:
Ok. That "works". I was coming from an NSOpenGLView example where  
the view

sets the context before the drawRect is sent.

Any it, doesn't crash/hang/stop now, but it doesn't draw anything,  
either...

:(


Does identical code placed in drawRect: (without the context setting
stuff, of course) draw? If so, it's probably a flushing problem. Be
sure to flush your GL context before you exit.

I thought of another possible approach. Since NSOpenGLView tries to
act like a regular NSView, it may be sufficient to wrap your calls in
a lockFocus/unlockFocus pair.

Mike
___

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

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

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

This email sent to br...@darknova.com


___

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

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

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

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