반응형
현재 메소드 호출의 견적 ID
현재 메소드가있는 현재 서열 ID를 인쇄하는 방법이 실행됩니까?
(objective-c 부탁합니다)
NSLog(@"%@", [NSThread currentThread]);
#include <pthread.h>
...
mach_port_t machTID = pthread_mach_thread_np(pthread_self());
NSLog(@"current thread: %x", machTID);
스위프트 3에서
print("Current thread \(Thread.current)")
스위프트에서
print("Current thread \(NSThread.currentThread())")
에서 Swift4
print ( "\ (나사 전류)")
다음과 같이 해킹 할 수 있습니다 (이것은 예쁘게 인쇄 수 있습니다).
+ (NSString *)getPrettyCurrentThreadDescription {
NSString *raw = [NSString stringWithFormat:@"%@", [NSThread currentThread]];
NSArray *firstSplit = [raw componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"{"]];
if ([firstSplit count] > 1) {
NSArray *secondSplit = [firstSplit[1] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"}"]];
if ([secondSplit count] > 0) {
NSString *numberAndName = secondSplit[0];
return numberAndName;
}
}
return raw;
}
참고 URL : https://stackoverflow.com/questions/1616572/getting-thread-id-of-current-method-call
반응형
'IT' 카테고리의 다른 글
Java / Android- 전체 스택 추적을 인쇄하는 방법은 무엇입니까? (0) | 2020.07.17 |
---|---|
SMTP 서버에서 PHP로 이메일 보내기 (0) | 2020.07.17 |
GHCi의 여러 줄 명령 (0) | 2020.07.17 |
100 % 너비 테이블 오버플로 div 컨테이너 (0) | 2020.07.17 |
"mro ()"는 무엇을 씁니까? (0) | 2020.07.17 |