Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// DTWeakSupport.h | ||
// DTFoundation | ||
// | ||
// Created by Oliver Drobnik on 6/3/13. | ||
// Copyright (c) 2013 Cocoanetics. All rights reserved. | ||
// | ||
|
||
/** | ||
Useful defines for building code the compiles with zeroing weak references if the deployment target allows it. This is possible from minimum supported iOS 5.0 and OS X 10.7 and above. Note that on OS X 10.7 some AppKit classes do not support having a weak ref, e.g. NSWindowController or NSViewController. | ||
*/ | ||
|
||
#import <Availability.h> | ||
|
||
#if __has_feature(objc_arc_weak) | ||
|
||
// zeroing weak refs are supported for ivars and properties | ||
#define DT_WEAK_VARIABLE __weak | ||
#define DT_WEAK_PROPERTY weak | ||
|
||
#elif __has_feature(objc_arc) | ||
|
||
/// zeroing weak refs not supported, fall back to unsafe unretained and assigning | ||
#define DT_WEAK_VARIABLE __unsafe_unretained | ||
#define DT_WEAK_PROPERTY assign | ||
|
||
#else | ||
|
||
// define something, as this header might be included in a non-ARC project for using compiled code from an ARC static lib | ||
#define DT_WEAK_VARIABLE | ||
#define DT_WEAK_PROPERTY assign | ||
|
||
#endif |