```

... earlier we said top-level code isn’t allowed in most of your app’s source files. The exception is a special file named “main.swift”, which behaves much like a playground file, but is built with your app’s source code. The “main.swift” file can contain top-level code, and the order-dependent rules apply as well. In effect, the first line of code to run in “main.swift” is implicitly defined as the main entrypoint for the program. This allows the minimal Swift program to be a single line — as long as that line is in “main.swift”.

```

原因就是你把print等等表达式放到其他文件去了。在main.swift这个文件中写就没问题

知道怎么改就可以了。如果不满足的话,可以看看上面这段官方代码,写得真好

文/把时间当做朋友(简书作者)
原文链接:http://www.jianshu.com/p/6bc97afd9478
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

swift错误 Expressions are not allowed at the top level的更多相关文章

  1. 【104】Maven3.5.0结合eclipse使用,提示Lambda expressions are allowed only at source level 1.8 or above错误的解决方法

    错误重现 我的机器上安装了 maven 3.5.0,在 eclipse 中创建 maven 项目.pom.xml配置如下: <project xmlns="http://maven.a ...

  2. lambda expressions are not supported at this language level

    IDEA下报错:lambda expressions are not supported at this language level 解决: 1. File -> Project Struct ...

  3. 关于idea中使用lamb表达式报错:ambda expressions are not supported at this language level

    我使用的是jdk1.8,使用lamb表达式的时候,报错 ambda expressions are not supported at this language level, 后来,设置了 接着重启了 ...

  4. AS报错:lambda expressions are not supported at this language level

    AS报错:lambda expressions are not supported at this language level 解决方法 打开打开 File --> Project Stuct ...

  5. swift错误和异常处理

    异常 (exception) 和错误 (error). 在 Objective-C 开发中,异常往往是由程序员的错误导致的 app 无法继续运行,比如我们向一个无法响应某个消息的NSObject 对象 ...

  6. 学习Swift -- 错误处理

    错误处理 错误处理是响应错误以及从错误中返回的过程.swift提供第一类错误支持,包括在运行时抛出,捕获,传送和控制可回收错误. 一些函数和方法不能总保证能够执行所有代码或产生有用的输出.可空类型用来 ...

  7. Swift 错误记录

    最近几天开始学习Swift,作为一个从 OC 转到 Swift 的程序员,我一直以为很简单.但是现在学习一个星期之后,发现问题还是蛮多的! 最大的问题就是 太特么 不习惯了!!!!!!!!!! 好吧, ...

  8. swift 错误集锦

    1.注册 NIB 出现错误 // error:'registerNib(_:forCellReuseIdentifier:)' has been renamed to 'register' (_:fo ...

  9. [Swift]错误提示:Method does not override any method from its superclass

    问题原因:方法名称书写错误! ViewController 生命周期 // 加载视图时会调用该方法 override func loadView() { super.loadView() print( ...

随机推荐

  1. CSS display:inline-block

    CSS display:inline-block 在css布局里,我们经常看到代码 「display:inline-block; *display:inline; zoom:1; 」,大多人会说上面的 ...

  2. NSRunLoop的进一步理解

    iPhone应用开发中关于NSRunLoop的概述是本文要介绍的内容,NSRunLoop是一种更加高明的消息处理模式,他就高明在对消息处理过程进行了更好的抽象和封装,这样才能是的你不用处理一些很琐碎很 ...

  3. CUDA[1] Introductory

    Section 0 :Induction of CUDA CUDA是啥?CUDA®: A General-Purpose Parallel Computing Platform and Program ...

  4. python gettitle.py

    #!/usr/bin/env python # coding=utf-8 import threading import requests import Queue import sys import ...

  5. Xamarin.ios 重新定位视图

    //旋转手机重新定位视图 /// <summary> /// 重新定位视图 /// </summary> /// <param name="toInterfac ...

  6. 安装php openssl扩展

    安装openssl扩展 cp config0.m4 config.m4 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/loc ...

  7. 2016福州大学软件工程第五、六次团队作业-Alpha阶段成绩汇总

    1.本次作业成绩统计结果: 本次Alpha阶段团队作业公布如下: 表格说明: PE:贡献百分比 YS:演示评分(满分15分) BK:博客评分(满分15分) SH:事后诸葛亮环节(满分5分) P:个人分 ...

  8. nandflash的读写(2440)

    说明: 根据物理结构上的区别 , NandFlash主要分为如下两类:1)•SLC (Single Level Cell): 单层式存储2)•MLC (Multi Level Cell): 多层式存储 ...

  9. Tengine 安装配置全过程

    Tengine官网上有个非常简单的教程,中间并未涉及到一些常用的设置,所以仅供参考.一下午为本人的安装步骤及过程. 1.安装必要的编译环境好 由于Tengine安装需要使用源代码自行编译,所以在安装前 ...

  10. windows 64位 安装apache+php+mysql

    1.下载PHP.Apache和Mysql软件以及VC库. 下面分别是PHP.Apache和Mysql的官网地址. PHP:http://windows.php.net/qa/ 注意 选择Thread ...