NSThread/NSMutableArray oddity
NSThread/NSMutableArray oddity
- Subject: NSThread/NSMutableArray oddity
- From: Matt Majka <email@hidden>
- Date: Thu, 11 Apr 2002 17:08:49 -0600
Hi!
I've got a relatively simple plotting application that uses the
main application thread to handle everything except data
collection and computation. There is a separate NSThread
that I create that collects data over TCP/IP and sends a
message to a plotting object to add the new data to the
plot. There can be up to 12 different data series plotted at
the same time and some of them may require scaling to fit on
the plot. I keep an NSMutableArray of NSNumbers representing
the scale values in my plotting object and the UI controls are
the only way to change these values. The plotting method
(-drawRect: of an NSOpenGLView subclass) simple reads
the values and scales the data points respectively.
I use the -setNeedsDisplay: method any time a point
is added to the plot or the scaling is changed. I hope
that is somewhat clear. Now for my problem. The
-drawRect: method never sees the changes to the
NSMutableArray scaling values. I can see the change
occur by using NSLog() in the method that the UI object
invokes to change the scale values, however the -drawRect:
method only sees the values that were in place upon initialization.
I didn't think synchronization would be a problem initially since
the array can only be written in one place and from one thread.
However, I have since tried using NSLock and a DO implementation
in an attempt to get the scaling values seen by the -drawRect:
method. All three implementations behave the same way.
Any ideas would be greatly appreciated as I am relatively
new to Cocoa.
Matt
_______________________________________________
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.