根據類名來跳轉對應介面

2021-07-22 20:28:14 字數 1103 閱讀 4445

//根據類名來跳轉對應介面

-(void)pushtoviewcontrollerwithclassname:(nsstring *)classname

@catch (n***ception *exception)

@finally

}}

有關執行時的知識點,請檢視我的關於執行時的系列文章:runtime從入門到精通

使用@try、catch捕獲異常:

以下是最簡單的**寫法,其中@finally可以去掉:

@try 

@catch (n***ception *exception)

@finally

在這裡舉多一具比較詳細的方法,丟擲異常:

@try 

@catch (n***ception *exception)

@finally

// 4

// 這裡一定會執行

nslog(@"try");

trytwo方法**:

- (void)trytwo

@catch (n***ception *exception)

@finally

// 9

// 如果丟擲異常,那麼這段**則不會執行

nslog(@"如果這裡丟擲異常,那麼這段**則不會執行");

}

為了方便大家理解,我在這裡再說明一下情況:

如果6丟擲異常,那麼執行順序為:1->5->6->8->3->4

如果6沒丟擲異常,那麼執行順序為:1->5->7->8->9->3->4

部分情況的崩潰我們是無法避免的,就算是qq也會有崩潰的時候。因此我們可以在程式崩潰之前做一些「動作」(收集錯誤資訊),以下例子是把捕獲到的異常傳送至開發者的郵箱。

nssetuncaughtexceptionhandler(&uncaughtexceptionhandler);

return yes;

}void uncaughtexceptionhandler(n***ception *exception)

根據類名來跳轉對應介面

根據類名來跳轉對應介面 void pushtoviewcontrollerwithclassname nsstring classname catch n ception exception finally 有關執行時的知識點,請檢視我的關於執行時的系列文章 runtime從入門到精通 使用 try...

跳轉到對應的系統介面

跳轉到對應的系統介面 public class intentutil 進入撥號介面 public static void dial activity activity,string phonenumber 直接撥號 需要許可權 android.permission.call phone public...

類名,抽象類名,介面類名

類名 類名作為形參和返回值型別時,呼叫方法傳遞的是該類的物件 貓類 public class cat 貓操作類 public class catoperator public cat geteat 貓的測試類 public class catdemo 抽象類名 抽象類名作為形參和返回值型別時,呼叫方...