Playground can display the results of the program in real time, sometimes we use loops or nesting, iterations, then the display of data may have to be batch and contrast, so as to see the results, sometimes we can directly from the image of a glance to know the program is right. Playground supports custom data capture and presentation. You can make comparisons between these graphs, one of which is the Xcpcapturevalue function.
This is the function: Func xcpcapturevalue<t> (identifier:string, value:t), manually capturing historical data, identifier is the name of the title of the chart displayed on the right side of the screen, Value is any data that needs to be captured, because it is possible to capture data in a loop to show the process of data change.
That is, each set of captured data forms a chart, and then the change can be shown in the next loop or next iteration. You can redraw this state diagram each time you change the identifier of the loop. The following is illustrated using an exchange-sorting algorithm, noting the use of Xcpcapturevalue in the program.
Create the playground file in Xcode6 Beta, copy the code from the background of the article to the playground, show the following interface, there are some running results displayed on the right side of the form:
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/
Click the + sign in the lower right corner of the screen to show the chart interface, as shown below. Xcpcapturevalue Advantage is that it is easy to learn and compare, can be a number of algorithms to demonstrate the image.