LoginSignup
23
19

More than 5 years have passed since last update.

Swift オープンソース化ではじめて知った import の書き方

Last updated at Posted at 2015-12-04

はじめに

Swift のソースをつらつら眺めていたんですが、はじめて知った import の記述を見たので投稿します。

import 例

特定の変数のみのインポート

// 例 
import var Foundation.NSUTF8StringEncoding
// or Playground では let でも大丈夫みたいでした
import let Foundation.NSUTF8StringEncoding 

// 元の定義
// public var NSUTF8StringEncoding: UInt { get }

特定のクラスのみのインポート

import struct Swift.String

// enum, class も同じ形式で大丈夫な模様
import enum UIKit.UILayoutConstraintAxis

特定の関数のみのインポート

import func CoreGraphics.CGRectMake

おわりに

ドキュメント見たらしっかり説明がありました。。

Swift
Import Declaration

23
19
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
23
19