質問編集履歴
1
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### 実現したいこと
|
2
2
|
|
3
|
-
iPhoneにある連絡先アプリの一覧画面のような、あいうえお順(濁点のものも同じセクション)でセクション
|
3
|
+
iPhoneにある連絡先アプリの一覧画面のような、あいうえお順(濁点のものも同じセクション)でセクションで区切る。
|
4
4
|
|
5
5
|
|
6
6
|
### 前提
|
@@ -9,20 +9,44 @@
|
|
9
9
|
|
10
10
|
### 発生している問題・エラーメッセージ
|
11
11
|
|
12
|
-
```
|
13
|
-
エラーメッセージ
|
12
|
+
エラーメッセージではないのですが、濁点があっても同じセクションに入れる方法がわからない状況です。
|
14
|
-
```
|
15
13
|
|
16
14
|
### 該当のソースコード
|
15
|
+
コードは抜粋しています。
|
16
|
+
```SwiftUI
|
17
|
+
struct ContactListView: View {
|
18
|
+
let kanadata = ["ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ","タ","チ","ツ","テ","ト","ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ","ミ","ム","メ","モ","ヤ","ユ","ヨ","ラ","リ","ル","レ","ロ","ワ"]
|
17
19
|
|
20
|
+
var body: some View {
|
18
|
-
|
21
|
+
NavigationView{
|
19
|
-
|
22
|
+
VStack{
|
23
|
+
List{
|
24
|
+
ForEach(kanadata, id: \.self) { kana in
|
25
|
+
|
26
|
+
let filteredContact = contact.filter{ $0.first_name_kana.hasPrefix(kana)}
|
27
|
+
|
28
|
+
if !filteredContact.isEmpty {
|
29
|
+
|
30
|
+
Section(header: Text("\(kana)")) {
|
31
|
+
|
32
|
+
ForEach(contact.filter{ $0.first_name_kana.hasPrefix(kana)}, id: \.contact_id) { item in
|
33
|
+
|
34
|
+
NavigationLink(destination: ContactView(contactId: item.contact_id)){
|
35
|
+
HStack{
|
36
|
+
Text(item.first_name)
|
37
|
+
Text(item.last_name)
|
38
|
+
}
|
39
|
+
}
|
20
40
|
```
|
21
41
|
|
22
42
|
### 試したこと
|
23
43
|
|
24
|
-
|
44
|
+
下記の条件を修正してみましたが、うまくいきませんでした。
|
45
|
+
修正前
|
46
|
+
let filteredContact = contact.filter{ $0.first_name_kana.hasPrefix(kana)}
|
47
|
+
修正後
|
48
|
+
let filteredContact = contact.filter{ $0.first_name_kana.hasPrefix(kana) || contact.filter{ $0.first_name_kana.hasPrefix((kana + "゛"))}}
|
25
49
|
|
26
50
|
### 補足情報(FW/ツールのバージョンなど)
|
27
51
|
|
28
|
-
どのような
|
52
|
+
どのような方法で実現可能なのか分からず、困っています。
|