
我想在Swift中复制的是C#中的这个方法:
public static Assembly GetComponentininvocationDegree(int invocationDegree) { if (invocationDegree < 0) throw new ArgumentOutOfRangeException("Cannot set out of range value: invocation degree must be greater than or equal to zero"); var stackInvocacion = new StackTrace().GetFrames(); if (invocationDegree > 0) { int invokingAssemblyIndex = 0; string currentDegreeComponentname; try { for (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 get component in invocation degree: invocation degree {0} does not exist",invocationDegree),ex); } return stackInvocacion[invokingAssemblyIndex].getmethod().ReflectedType.Assembly; } return stackInvocacion[0].getmethod().ReflectedType.Assembly; } 在许多情况下,您可以使用try / catch机制. do { try ... // risky business goes here} catch let error as NSError { print("Error: \(error.domain)") println(NSThread.callStackSymbols())} 总结 以上是内存溢出为你收集整理的如何在Swift中恢复堆栈跟踪?全部内容,希望文章能够帮你解决如何在Swift中恢复堆栈跟踪?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)