숫자 2개를 나누기를 해서 몫에 1000을 곱해 정수부분만 return하는 문제가 있었다.
그냥 나누기 하면 되겠지 하고
Int(3 / 2 * 1000)
⬆️ 이렇게 했는데 1500이 나와야하는데 1000이 나왔다.
처음 나누기 하면서 1.5가 아니라 그냥 1이 나온 것...🥹
Int(Float(3)/Float(2) * 1000)
⬆️ 이렇게 먼저 Float으로 바꿔 주고 나누기를 하는거였다.
struct Navigation: View {
let titles = ["디테일뷰로 이동하기", "디테일뷰로 이동하기2"]
let description = ["데스티네이션 입니다.", "데스티네이션 입니다.2"]
@State var showModal: Bool = false
var body: some View {
NavigationStack {
List {
ForEach([0,1], id: \.self) { index in
NavigationLink {
Text(description[index])
} label: {
Text(titles[index])
}
}
}
.toolbar(content: {
ToolbarItem(placement: .bottomBar) {
Button {
showModal = true
} label: {
Text("Add")
}
}
})
.sheet(isPresented: $showModal, content: {
Text("아이템 추가 페이지 입니다.")
})
}
}
}
struct Tab: View {
var body: some View {
TabView {
Text("Recevied")
.badge(2)
.tabItem {
Label("Received", systemImage: "tray.and.arrow.down.fill")
}
Text("Sent")
.tabItem {
Label("Sent", systemImage: "tray.and.arrow.up.fill")
}
Text("Account")
.badge("!")
.tabItem {
Label("Account", systemImage: "person.crop.circle.fill")
}
}
.tabViewStyle(.page(indexDisplayMode: .always))
}
}