LoginSignup
0
1

More than 1 year has passed since last update.

【Swift入門】extentionについて

Posted at

extentionとは

・メソッドを用途別に分類して、ソースコードを複数のファイルに分けるためのしくみ
・エクステンションを利用すると、1つの大きなクラスをいくつかのファイルに分割して記述できる

使用例

例えば、

test.swift
class hoge { 
// プロパティの定義   
// メソッドの定義
} 

という記述を、

test.swift
class hoge { 
// プロパティの定義
} 
extention hoge { 
// メソッドの定義(1)
}
extention hoge { 
// メソッドの定義(2)
}

のように分けて記述することができる。
ちなみに、struct(構造体)やenum(列挙型)にも同様にextensionを用いることができる。

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