Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Set the name of the network thread #871

wants to merge 2 commits into from

6 participants


This makes debugging a lot nicer.



Ah geez, that is a world of a difference.


 [NSThread currentThread].name = @"AFNetworking";

Didn't your parents teach you your manners about mixing dot and bracket syntax? ;)


TIL you can use dot syntax on classes. Thanks, @mattt. :)


TIL you can use dot syntax on classes.

Oh, no no no no no. But how will we separate ourselves from the uncleaned masses of scripting languages?!

Call me old-fashioned, but [[NSThread currentThread] setName:@"AFNetworking"]; looks quite handsome to me.


+1 @Mattt :)


I think I like the []. form; currentThread isn't really a property of the class, but name is a property of the instance.

But, you know:

#include "DotSyntaxArgument.h"

Yes, #include. #import's semantics are not appropriate here.


I have to agree with @mattt here, but for another reason: the NSThread header declares set name as:

- (void)setName:(NSString *)n NS_AVAILABLE(10_5, 2_0);

Aside from simply respecting the headers as declared, there is a benefit to conforming to property vs. method syntax: When you paste code into LLDB that uses dot syntax but the interface declares a method it gives you shit:

(lldb) po [NSThread currentThread].name
error: property 'name' not found on object of type 'id'
error: 1 errors parsing expression
(lldb) po [[NSThread currentThread] name]
$2 = 0x02e77844 <object returned empty description>

If you follow the convention, then you can often just copy arbitrary portions of code and introspect it in the debugger. Going with whatever you feel like means you will be doing casts within LLDB to see values for arbitrary objects.


Good point, @blakewatters.


[[GitHubThread currentThread] setBikeShedColor:color includesSurprisingLevelOfInsight:YES];


I'm OK with either way, as long as this one gets merged :)

@mattt I did change the commit extra for AFNetworking, I used this in my code: = @"AFNetworking";

And I know that it's not declared as property, but it behaves like a property. (isn't that what ObjC is all about?)

@blakewatters Good catch. Let's hope the lldb people continue working on it, since the debugger could infer the type from currentThread (it's declared as NSThread, not id). I bet this will work at some point.


Yes yes. The dot syntax conversation is interesting, but @#$%!!! We can fix the thread name.


Merged! bab6a8b

@mattt mattt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2013
  1. @steipete

    Set the name of the network thread.

    steipete authored
    This makes debugging a lot nicer.
Commits on Mar 29, 2013
  1. @steipete
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  AFNetworking/AFURLConnectionOperation.m
1  AFNetworking/AFURLConnectionOperation.m
@@ -159,6 +159,7 @@ @implementation AFURLConnectionOperation
+ (void) __attribute__((noreturn)) networkRequestThreadEntryPoint:(id)__unused object {
do {
@autoreleasepool {
+ [[NSThread currentThread] setName:@"AFNetworking"];
[[NSRunLoop currentRunLoop] run];
} while (YES);
Something went wrong with that request. Please try again.