| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
4,752 バイト追加 、 2024年9月12日 (木) 10:53
=====[https://www.typea.info/blog/index.php/2022/03/08/xamarin_mac_app_storyboard/ storyboard]=====
*[https://www.typea.info/blog/index.php/2022/03/08/xamarin_mac_app_storyboard/ storyboard]
 
=====[https://www.typea.info/blog/index.php/2022/03/13/storyboard_childwindow_macos/ 子画面表示]=====
*[https://www.typea.info/blog/index.php/2022/03/13/storyboard_childwindow_macos/ storyboard を使って子画面を表示]
 
=====[https://www.typea.info/blog/index.php/2022/03/15/storyboard_segue_connect_screen/ segue(セグエ)で画面遷移]=====
----
*[https://www.typea.info/blog/index.php/2022/03/15/storyboard_segue_connect_screen/ storyboard segue(セグエ)で画面遷移]<
 
*segueを呼び出し画面遷移させる
<pre>
//呼び出し元
performSegue(withIdentifier: "some_segue_id", sender: nil)
</pre>
=====[https://www.typea.info/blog/index.php/2022/06/04/ios_swift_navigation_controller/ Navigation Controller ナビゲーションバー]=====
*[https://www.typea.info/blog/index.php/2022/06/04/ios_swift_navigation_controller/ NavigationController ナビゲーションバー]
 
=====[https://www.typea.info/blog/index.php/2022/03/12/interfacebuilder_storyboard_tabview_screentransition/ Tab Viewの利用と画面遷移]=====
*[https://www.typea.info/blog/index.php/2022/03/12/interfacebuilder_storyboard_tabview_screentransition/ storyboard を使って Tab Viewの利用と画面遷移]
=====[https://www.typea.info/blog/index.php/2022/03/11/nstableview_celbased/ NSTableView CellBased]=====
*[https://www.typea.info/blog/index.php/2022/03/23/nstableview_viewbased_macos/ NSTableView ViewBased]
=====[https://www.typea.info/blog/index.php/2022/04/03/nsalert_macos/ NSAlert ダイアログ]=====
*[https://www.typea.info/blog/index.php/2022/04/03/nsalert_macos/ NSAlert ダイアログ]
 
====AutoLayout====
----
=====[https://www.typea.info/blog/index.php/2022/03/26/autolayout_concept/ AutoLayout概要]=====
*[https://www.typea.info/blog/index.php/2022/03/26/autolayout_concept/ AutoLayout概要]
*[https://www.typea.info/blog/index.php/2022/05/30/swift_ios_chart/ AutoLayout簡易操作 TinyConstraint]
====画面遷移====----*https://qiita.com/superman9387/items/c006ced215352f28a7b9=====[https://www.typea.info/blog/index.php/2022/03/13/storyboard_childwindow_macos/ 子画面表示]=====*[https://www.typea.info/blog/index.php/2022/03/13/storyboard_childwindow_macos/ storyboard を使って子画面を表示]=====[https://www.typea.info/blog/index.php/2022/0403/15/storyboard_segue_connect_screen/ segue(セグエ)で画面遷移]=====----*[https://www.typea.info/blog/index.php/2022/03/nsalert_macos15/storyboard_segue_connect_screen/ storyboard segue(セグエ)で画面遷移]*segueを呼び出し画面遷移させる<pre>//呼び出し元performSegue(withIdentifier: "some_segue_id", sender: nil)</pre>=====[https://www.typea.info/blog/ NSAlert ダイアログindex.php/2022/06/04/ios_swift_navigation_controller/ Navigation Controller ナビゲーションバー]=====*[https://www.typea.info/blog/index.php/2022/06/04/ios_swift_navigation_controller/ NavigationController ナビゲーションバー]=====[https://www.typea.info/blog/index.php/2022/03/nsalert_macos12/interfacebuilder_storyboard_tabview_screentransition/ Tab Viewの利用と画面遷移]=====*[https://www.typea.info/blog/index.php/2022/03/12/interfacebuilder_storyboard_tabview_screentransition/ NSAlert ダイアログstoryboard を使って Tab Viewの利用と画面遷移]
==コマンドライン==
[3] = 4
}
</pre>
 
====スライス====
<pre>
8> l
$R5: [Int] = 8 values {
[0] = 1
[1] = 2
[2] = 3
[3] = 4
[4] = 5
[5] = 6
[6] = 7
[7] = 8
}
9> l[2..<5]
$R6: ArraySlice<Int> = 3 values {
[2] = 3
[3] = 4
[4] = 5
</pre>
</pre>
===辞書 [https://developer.apple.com/documentation/swift/dictionary Dictionary<Key, Value>]===
----
*キーと値をもつコレクション
3>
</pre>
*====削除====
<pre>
3> sex.removeValue(forKey:"1")
}
}
</pre>
====空の辞書====
<pre>
var emptyDict: [String: String] = [:]
</pre>
$R0: Bool = true
</pre>
===イテレーター===
[https://developer.apple.com/documentation/swift/iteratorprotocol IteratorProtcol]
<pre>
let animals = ["Antelope", "Butterfly", "Camel", "Dolphin"]
var animalIterator = animals.makeIterator()
while let animal = animalIterator.next() {
print(animal)
}
</pre>
 
==演算子==
*C言語の演算子はほぼ使える
lazy var プロパティ名 : プロパティ型 = 式
</pre>
 
===KeyPath===
*https://qiita.com/imchino/items/67a987681bca5ad0408b
*「あるデータ型に定義されたプロパティまでの参照(パス)」です。
*キーパス式は、型のプロパティまたは添え字を参照する。
*キー・値監視などの動的プログラミングタスクでは、キーパス式を使用する。
<pre>
\<#type name#>.<#path#>
</pre>
 
==サブスクリプト==
*コレクションへの統一的なアクセス手法
8> r.reduce("", {result, element in result + "-" + String(element) })
$R3: String = "-1-2-3"
</pre>
=====カウントを取る =====
<pre>
let count = sequence.reduce(0) { acc, row in acc + 1 }
</pre>
*lastプロパティ
====変換=========Array -> Set =====<pre> 1> let ary: [Int] = [3,2,3,2]ary: [Int] = 4 values { [0] = 3 [1] = 2 [2] = 3 [3] = 2} 2> print(Set(ary))[3, 2]</pre>===== Set -> Array =====<pre> 6> let set: Set<Int> = [3,4,5,6]set: Set<Int> = 4 values { [0] = 4 [1] = 6 [2] = 3 [3] = 5} 7> print(Array(set))[4, 6, 3, 5]</pre> ==クロージャ==*基本*https://qiita.com/atsuastu_jr/items/e3a6990127d96c39a167
<pre>
{ 引数 in 戻り値を返す式 }
<pre>
hello,swift!
</pre>
 
===コールバックにクロージャを利用する例===
*非同期処理の結果をクロージャを用いて呼び出し元に返す
<pre>
static func accessRequest(completion:((String?) -> Void)?) {
let allTypes = Set([
HKQuantityType.quantityType(forIdentifier: .bodyMass)!,
/* HKQuantityType.quantityType(forIdentifier: .stepCount)!,*/
])
 
self.getHealthStore()?.requestAuthorization(toShare: allTypes, read: allTypes) { (success, error) in
if success {
completion?("アクセス許可: \(String(describing: success))")
} else {
completion?("アクセス不許可: \(String(describing: error?.localizedDescription))")
}
}
}
</pre>
hello,swift!
</pre>
 
===例===
* Message.user.name の重複を取り除き、","で連結して返す
<pre>
func joinAndUniqueUserNames(messages: [Message]) -> String {
var names:Set<String> = []
 
// クロージャ例
messages.forEach({message in names.insert(message.user.name)})
 
// トレイリングクロージャ例
messages.forEach { message in
names.insert(message.user.name)
}
return names.joined(separator: ",")
}
</pre>
 
===属性===
----
Swiftにおけるクロージャには、いくつかの属性を指定できます
====@escapeing属性====
----
https://qiita.com/imchino/items/48564b0c23a64f539060
*クロージャは、関数に引数として渡されたとき「関数をエスケープ」できます。
print(genericSample(x:1.2, y:"abc"))
</pre>
 
===some,any===
----
https://jimaru.blog/programming/swift/swift-some-any/
==並行処理==
self.hogeLabel.text = result
}
</pre>
 
==ユニットテスト==
===非同期処理をテストする===
<pre>
func testAccessRequest() {
var result : String?
let expectation = expectation(description: "非同期待ち")
// 非同期処理の呼び出しとコールバック
HealthKitHelper.accessRequest() { accessResult in
result = accessResult
expectation.fulfill() // 非同期待ち解除
}
waitForExpectations(timeout: 4) // 指定時間応答がなければ失敗
 
print("ACCESS REQUEST : \(String(describing: result))")
assert(result != nil)
}
</pre>
=====[https://www.typea.info/blog/index.php/2022/06/07/watchos_app_prestudy/ watchOS 開発概要]=====
----
[https://developer.apple.com/documentation/watchos-apps Developer Document]
=====[https://www.typea.info/blog/index.php/2022/06/08/swift_watchos_simple_app_connect_healthkit/ HealthKit利用 watchOS アプリ作成]=====
=====[https://www.typea.info/blog/index.php/2022/06/11/swift_watchos_complication_watchface_run_app/ コンプリケーションを文字盤に追加する]=====
 
=====[https://www.typea.info/blog/index.php/2022/06/14/swift_watchos_watchface_complication/ 文字盤に画像や情報を表示する]=====
 
=====[https://developer.apple.com/documentation/watchos-apps/setting-up-tests-for-your-watchos-app Unit Tests]=====
 
=====[https://qiita.com/am10/items/e58dfe28f024b3dc39ad WatchKitオブジェクト]=====
====HealthKit====
$R1: Int = 8549
</pre>
====Sum/Average====
<pre>
1> let l = [1,2,3,4,5]
l: [Int] = 5 values {
[0] = 1
[1] = 2
[2] = 3
[3] = 4
[4] = 5
}
2> l.reduce(0,+)
$R0: Int = 15
3> l.reduce(0,+) / l.count
$R1: Int = 3
</pre>
 
====[[デザイン]]====
=====[https://photoshopvip.net/102903 配色]=====
*http://photoshopvip.net/95427
*https://colorhunt.co/palette/196224
 
=====アイコン=====
*https://www.flaticon.com
 
====書式====
=====カンマつき数値=====
5> print(nfmt.string(from: NSNumber(value:12345)))
Optional("12,345")
</pre>
 
=====小数点桁揃え=====
<pre>
print(String(format:"%.1f", (5.0 / 3.0)))
1.7
</pre>
 
=====桁揃え=====
<pre>
print(String(format:"%05d", 99))
00099
</pre>
====日付計算====
<pre>
1 3> let today = Date()today: Foundation.Date = 2022-06-18 02:38:05 UTC 4> let d tommorow = Calendar.current.date(byAdding: .monthday, value:1, to: Date()today) dtommorow: Foundation.Date? = 2022-0706-03 1519 02:3738:30 05 UTC
</pre>
*NSDateに変換

案内メニュー