import XCPlayground
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
containerView.backgroundColor = UIColor.yellowColor()
XCPlaygroundPage.currentPage.liveView = containerView
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view.center = CGPoint(x: containerView.center.x, y: containerView.center.y-100)
view.backgroundColor = UIColor.redColor()
containerView.addSubview(view)
UIView.animateWithDuration(3, delay: 0, usingSpringWithDamping: 0.1, initialSpringVelocity: 6, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
view.center.y += 100
}, completion:{ (animation: Bool) in
view.center.y -= 100
}
)
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
let url = NSURL(string: "https://avatars1.githubusercontent.com/u/5317671?v=3&s=460")!
let task = NSURLSession.sharedSession().dataTaskWithURL(url) {
data, _, _ in
let image = UIImage(data: data!)
}
task.resume()
let url2 = NSURL(string: "http://www.test.51offer.com/mobile/abroad/query_school_by_name?name=%E4%B8%80")!
let task2 = NSURLSession.sharedSession().dataTaskWithURL(url2) {
data, _, _ in
let str = String(NSString(data: data!, encoding: NSUTF8StringEncoding))
}
task2.resume()