LoginSignup
41
40

More than 5 years have passed since last update.

Xcode6 betaを落としてSwiftを少し触ってみた

Last updated at Posted at 2014-06-03

NDAの制約があるので細かい事までは書けないし、
この中にも問題のある部分があれば指摘して頂きたいと思います。

AppleからSwiftの言語情報が発表されたのでまずはそちらをご紹介。
The Swift Programming Language (iBooks Store)

Xcode6 betaを落として簡単に触ってみたので軽くご紹介したいと思います。

AppDelegateの拡張子はswiftとなっています。
今回RootViewController.swiftを作成してUIWindowのrootViewControllerを設定して、
UILabelでテキストを表示してみました。

AppDelegate.swift
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

        let rootViewController = RootViewController();
        self.window!.rootViewController = rootViewController;

        self.window!.backgroundColor = UIColor.whiteColor()
        self.window!.makeKeyAndVisible()
        return true
    }
}
RootViewController.swift
import UIKit

class RootViewController : UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad();

        let label = UILabel();
        label.frame = CGRect(x: 30.0, y: 30.0, width:200.0, height:200.0);
        label.text = "TEST";

        self.view.addSubview(label);
    }
}

結果はこちら
スクリーンショット 2014-06-03 10.07.39.png

まだ詳しくみてないけどUIKitの概念自体は大きく変わる事は無さそうです。
感覚的にはRuby motionに似てる?かな?
細かい事だけどファイル毎にimportが無くなった様に見えるけどこれはnamespaceのお陰かな。

まだまだ分からない事だらけだけどこれから触るのが楽しみです!

41
40
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
40