iOS 기본 (swift)
[iOS - swift] print vs NSLog
jake-kim
2021. 2. 24. 23:49
print와 NSLog의 차이
- NSLog는 String타입만 입력 가능
print(1)
NSLog(1) // Cannot convert value of type 'Int' to expected argument type 'String'
- NSLog는 time stamp와 Project이름이 같이 출력
let sample = 123
print("this is print = \(sample)") // this is print = 123
NSLog("this is NSLog = \(sample)") // 2021-02-24 23:35:53.363868+0900 NSLog[5403:871822] this is NSLog = 123
- NSLog는 print에 비하여 매우 느린 performance
- NSLog는 multi thread 환경에서 사용, overlapping되지 않고 출력
- print는 multi thread 환경에서 사용하지 않고, overlapping되며 출력
* 참고