HTML text -> UILabel 적용을 위해 NSMutableAttributedString 변환 시 크래시 발생

상황

서버에서 내려주는 HTML text를 UILabel로 적용하기 위해 아래와 같이 변환하려 함 let attributedString = try? NSMutableAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)디버그 시 크래시 발생


에러 메세지

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1aef22a18)


해결 방법


Malloc Stack Logging을 꺼주자.

스크린샷 2025-03-12 오후 3.37.53.png
스크린샷 2025-03-12 오후 3.38.03.png

 

이유

NSMutableAttributedString 변환 시 WebKit인가를 사용하는데 원래 Malloc Stack Logging을 키고 Web 썸띵을 사용하면 디버그 모드에서 크래시가 발생했음(...) Xcode 버그인가? 명확한 원인은 좀 더 탐구가 필요하다.

  let attributedString = try? NSMutableAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) 

 

귀속 = 시도하자? nsMutableAttRiptedString (데이터 : 데이터, 옵션 : [nsattriptedString.DocumentReadingOptionKey.DocumentType : nsAttRibutedString.documentType.html], DocumentAttributes : NIL)
 
귀속 = 시도하자? nsMutableAttRiptedString (데이터 : 데이터, 옵션 : [nsattriptedString.DocumentReadingOptionKey.DocumentType : nsAttRibutedString.documentType.html], DocumentAttributes : NIL)
 
귀속 = 시도하자? nsMutableAttRiptedString (데이터 : 데이터, 옵션 : [nsattriptedString.DocumentReadingOptionKey.DocumentType : nsAttRibutedString.documentType.html], DocumentAttributes : NIL)
 
귀속 = 시도하자? nsMutableAttRiptedString (데이터 : 데이터, 옵션 : [nsattriptedString.DocumentReadingOptionKey.DocumentType : nsAttRibutedString.documentType.html], DocumentAttributes : NIL)
 
귀속 = 시도하자?
 
귀속 = 시도하자?
 
nsmutableattriptring
 
nsmutableattriptring
 
Malloc 스택 로깅
 
Malloc 스택 로깅
 

'iOS > iOS Troubleshooting' 카테고리의 다른 글

iOS 12 - NSInternalInconsistencyException  (0) 2025.02.03