• 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
NSDistantObject error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDistantObject error


  • Subject: NSDistantObject error
  • From: "email@hidden" <email@hidden>
  • Date: Sat, 14 Dec 2002 16:33:17 +0100

Hi,
could someone explain why I got this error?
I launch a thread clicking on a button:
- (IBAction)LaunchTask:(id)sender
{
[tableObject SetArray:logArray];

[NSApplication detachDrawingThread: @selector(ExecuteTask) toTarget:
self withObject: self];
}

LaunchTask and ExecuteTask are both in the object MainObject

- (void)ExecuteTask
{
NSAutoreleasePool *pool;
NSConnection *serverConnection;
int i;

pool = [[NSAutoreleasePool alloc] init];
serverConnection = [NSConnection
connectionWithReceivePort:threadReceivePort sendPort:threadSendPort];
appkitProxy = (MainObject*)[[serverConnection rootProxy] retain];

for(i = 0; i < 100000; i++){
// I do everything here in this loop
// and if I need to update some graphic object, I use
[appkitProxy UpdateTextFields];
}

// then I release the pool
[appkitProxy release];
appkitProxy = nil;
[serverConnection invalidate];
[pool release];
}

My thread was working very fine until I added a new window to the file
"MainMenu.nib".
Just to clarify, UpdateTextFields updates some NSTextFields that are
IBOutlet of the class MainObject. It works very well.

THE ERROR:
I added a new window "LogWindow" to the file "MainMenu.nib" and inside this
window I put a NSTableView.
Then I created and instantiated a new class "LogTable" which is the delegate
and dataSource of the NSTableView.
Then I added an outlet to the class "MainObject" and I connected the class
"MainObject" to the class "LogTable" through the object "tableObject".

During the loop "for(i = 0...)" I need to update the NSTableView, so I
modified the loop this way:
for(i = 0; i < 100000; i++){
[appkitProxy UpdateTextFields];
[appkitProxy UpdateLogWindow];
}

Where:
- (void)UpdateLogWindow
{
[logArray addObject:@"Done"];
[tableObject UpdateArray];
}

In the class "LogTable" I have:
- (void)SetArray:(NSMutableArray*)theArray
{
tableArray = theArray;
}

- (void)UpdateArray
{
[theList reloadData];
}
"theList" is an outlet of the class "LogTable" and it refers to the
NSTableView object.

When my application executes the thread now, it produces an error:
Uncaught exception: <NSObjectInaccessibleException> NSDistantObject access
attempted from another thread


And, if I use
[self UpdateLogWindow];
instead of
[appkitProxy UpdateLogWindow];
my application run better, the LogTable is being update very well, but if I
touch the interface (if I resize the Log Window, or I click on a button,...)
before or during the loop, it produces the same error.

What did I wrong?

--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
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.

  • Prev by Date: Re: Tooltips - what a pathetic joke... :)
  • Next by Date: Re: superclass and awakeFromNib
  • Previous by thread: Re: Breaking
  • Next by thread: Re: superclass and awakeFromNib
  • Index(es):
    • Date
    • Thread