How Do I Recover a Stack Trace in Swift? -


how recover stack trace in swift, can find out method last 1 called before crash?

what want replicate in swift method in c#:

public static assembly getcomponentininvocationdegree(int invocationdegree)     {         if (invocationdegree < 0) throw new argumentoutofrangeexception("cannot set out of range value: invocation degree must greater or equal zero");          var stackinvocacion = new stacktrace().getframes();         if (invocationdegree > 0)         {             int invokingassemblyindex = 0;             string currentdegreecomponentname;             try             {                 (int currentdegree = 0; currentdegree < invocationdegree; currentdegree++)                 {                     currentdegreecomponentname = stackinvocacion[invokingassemblyindex].getmethod().reflectedtype.assembly.getname().name;                     while (stackinvocacion[invokingassemblyindex].getmethod().reflectedtype.assembly.getname().name == currentdegreecomponentname) invokingassemblyindex++;                                         }             }             catch (exception ex) { throw new invalidoperationexception(string.format("cannot component in invocation degree: invocation degree {0} not exist", invocationdegree), ex); }              return stackinvocacion[invokingassemblyindex].getmethod().reflectedtype.assembly;         }          return stackinvocacion[0].getmethod().reflectedtype.assembly;     } 

in many cases, use try/catch mechanism.

do {     try ... // risky business goes here } catch let error nserror {     print("error: \(error.domain)")     println(nsthread.callstacksymbols()) }      

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -