• 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
NSThread/NSMutableArray oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSThread/NSMutableArray oddity
      • From: Matt Majka <email@hidden>
  • Prev by Date: Re: .icns file format?
  • Next by Date: Re: Problem linking to zlib
  • Previous by thread: [ANN] Some new Mulle stuff
  • Next by thread: Re: NSThread/NSMutableArray oddity
  • Index(es):
    • Date
    • Thread