0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

@mainってなに!?!? - iOS Swift

0
Posted at

iOSのアプリ作成を始めたら急に出てきた@main。。。
なにこれ?
気になって仕方ない

エントリーポイント

「エントリーポイント」と調べたら出てくると思いますが、終わりました。
なにエントリーポイントって。

エントリーポイントとはプログラムが始まる最初の場所です。
iOSやAndroidに限らず、プログラムには一番最初に実行されるコードがあります。
iOSにおいては、@mainを書くことで最初に実行するコードを指定します。

import SwiftUI

@main
struct プロジェクト名: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

ちなみに@mainを複数のクラスや構造体などに指定するとエラーになります。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?