일모도원(日暮途遠) 개발자
[iOS개발] print()와 debugPrint() 차이 본문
반응형
print()는 콘솔에 내용을 표시하고자 할때 사용한다. (릴리즈모드에서도 사용하면 속도저하가 있으므로 디버그일때만 쓰자)
debugPrint()는 print()와 비슷하게 보이는데 이름을 보면 뭔가 debug할때 쓸거 같다.
실제로 보면 debugPrint는 그냥 쌍따옴표만 더 붙어있는거 같다. 이정도면 굳이 debugPrint를 쓸필요가 없어보인다.
print("print") //print
debugPrint("debugPrint") //"debugPrint"
하지만 API를 호출해서 결과물을 볼때는 확연하게 다르다.
아래 코드가 실행되어 response를 보고자 할때 확실히 debugPrint가 많은 정보를 보여준다.
AF.request(url, method: .post, parameters: try? data.json())
.validate().responseDecodable(of: LoginResponse.self) { response in
debugPrint(response)
print(response)
}
debugPrint(response)의 결과 : success위에도 내용이 엄청 많다.
[Request]: POST http://192.168.0.23:8080/mobileLogin.ajax
[Headers]:
Content-Type: application/x-www-form-urlencoded; charset=utf-8
[Body]: 57 bytes
[Response]:
[Status Code]: 200
[Headers]:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Access-Control-Allow-Methods: GET,HEAD,OPTIONS,POST,PUT
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json;charset=UTF-8
Date: Fri, 24 Feb 2023 10:01:38 GMT
Keep-Alive: timeout=20
Set-Cookie: JSESSIONID=8681DEAC294C8770DDD8D9E4C74D; Path=/; HttpOnly, UID=2285; Max-Age=604800; Expires=Fri, 03 Mar 2023 10:01:38 GMT, TOKEN=ji@ji.com-|-QGjXP7+IAhghPBQuw==; Max-Age=604800; Expires=Fri, 03 Mar 2023 10:01:38 GMT
Transfer-Encoding: Identity
[Body]: {~~~~~~~~~~~~~~~}
[Network Duration]: 0.07575500011444092s
[Serialization Duration]: 0.0008314166916534305s
[Result]: success(AraKoica.LoginResponse(~~~~~~~~~~~~~~~~~~)
print(response)를 했을때의 결과 : success 내용만 보여준다.
success(AraKoica.LoginResponse(~~~~~~~~~~~~~~~~~~~~)
디버깅을 할때는 debugPrint()를 사용하자.
반응형
'iOS개발 > iOS개발' 카테고리의 다른 글
[iOS개발] 인앱관련 Sandbox관련 리젝 (0) | 2024.05.07 |
---|---|
[iOS개발] SwiftSoap로 \n 문자 추출하기 (1) | 2023.09.23 |
[iOS개발] 파일앱(Files App)에 내 앱 보이기 (0) | 2022.09.04 |
[iOS개발] 앱 평가 요청하기 (0) | 2022.09.04 |
[iOS개발] 앱id (App id, Apple id) 찾기 (0) | 2022.09.04 |