最新記事 (2 ページ目)
[Swift] GCD関連 [Swift4対応]
キューの作成 (Swift2まで) let queue1 = dispatch_queue_create("arrayQ", DISPATCH_QUEUE_SERIAL) let queue2 = d … &8220;[Swift] GCD関連 [Swift4対応]&8221; の続きを読む
[Swift][Error]Argument labels ‘(_:)’ do not match any available overloads
・エラーメッセージ Argument labels ‘(_:)’ do not match any available overloads ・エラー例 let num = 3 var nsnum = NSNumber(n … &8220;[Swift][Error]Argument labels &8216;(_:)&8217; do not match any available overloads&8221; の続きを読む
Macのsedで改行を出力する
Macのsedで特定の文字を改行に変換したいと思ったことがあると思いますが、Macでは ‘\n’ が出力できません。 $ echo "penapplepenpineapple" | sed &038; … &8220;Macのsedで改行を出力する&8221; の続きを読む
[Swift] Swift3で対象範囲を指定して配列内の要素を削除する
ArrayクラスのremoveSubrangeメソッドを使うと以下のように削除することが出来ます。 var t = [“zero”, “one”, “two”, “three”, “four”] t.removeSubr … &8220;[Swift] Swift3で対象範囲を指定して配列内の要素を削除する&8221; の続きを読む
[Swift] Swift3でArrayにremoveObjectを実装する
NSArrayにはremoveObjectというインデックスではなくオブジェクトを指定して配列内の該当する要素を削除するメソッドがあります。 同じものがSwiftのArrayにもあるかと思ったのですが無く困ってましたが、 … &8220;[Swift] Swift3でArrayにremoveObjectを実装する&8221; の続きを読む
[Swift][Error] Value of type ‘[*]’ has no member ‘*’
・エラーメッセージ Value of type ‘[]’ has no member ‘’ ・エラー例 var x:[Int] = [1,2,3] if x.containsObject(2) { print(“x co … &8220;[Swift][Error] Value of type &8216;[]&8217; has no member &8216;&8217;&8221; の続きを読む
[Swift][Error] Cannot assign value of type ‘[AnyObject]’ to type *
・エラーメッセージ Cannot assign value of type ‘[AnyObject]’ to type ・エラー例 var x:[Int] var y:[AnyObject] = [1,2,3] x … &8220;[Swift][Error] Cannot assign value of type &8216;[AnyObject]&8217; to type &8221; の続きを読む
[Swift][Error] Can’t convert value of type * to expected argument type *
・エラーメッセージ Can’t convert value of type to expected argument type ・エラー例 var y:Double var x:Int = 10 y = 10 + … &8220;[Swift][Error] Can&8217;t convert value of type to expected argument type &8221; の続きを読む
[Swift] インスタンスを比較する
Swiftでインスタンスの内容を比較する場合、比較したいクラスにはisEqualメソッドを実装します。 import Foundation class TestObject : NSObject { var cnt:In … &8220;[Swift] インスタンスを比較する&8221; の続きを読む
[Swift] 文字列リテラル内で変数や定数を使うには
文字列リテラル内で変数や定数を使うには次のようにします。 let y=2016 let m=7 var d=4 var a=”月” print(“今日は \(y)年\(m)月\(d)日 \(a)曜日 です”) // =&038; … &8220;[Swift] 文字列リテラル内で変数や定数を使うには&8221; の続きを読む