My machine is MacBook Pro (Retina, 15-inch, Mid 2015). The system is big sur 11.0.1. Sometimes Xcode exits unexpectedly after the program is compiled successfully. What is the reason?
Post
Replies
Boosts
Views
Activity
Can learn Swift UI website, which websites are there
“Cannot convert return expression of type 'Void' to return type 'Bool'” How to solve it?
After writing a good run, the final simulator program only shows Goodone. Swift, a single module. The ContentView.swift content cannot be displayed. Unable to use the program properly. Need help
// goodone.swift
//
//
// Created by user on 2021/6/4.
//
import SwiftUI
struct goodone: View {
let coreDM: CoreDataManager
@State private var movieTitle: String = ""
@State private var movies: [Movie] = [Movie]()
@State private var needsRefresh: Bool = false
private func populateMovies(){
movies = coreDM.getAllMovie()
}
var body: some View {
NavigationView{
VStack {
TextField("输入待办事项", text: $movieTitle)
.textFieldStyle(RoundedBorderTextFieldStyle())
Button("保存"){
coreDM.saveMovie(title: movieTitle)
populateMovies()
}
List {
ForEach(movies, id:\.self) { movie in
NavigationLink(
destination: MovieDetail(movie: movie, coreDM: coreDM, needsRefresh: $needsRefresh),
label: {
Text(movie.title ?? "")
})
}.onDelete(perform: { indexSet in
indexSet.forEach{ index in
let movie = movies[index]
//delete it using Core Data Manager
coreDM.deleteMovie(movie: movie)
populateMovies()
}
})
}.listStyle(PlainListStyle())
.accentColor(needsRefresh ?.white:.black)
Spacer()
}.padding()
.navigationTitle("待办事项")
.onAppear(perform: {
populateMovies()
})
}
}
}
struct goodone_Previews: PreviewProvider {
static var previews: some View {
goodone(coreDM: CoreDataManager())
}
}
// Main.swift
//
//
// Created by user on 2021/5/27.
//
import SwiftUI
struct Main: View {
var body: some View {
TabView{
goodone(coreDM: CoreDataManager())
.tabItem {
Image(systemName: "bolt.car")
Text("待办事项")
}.tag(1)
Text("车主信息")
.tabItem {
Image(systemName: "car.fill")
Text("车主信息")
}.tag(2)
Text("车主需求")
.tabItem {
Image(systemName: "person")
Text("车主需求")
}.tag(3)
Text("信息检索")
.tabItem {
Image(systemName: "simcard.2")
Text("信息检索")
}.tag(4)
}.accentColor(.red)
.font(.title3)
}
}
struct Main_Previews: PreviewProvider {
static var previews: some View {
Main()
}
}
// ContentView.swift
//
//
// Created by user on 2021/5/27.
//
import SwiftUI
struct ContentView: View {
var body: some View {
Main()
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
}
Request to recommend
I deployed Xcode to iPhone, emulator and iPhone, and iCloud data is synchronized. But I am using testlight for distribution, so I cannot synchronize. I did not respond in iCloud Kit Database developer mode, and now I have changed to production mode, but there is no response, so I cannot synchronize. That's why.