I face to same issue in Playground. Normal Project can compile it.
Post
Replies
Boosts
Views
Activity
List in List does not work well.
You should change code like below code
List {
Button("ADD") {
}
Section {
ForEach(data) { datum in
}
}
}
class FinalBluePrint: ObservableObject {
@Published var currentGrade: Double = 5;
@Published var desiredGrade : Double = 0;
@Published var finalWeight : Double = 0;
var finalNeededGrade : Double {
let desiredGrade = self.desiredGrade;
let currentGrade = self.currentGrade;
let finalWeight = self.finalWeight;
let finalNeededGrade = (desiredGrade - currentGrade * (100 - finalWeight)) / finalWeight;
return finalNeededGrade
}
}
struct ContentView: View {
@StateObject var final = FinalBluePrint()
var body : some View {
NavigationView {
VStack {
TextField("Current Grade", value: $final.currentGrade, format: .number).keyboardType(.decimalPad);
TextField("Desired Grade", value: $final.desiredGrade, format: .number).keyboardType(.decimalPad);
TextField("Final Weight", value: $final.finalWeight, format: .number).keyboardType(.decimalPad);
Text(final.currentGrade, format: .number);
Text(final.finalNeededGrade, format: .number);
}
}
}
}
https://developer.apple.com/wwdc22/10054 doesn't explain multi NavigationLink in one cell.
FileRepresentation.importing's 'receivedData' is already deleted. when I use.
import CoreTransferable
struct Movie: Transferable {
let url: URL
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .movie) { movie in
SentTransferredFile(movie.url)
} importing: { receivedData in
let fileName = receivedData.file.lastPathComponent
let copy: URL = FileManager.default.temporaryDirectory.appendingPathComponent(fileName)
try FileManager.default.copyItem(at: receivedData.file, to: copy)
return .init(url: copy)
}
}
}
Error Domain=NSCocoaErrorDomain Code=260 "The file “IMG_0458.mov” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/Application/D2E2AF9F-E879-4792-89CE-E7FB6B1B8234/tmp/.com.apple.Foundation.NSItemProvider.flbzCW/IMG_0458.mov, NSUnderlyingError=0x28389eeb0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Is this bug or problem?
if comment out // people.append(.init(name: "ace")), dismiss is works properly.
This problem fixed in iOS 16 beta 5. thanks
https://github.com/zunda-pixel/SamplePhotosPicker
same in Beta 5.
I found resolution. user NavigationPath
struct TimelineView: View {
@State var path = NavigationPath()
let tweets: [Tweet] = tweets
let users: [User] = users
var body: some View {
NavigationStack(path: $path) {
List(tweets) { tweet in
let user = users.first { $0.id == tweet.userID }!
HStack {
Image(systemName: "person")
.onTapGesture {
path.append(user)
}
VStack {
Text("@\(user.name)")
Text(tweet.text)
}
Spacer()
}
.swipeActions(edge: .leading) {
Button("Like") { }
}
.contentShape(Rectangle())
.onTapGesture {
path.append(tweet)
}
}
.navigationDestination(for: Tweet.self) { tweet in
TweetDetailView(tweet: tweet)
}
.navigationDestination(for: User.self) { user in
UserDetailView(user: user)
}
}
}
}
I fixed with navigationDestination(isPresented:)
import SwiftUI
struct ContentView: View {
@State var isPresentedDetailView = false
@State var isPresentedImageView = false
var body: some View {
NavigationStack {
List {
HStack {
Text("Name")
.onTapGesture {
isPresentedDetailView.toggle()
}
Image(systemName: "person")
.onTapGesture {
isPresentedImageView.toggle()
}
}
}
.navigationDestination(isPresented: $isPresentedImageView) {
Image(systemName: "person")
}
.navigationDestination(isPresented: $isPresentedDetailView) {
Text("Detail View")
}
}
}
}
This bug is fixed in iOS 16 beta 5.
This problem is not happened when run again.
I use RegexComponentBuilder.buildPartialBlock but different result
let words = ["@apple", "#swift"]
func getRegex() -> some RegexComponent {
var regex = RegexComponentBuilder.buildPartialBlock(first: Regex { words.first! } )
for word in words[1...] {
regex = RegexComponentBuilder.buildPartialBlock(accumulated: regex, next: Regex { word })
}
return ChoiceOf { regex }
}
let regex1 = getRegex()
let regex2 = Regex {
ChoiceOf {
"@swift"
"#swift"
}
}
let string = "aaa @swift #swift aaa"
for match in string.matches(of: regex1) {
print(String(string[match.range]))
} // print ""
for match in string.matches(of: regex2) {
print(String(string[match.range]))
} // @swift #swift
At the moment, @Environment can't use for Binding
I don't know whether it's a bug or not
https://developer.apple.com/forums/thread/732658