Using Playground to debug iOS code

Source: Internet
Author: User

1.Playground Introduction

Playground is a fast-learning code model for Apple Xcode6, which does not have to be engineered to directly see the results of code execution, and has a unique advantage over rapid prototyping, as well as learning language details. The disadvantage is that there is no user interaction input.

I see the examples we use are written using OSX's Code and Class library (which is also the Mac OSX version of playground created by default using the shortcut menu). Looking at Apple's instructions, playground is supported by iOS.

So just look for, how to support the iOS class library.

2. Create Playground

First, when Xcode starts, it displays an interface. The first item above is "Get started with a playground"

Click to create a playground that you can use directly.

However, it is important to note that the Mac OSX version of Playground is created at this time. You can see it from the default referenced library.

Import Cocoa

3. Modify the newly created playground to iOS version.

Select the menu "View", "Utilities", "Show File Inspector", the right side of the window will display the file properties of the sidebar,

Note The playground settings part of the platform, currently Ox X, is changed to iOS.

Automatically generated code on the left after the change is complete. Import cocoa is not the right fit.

Modify the import UIKit used for iOS

In order to use Playground's instant display, you can

Import Xcplayground

This allows you to use the built-in Xcpcapturevalue to aggregate output values.

At this point, you can debug your iOS code with playground.

Note: Be careful next to that option: Resource path, which refers to the relative path of the resource file, if there is a local picture file that requires attention to this path.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.