Permalink
Browse files

Fixing compiler issues when min deployment target is iOS 6+ or Max OS…

… X 10.8+
  • Loading branch information...
robbiehanson committed Jul 7, 2012
1 parent e56aa25 commit bd2959603d6f972c68ec1e6640811ea42097f2ea
@@ -8,6 +8,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; // | XMPP_LOG_FLAG_TRACE;
@@ -57,7 +83,9 @@ - (BOOL)configureWithParent:(XMPPRoster *)aParent queue:(dispatch_queue_t)queue
parent = aParent;
parentQueue = queue;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_retain(parentQueue);
+ #endif
return YES;
}
@@ -68,8 +96,10 @@ - (BOOL)configureWithParent:(XMPPRoster *)aParent queue:(dispatch_queue_t)queue
- (void)dealloc
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
if (parentQueue)
dispatch_release(parentQueue);
+ #endif
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -16,6 +16,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
// Log flags: trace
#if DEBUG
@@ -57,7 +83,9 @@ - (id)initWithRpcID:(NSString *)aRpcID timer:(dispatch_source_t)aTimer
rpcID = [aRpcID copy];
timer = aTimer;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_retain(timer);
+ #endif
}
return self;
}
@@ -77,7 +105,9 @@ - (void)cancelTimer
if (timer)
{
dispatch_source_cancel(timer);
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(timer);
+ #endif
timer = NULL;
}
}
@@ -8,6 +8,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_VERBOSE | XMPP_LOG_FLAG_TRACE;
@@ -337,7 +363,9 @@ - (void)destroyDeleteTimer
if (deleteTimer)
{
dispatch_source_cancel(deleteTimer);
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(deleteTimer);
+ #endif
deleteTimer = NULL;
}
}
@@ -8,6 +8,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; // | XMPP_LOG_FLAG_TRACE;
@@ -76,7 +102,9 @@ - (BOOL)configureWithParent:(XMPPRoom *)aParent queue:(dispatch_queue_t)queue
parent = aParent;
parentQueue = queue;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_retain(parentQueue);
+ #endif
result = YES;
}
@@ -92,8 +120,10 @@ - (BOOL)configureWithParent:(XMPPRoom *)aParent queue:(dispatch_queue_t)queue
- (void)dealloc
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
if (parentQueue)
dispatch_release(parentQueue);
+ #endif
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -7,6 +7,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
// Log flags: trace
#if DEBUG
@@ -340,7 +366,9 @@ - (void)stopPingIntervalTimer
if (pingIntervalTimer)
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(pingIntervalTimer);
+ #endif
pingIntervalTimer = NULL;
}
}
@@ -6,6 +6,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
// Log flags: trace
#if DEBUG
@@ -88,11 +114,8 @@ - (void)dealloc
{
// recalibrationTimer released in [self deactivate]
-
[xmppTime removeDelegate:self];
xmppTime = nil; // Might be referenced via [super dealloc] -> [self deactivate]
-
-
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -360,7 +383,9 @@ - (void)stopRecalibrationTimer
if (recalibrationTimer)
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(recalibrationTimer);
+ #endif
recalibrationTimer = NULL;
}
}

0 comments on commit bd29596

Please sign in to comment.