• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextField refreshes are wacky.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField refreshes are wacky.


  • Subject: Re: NSTextField refreshes are wacky.
  • From: Jonathan Feinberg <email@hidden>
  • Date: Wed, 13 Mar 2002 11:14:46 -0500

At 8:00 PM -0800 3/12/02, Kurt Revis wrote:
You can use DO to communicate across threads, and apparently it's the Apple-suggested way to do it. I think it's overly complicated and confusing, though--I remember trying to do it when I started learning Cocoa, and I just wasted a lot of time floundering. Maybe the documentation is better these days, though.

I did find the documentation a bit disorganized, but I was able to figure it out. These two pages were the key:

http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/DistrObjects/Tasks/vending.html

http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/DistrObjects/Tasks/accessing.html

And here is a minimal example of the technique I used, which is generally applicable to influencing AppKit objects from worker threads.

@protocol StatusProxy
- (oneway void)setStatus:(NSString *)msg;
@end

@interface StatusThing : NSObject <StatusProxy> {
IBOutlet NSTextField *statusField;
}
- (void)setStatus:(NSString *)msg;
@end

@implementation StatusThing
- (void)awakeFromNib // or -init, etc.
{
NSConnection *theConnection = [NSConnection defaultConnection];
[theConnection setRootObject:self];
[theConnection registerName:@"StatusServer"]; // Check for failure in Real Life
}

- (void)setStatus:(NSString *)msg { [statusField setStringValue:msg]; }

- (void)workerThread:(id)arg
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
id controller = [NSConnection
rootProxyForConnectionWithRegisteredName:@"StatusServer"
host:nil];
[controller setProtocolForProxy:@protocol(StatusProxy)];
[controller setStatus:@"Ta dahhhh!"];
[pool release];
}
@end
--
Jonathan Feinberg email@hidden Inwood, NY, NY
http://MrFeinberg.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSTextField refreshes are wacky.
      • From: David Remahl <email@hidden>
References: 
 >Re: NSTextField refreshes are wacky. (From: Kurt Revis <email@hidden>)

  • Prev by Date: Re: PDFImageRep problem from archives
  • Next by Date: Re: NSTextField refreshes are wacky.
  • Previous by thread: Re: NSTextField refreshes are wacky.
  • Next by thread: Re: NSTextField refreshes are wacky.
  • Index(es):
    • Date
    • Thread