logcat的
//1. create the block instance separately
let myBlockForKey1:MyBlock = { () in
print("block for key1 called")
}
//2. create dic of blocks as
let dicOfBlocks:[String:MyBlock] = ["key1":myBlockForKey1]
//3. call your function
MyBlockExecutor.runBlock(from: dicOfBlocks, andKey: "key1")
Java代码
09-14 23:00:23.990 7081-7081/com.example.android.justtjava E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.justtjava, PID: 7081
java.lang.IndexOutOfBoundsException
at android.graphics.Paint.getRunAdvance(Paint.java:2557)
at android.text.TextLine.handleText(TextLine.java:719)
at android.text.TextLine.handleRun(TextLine.java:869)
at android.text.TextLine.measureRun(TextLine.java:387)
at android.text.TextLine.measure(TextLine.java:277)
at android.text.Layout.getHorizontal(Layout.java:943)
at android.text.Layout.getHorizontal(Layout.java:921)
at android.text.Layout.getPrimaryHorizontal(Layout.java:892)
at android.text.Layout.getPrimaryHorizontal(Layout.java:882)
at android.widget.Editor$CursorAnchorInfoNotifier.updatePosition(Editor.java:3950)
at android.widget.Editor$PositionListener.onPreDraw(Editor.java:2968)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2205)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6344)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6236)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)