blob: 89cbbd5c21739063b9fbd51884085219de3d37a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
//
// NSThread+ThreadIndex.m
//
#import "NSThread+ThreadIndex.h"
@implementation NSThread (ThreadIndex)
- (NSInteger)threadIndex {
NSString *description = [self description];
NSArray *keyValuePairs = [description componentsSeparatedByString:@","];
for (NSString *keyValuePair in keyValuePairs) {
NSArray *components = [keyValuePair componentsSeparatedByString:@"="];
NSString *key = components[0];
key = [key stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if ([key rangeOfString:@"num"].location != NSNotFound) {
return [components[1] integerValue];
}
}
return -1;
}
@end
|