• 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: Threadsafe copy of objective c object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threadsafe copy of objective c object


  • Subject: Re: Threadsafe copy of objective c object
  • From: Marcel Weiher <email@hidden>
  • Date: Tue, 03 Sep 2013 20:49:18 +0200

On Sep 3, 2013, at 12:52 , Jonathan Taylor <email@hidden> wrote:

> I have an objective c object which contains a number of properties that serve as parameters for an algorithm. They are bound to UI elements. I would like to take a snapshot copy of the object that will be used for one whole run of the algorithm (rather than risk parameters changing halfway through the run). i.e. I just want to do [myObject copy].

What are the property parameters?  A bunch of numbers, maybe some strings?

> [complications]

> Is there any way, then, that I can take a copy in a threadsafe manner? If necessary I can do the copy on the main thread, but I would prefer not to have to do that for timing reasons.

Unless there is some dire reason not to do this, I would make a copy on the main thread every time the UI changes, and stash that copy somewhere the worker thread can access it easily.

The reasoning is that humans are generally slow compared to computers, so changes are likely going to happen at reasonably slow rate.


-(void)uiDidChange
{
	id newSnapshot=[[parameters copy] autorelease];
	[self setSnapshot:newSnapshot];
}

Marcel

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


References: 
 >Threadsafe copy of objective c object (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: NSSavePanel problem with sandboxing
  • Next by Date: Re: Auto layout semantics?
  • Previous by thread: Re: Threadsafe copy of objective c object
  • Next by thread: NSPanel doesn't reposition correctly after screen resize
  • Index(es):
    • Date
    • Thread