簡體   English   中英

如何在 objc class 的 init 中設置 lldb 斷點

[英]How do I set an lldb breakpoint in init of objc class

我正在調查在哪里制作/呈現了有問題的錯誤配置警報控制器

由於未捕獲的異常“NSGenericException”而終止應用程序,原因:“您的應用程序已從 UP.BVTabBarViewController () 呈現樣式為 UIAlertControllerStyleActionSheet 的 UIAlertController ()。 具有此樣式的 UIAlertController 的 modalPresentationStyle 是 UIModalPresentationPopover。 您必須通過警報控制器的 popoverPresentationController 提供此彈出窗口的位置信息。 您必須提供 sourceView 和 sourceRect 或 barButtonItem。 如果在您呈現警報 controller 時不知道此信息,您可以在 UIPopoverPresentationControllerDelegate 方法 -prepareForPopoverPresentation 中提供它。

我天真地嘗試過這個:

(lldb)  br s -n "-[UIAlertController init]"
Breakpoint 100: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

什么是正確的(工作)方式?

除非您完全錯誤地執行此操作,否則您的警報控制器都是通過調用創建的

+[UIAlertController alertControllerWithTitle:message:preferredStyle:]

然而,這個斷點真的沒有必要,它對你沒有幫助,因為除非你調用導致問題的特定警報,否則你不會遇到斷點。 相反,只需在全局代碼中搜索.actionSheet並修復未配置為彈出框的代碼。

規則是,在 iPad 上,所有操作表都必須明確指定一個源視圖或源欄按鈕項,以便箭頭指向; 當您遇到您沒有這樣做的操作表時,這將立即顯而易見。

為了提供更通用的答案,對於任何 class 您可以執行以下操作:

br s -r '-\[UISomeClass init'
br s -r '\+\[UISomeClass '

第一個在任何以init開頭的方法上創建一個斷點。 第二個匹配所有 class 方法,並為每個方法創建斷點。

兩種方法都沒有涵蓋一種情況:超類方法。 也許不是UIAlertController關心的問題,但通常斷點只能在 class 實現的方法上設置,而不是在繼承的方法上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM