Swiftで、セレクタ(@selector)を指定する。


Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 2692

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798
LINEで送る
Pocket

最近、Swiftでコードを書きまくっています。
新しいことを始めると、面白くて仕方ないですね。

書く度にアドレナリンが出ているのが分かります。
この調子で、メインの部分はSwiftで全て書いてアプリをリリースする予定です。

Objective-Cからの流れでSwiftを書き始めて感じているのは、受け入れやすいなぁということです。
すんなりと、移行できそうです。

Objective-Cで書かれていたUIKitなどのFrameworkもほとんどSwiftに対応しているようなので、その点もすんなり移行できそうと思う部分の一つです。
学習コストがそれほど高くないと感じるからでしょうか。

コードも簡潔でさっぱりして、読みやすいと思うことも多いですし今のところSwiftの方がいいなぁと思うことの方が多いです。

でも、Objective-Cならこうやって書いていたという部分がSwiftではコロっと変わっているとこも結構あります。

体験しながら体で覚える方が性に合っているので、そういうところは場当たり的に潰していって学習しています。

で、セレクタを呼ぶというのも一つ引っかかったところでした。
Objective-Cでは@selectorで、セレクタを指すのですがSwiftではどうするのか。


なんとStringで書けばよいだけでした。
シンプルすぎてびっくりしました。

@selector() in Swift? – Stack Overflow

UITextFieldのデリゲートで、UITextFieldTextDidChangeNotificationを受け取るときを例に挙げますが、以下の様なコードです。

func textFieldDidBeginEditing(textField: UITextField!) {

       NSNotificationCenter.defaultCenter().addObserver(self, selector:"textFieldDidChange:", name: UITextFieldTextDidChangeNotification, object: nil)

 }

func textFieldDidChange(notification:NSNotification) {

        print("change")
}

覚書終わり。

これからも更新を続けていきますので、Feedlyへの登録をお願いします!

follow us in feedly

LINEで送る
Pocket


Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

コメントを残す
Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/jagaimopotato/www/html/blog/wp-includes/formatting.php on line 4798