× 目录 [1]let [2]const [3]try 前面的话 尽管函数作用域是最常见的作用域单元,也是现行大多数javascript最普遍的设计方法,但其他类型的作用域单元也是存在的,并且通过使用其他类型的作用域单元甚至可以实现维护起来更加优秀、简洁的代码,比如块作用域。随着ES6的推广,块作用 ...
分类:
编程语言 时间:
2016-07-24 22:25:10
阅读次数:
175
/**点击手势*/ func tapGestureDemo() { //建立手势识别器 let gesture = UITapGestureRecognizer(target: self, action: "viewTap:") //附加识别器到视图 self.view1.addGestureRec ...
分类:
编程语言 时间:
2016-07-24 19:11:25
阅读次数:
171
一、变量 1. LET 我们都习惯用var 来声明变量,现在还可以用let来声明变量,两者的主要区别是作用域:var声明的变量作用域为包围它的函数,而let声明的变量作用域仅在它所在的块中。(在ES5中是没有块的概念的)。 这样使代码更加干净,减少滞留的变量,再如我们经常用的数组遍历: 通常情况下, ...
分类:
其他好文 时间:
2016-07-24 14:52:51
阅读次数:
120
import UIKit class ViewController:UIViewController { overridefunc viewDidLoad() { super.viewDidLoad() let textview = UITextView(frame:CGRect(x: 10,y: ...
分类:
编程语言 时间:
2016-07-24 13:28:39
阅读次数:
179
使用`let`来声明常量,使用`var`来声明变量。 一个常量的值在编译时并不需要获取,但是你只能为它赋值一次。 也就是说你可以用常量来表示这样一个值:你只需要决定一次,但是需要使用很多次。 var myVariable = 42 myVariable = 50 let myConstant = 4 ...
分类:
编程语言 时间:
2016-07-23 19:33:16
阅读次数:
196
2437: English word Description You still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words ...
分类:
其他好文 时间:
2016-07-23 11:57:49
阅读次数:
160
A Chess Game Problem Description Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located ...
分类:
其他好文 时间:
2016-07-22 22:53:15
阅读次数:
179
// Make: 加载 菊花 func _initUIActivityIndicatorView() { let activity = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White ...
分类:
编程语言 时间:
2016-07-22 12:45:53
阅读次数:
167
在这篇文章中,我将为你整理一下 iOS 开发中几种多线程方案,以及其使用方法和注意事项。当然也会给出几种多线程的案例,在实际使用中感受它们的区别。还有一点需要说明的是,这篇文章将会使用 Swift 和 Objective-c 两种语言讲解,双语幼儿园。OK,let's begin! 概述 这篇文章中 ...
分类:
移动开发 时间:
2016-07-22 09:59:21
阅读次数:
367
let命令 1)let声明的变量只在let命令所在的代码块内有效,如: 1 { 2 let a = 10; 3 var b = 1;} 4 5 a // ReferenceError: a is not defined. 6 b // 1 1 { 2 let a = 10; 3 var b = 1; ...
分类:
其他好文 时间:
2016-07-21 21:36:04
阅读次数:
157