Swift の列挙型 (enum) では列挙子に Int などの Raw 値を設定してプログラムで使えるようになっています。 そんな Raw 値には独自のクラスも使用できます。
注意書き ※この記事はSwift4.1までのものです。 Swift4.2からは CaseIterable が搭載されたのでそちらをお使いください enum SomeType:String, CaseIterable { case A, B, C, D } print(SomeType.allCases) 概要 以前に、 enumの列挙子を配列で取得するのをprotocolでという記事で、Enumで宣言したcaseを配列で返すprotocolを紹介したのですが、 Xcode 8 betaとSwift3.0 preview-1が出たということで、swift3.0に対応するように書き換えてみました。 なぜ作ったか enum に宣言した全てのcaseが配列でほしい時に、
なりゆき segueのidentifierってどうやってつけてるんだろみんな 文字リテラル使いたくないから行き先のViewControllerのクラス名使ってString(HogeViewController.self)ってやってるけど — ひらり (@hiragram) 2016年4月4日 とりあえず事の顛末はツイートを辿ってもらえば全部理解できるんですが折角なので共有をします。 クラス名使ってると、UINavigationControllerとかUITabBarControllerに遷移しようものなら即死ですし、でなくとも複数の画面から指してる場合も死ねますね。よろしくない。 せっかくSwift使ってるんですから幸せになりたいものです。 レベル1 (enum + extension) Protocolを宣言してUIViewControllerにextensionを生やします。 prot
SwiftProtobuf offers many advantages over alternative serialization systems: Safety: The protobuf code-generation system avoids the errors that are common with hand-built serialization code. Correctness: SwiftProtobuf passes both its own extensive test suite and Google's full conformance test for protobuf correctness. Schema-driven: Defining your data structures in a separate .proto schema file cl
This open source project provides the latest CMap resources for Adobe’s public character collections. CMap (Character Map) resources are used to unidirectionally map character codes, such as a Unicode encoding form, to CIDs (Characters IDs, meaning glyphs) of a CIDFont resource. CMap resources, like CIDFont resources, include a /CIDSystemInfo dictionary that specifies /Registry and /Ordering strin
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く