vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
ObjectHolder.h
1 
2 #if IPHONE
3 #import <UIKit/UIKit.h>
4 #else
5 #import <Cocoa/Cocoa.h>
6 #endif
7 #import "MAZeroingWeakRef.h"
8 
9 
10 
12 /*
13 \ingroup VVBasics
14 created for working with the MutNRLockArray class.
15 
16 basically, you create an instance of this class and give it a reference to an instance of an object. the instance is NOT retained- but you're now free to pass ObjectHolder to stuff which will otherwise retain/release it without worrying about whether the passed instance is retained/released.
17 
18 if you call a method on an instance of ObjectHolder and the ObjectHolder class doesn't respond to that method, the instance will try to call the method on its object. this means that working with ObjectHolder should- theoretically, at any rate- be transparent...
19 */
20 
21 
22 
23 
24 @interface ObjectHolder : NSObject {
25  BOOL deleted;
26  id object; // a non-retained reference to the object (dumb weak reference)
27  VV_MAZeroingWeakRef *zwr; // retained instance of VV_MAZeroingWeakRef (smart weak reference)
28 }
29 
30 + (id) createWithObject:(id)o;
31 + (id) createWithZWRObject:(id)o;
32 - (id) init;
33 - (id) initWithObject:(id)o;
34 - (id) initWithZWRObject:(id)o;
35 
36 - (void) setObject:(id)n;
37 - (void) setZWRObject:(id)n;
38 - (id) object;
39 
40 @end
holds a weak ref to an NSObject. stupid by default, but can also use a MAZeroingWeakRef, which is a totally frickin sweet class written by the venerable Mike Ash.
Definition: ObjectHolder.h:24