Skip to content

Working with references

aramallo edited this page Sep 14, 2010 · 1 revision

References are instances of the CTKReference class (analogous to Clojure Refs — http://clojure.org/Refs)

Creating a CTKReference

There are 2 ways of creating a reference. One is by invoking one of the initialization methods. In the following example we are creating a reference to a hashMap.


CTKPersistentHashMap *map = [CTKPersistentHashMap emptyHashMap];
CTKReference *ref = [CTKReference referenceWithValue:map];

Alternatively one can create a reference by using the reference convenience method which is added by CTKConcurrency through a category to NSObject.


CTKPersistentHashmap *map = [CTKPersistentHashmap emptyHashMap];
CTKReference *ref = [map reference];
Clone this wiki locally