Use DISPATCH_CURRENT_QUEUE_LABEL if available #156

Merged
merged 6 commits into from Nov 7, 2013

Conversation

Projects
None yet
4 participants
Contributor

kolyuchiy commented Nov 5, 2013

A better way to get current queue label on iOS 7.
Issue #108, Issue #121.

cbowns commented on 0d80367 Nov 6, 2013

What's the logic intended to be here, only call get_label on iOS < 7.0?

kolyuchiy added some commits Nov 6, 2013

@kolyuchiy kolyuchiy Fix compilation on earlier SDKs
Check if DISPATCH_CURRENT_QUEUE_LABEL is defined.
31196bb
@kolyuchiy kolyuchiy Add comments 52f267e
Contributor

kolyuchiy commented Nov 6, 2013

Using DISPATCH_CURRENT_QUEUE_LABEL works only if the SDK is 7.0+ and the app is running under iOS 7.0+.

Not equals "ascending" here means that the iOS version should be not less than 7.0.

@rivera-ernesto rivera-ernesto and 1 other commented on an outdated diff Nov 6, 2013

Lumberjack/DDLog.m
+#ifdef DISPATCH_CURRENT_QUEUE_LABEL
+ // If compiling with iOS 7.0+ SDK for any deployment target
+ if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
+ // If runtime environment is iOS 7.0+
+ queueLabel = dd_str_copy(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));
+ }
+ else {
+ queueLabel = dd_str_copy("");
+ }
+#elif __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
@rivera-ernesto

rivera-ernesto Nov 6, 2013

Member

Maybe its cleaner to use __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 here.

@kolyuchiy

kolyuchiy Nov 6, 2013

Contributor

Fixed.

@rivera-ernesto rivera-ernesto and 1 other commented on an outdated diff Nov 6, 2013

Lumberjack/DDLog.m
+#ifdef DISPATCH_CURRENT_QUEUE_LABEL
@rivera-ernesto

rivera-ernesto Nov 6, 2013

Member

For clarity this could be __IPHONE_OS_VERSION_MAX_REQUIRED >= __IPHONE_7_0 right?

@kolyuchiy

kolyuchiy Nov 6, 2013

Contributor

I prefer to test for functionality rather than for version when possible. But in this case it does not matter.

@rivera-ernesto rivera-ernesto and 1 other commented on an outdated diff Nov 6, 2013

Lumberjack/DDLog.m
+#ifdef DISPATCH_CURRENT_QUEUE_LABEL
+ // If compiling with iOS 7.0+ SDK for any deployment target
+ if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
+ // If runtime environment is iOS 7.0+
+ queueLabel = dd_str_copy(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));
@rivera-ernesto

rivera-ernesto Nov 6, 2013

Member

From dispatch_queue_get_label(dispatch_queue_t queue) documentation:

queue
This parameter cannot be NULL.

But in queue.h:

#define DISPATCH_CURRENT_QUEUE_LABEL NULL

@kolyuchiy

kolyuchiy Nov 6, 2013

Contributor

Probably this documentation has not been updated. You can find more recent documentation in dispatch/queue.h header file.

@rivera-ernesto

rivera-ernesto Nov 7, 2013

Member

You're right!

Member

rivera-ernesto commented Nov 7, 2013

Thanks for the updates!

Let's give a good test before releasing 1.6.3.

@rivera-ernesto rivera-ernesto added a commit that referenced this pull request Nov 7, 2013

@rivera-ernesto rivera-ernesto Merge pull request #156 from denivip/current-queue-ios7
Use DISPATCH_CURRENT_QUEUE_LABEL if available
dadf95e

@rivera-ernesto rivera-ernesto merged commit dadf95e into CocoaLumberjack:master Nov 7, 2013

@rivera-ernesto rivera-ernesto added a commit to rivera-ernesto/CocoaLumberjack that referenced this pull request Nov 8, 2013

@rivera-ernesto rivera-ernesto Stop ignoring deprecation warnings
No longer necessary after pull requests #121 and #156, and more importantly, that was ugly.
c4d3332

rivera-ernesto referenced this pull request Nov 8, 2013

Merged

Fix build on OS X #159

If you use __IPHONE_7_0 when build under Xcode 4.6.3, it will cause building error due to __IPHONE_7_0( I mean __IPHONE_7_0 may be considered as 0) is undefined. should use 70000 instead

Member

rivera-ernesto replied Nov 8, 2013

You're right. That was one of the reasons why I was using #if XCODE_VERSION_MAJOR >= 0500 in another project.

BTW I'm trying to fix this and other issues in #159.

Great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment