LoginSignup
57
57

More than 5 years have passed since last update.

Swiftでクラスメソッド

Last updated at Posted at 2014-06-05

Swiftでのクラスメソッドの書き方

Class.swift
class SomeClass {
    class func someTypeMethod() {
        // type method implementation goes here
    }
}

SomeClass.someTypeMethod()

Objective-Cの場合だと

SomeClass.m
+ (void)someTypeMethod;

となります

追記

Swift1.2より、staticが使用できます。

class SomeClass {
    static func someTypeMethod() {
    }
}
57
57
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
57
57