zoukankan      html  css  js  c++  java
  • 让Playground支持UIKit框架

    http://blog.diveinedu.cn/playground_uikit_ios/

    让Playground支持UIKit框架

    Xcode 6新增了Playground用来学习和测试Swift代码。它能够实时的看到代码的效果,包括变量、终端输出甚至是Cocoa框架中的UI控件,而苹果在WWDC 2014上还演示了SpriteKit框架在Playground中的使用。不过默认情况下Playground只支持Mac的Cocoa框架,如果我们想要在里面测试iOS的UIKit框架就会出错。当然,你可以先新建一个iOS的项目,然后在里面创建Playground。

    其实不需要这么麻烦,Playground也是一个Bundle形式的存在,里面一共有三个文件:

    • contents.xcplayground
    • section-1.swift
    • timeline.xctimeline

    其中contents.xcplayground是这个Playground的配置文件,主要用来说明所使用的平台信息:

    1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    2 <playground version='3.0' sdk='iphonesimulator'>
    3     <sections>
    4         <code source-file-name='section-1.swift'/>
    5     </sections>
    6     <timeline fileName='timeline.xctimeline'/>
    7 </playground>

    其中sdk说明所使用的平台,iphonesimulator表示它可以使用UIKit等iOS上的框架,而默认为macosx。

    因此我们只需要在创建Playground后,将sdk修改为iphonesimulator就可以实时的测试iOS里面控件的效果了!

    Snip20140614_1

  • 相关阅读:
    数据结构进阶——线段树
    基本数据结构—Hash哈希
    NOIP2013提高组 day2 2019.7.15
    基本算法——归并排序
    基本数据结构—Trie
    NOIP 2011 提高组 Day2 校模拟 7.11
    Noip2014提高组真题Day1,2 校模拟7.7
    NOIP2015 提高组 day1 7.8校模拟
    NOIP2008 提高组 6.9校模拟
    STL-#include<set>
  • 原文地址:https://www.cnblogs.com/xuejinhui/p/4616648.html
Copyright © 2011-2022 走看看