Re: NSThread and UI

2008-07-20 Thread Bruce Johnson
AppKit stuff isn't thread safe.  AppKit stuff is usually the user
interface stuff (like Progress bars) So that should be run on the main
thread, something like:

> [NSThread detachNewThreadSelector:@selector(convert)
> toTarget:self
>   withObject:nil];
>
> - (void) convert {
>
>
>if (...) {
>NSRunCriticalAlertPanel(...);
>}
>
>int i;
>for(i = 0; i < 10; i++) {
>[self performSelectorOnMainThread: 
> @selector(updateProgressBarWithValue:) withObject: [NSNumber numberWithInt: i 
> waitUntilDone: NO]]
>...
>}
>
>[progressIndicator stopAnimation:self];
> }

- (void) updateProgressBarWithValue: (NSNumber *) aNumber
{
 [progressIndicator setDoubleValue: [aNumber doubleValue]]];
}

or some such...
-- 

Bruce Johnson
[EMAIL PROTECTED]
___

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 [EMAIL PROTECTED]


Escaping white space in an NSString

2009-05-20 Thread Bruce Johnson
I have a unix path in an NSString via [[NSBundle bundleForClass: [self
class]] pathForResource:  etc.. etc..
The problem is that the path has white spaces scattered in the string.
 And I need to pass the unix path to a CLI application.  The CLI app
croaks on the white spaces (for obvious reasons)

Is there a standard Cocoa way of escaping the white spaces like is
done in the Terminal Application (I'm not looking for percent escapes)
that has eluded my searches today?

I also would like it to work in both Leopard and iPhone.

Thanks

-- 

Bruce Johnson
bdjohnso...@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: Escaping white space in an NSString

2009-05-20 Thread Bruce Johnson
> Post your croaking code.  You seem to have some misapprehensions about how
> command-line arguments work,
No misapprehensions here.  Just came up blank after an extended round
of web searches.  I was just wondering if I was overlooking something
obvious. (which is known to happen)


> What CLI were you planning to run on iPhone?
The CLI is for a Cocoa App, but I need to call this in both Leopard and iPhone

char  mdfile[PATHSIZE];
strncpy(mdfile, , MAXREAD);

FILE * stream = fopen(, "rt");

the rest of the c-code iterates over a rather large text file getting
a line at a time, (fgets(inbuff,MAXREAD,stream)) make some
calculations and then go onto the next line.

So as you can see, a non-escaped, white space laden "pathToFile" will
return a bogus FILE *stream.
-- 

Bruce Johnson
bdjohnso...@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