LoginSignup
13
13

More than 5 years have passed since last update.

Swiftで詰まったとこ

Last updated at Posted at 2014-08-07

逐次更新

data

dataという変数があると思っていて使おうとするもmodule is not convertible to~というエラーが出て使えなかった
→Swiftのdataモジュールというのが定義されていた
→試してないけどdataという変数名は使えないのでは

CGクラスのUnmanaged

返り値にUnmanagedがついているものはSwiftのメモリマネジメントに入れてやらないとそのまま使えない
→cgImage = unmanagedCGImage.takeRetainedValue()
参考: http://stackoverflow.com/questions/24215757/using-unmanagedanyobject-as-key-in-nsmutabledictionary

UICollectionViewCellサブクラスを使用するとき

なんか詰まったんだけど忘れた。なんだったかな…

readonly property

セッタを定義していないプロパティに値をセットしようとするとコンパイルエラーになる


    var hoge: Hoge! {
        get {
            return (何か処理)
        }
    }

マクロ

ないっぽい

数値をフォーマットして文字列に変換

こんなん


String.localizedStringWithFormat("%02d", index)

Precision String Format Specifier In Swift - Stack Overflow - http://stackoverflow.com/questions/24051314/precision-string-format-specifier-in-swift/25915588#25915588

Macros in Swift? - Stack Overflow - http://stackoverflow.com/questions/24114288/macros-in-swift

CocoaPods

Masonry

そのほか

Swiftじゃないけど
http://d.hatena.ne.jp/ntaku/20110110/1294632603

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