OK after I'm done with my last issue I came across some weird UI layout
this is really a serious issue because afterward it looks like this😂
why?
I've never met this kind of issue before in my same code before upgrading to Ventura
code:
List {
...
Section {
ForEach(data) { datum in
TableRow(data: datum)
.swipeActions {
Button(role: .destructive) {
data.delete(datum)
} label: {
Label("Delete", systemImage: "trash")
}
}
}
}
...
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm trying out Swift Charts and I'm pretty messed up
After I deleted all of my items, I couldn't add items anymore
import SwiftUI
extension Array where Element == ChartsData {
mutating func delete(_ item: ChartsData) {
self.removeAll {
$0 == item
}
}
}
struct ContentView: View {
var ofType: ChartsType
@State var data: [ChartsData] = []
var body: some View {
List {
VStack {
HStack {
Spacer()
// MARK - add button
Button {
data.append(ChartsData(item: "item"))
} label: {
Image(systemName: "plus").imageScale(.large)
}.buttonStyle(.plain).padding()
}
List {
ForEach(data) { datum in
TableRow(data: datum).swipeActions {
Button(role: .destructive) {
data.delete(datum)
} label: {
Label("Delete", systemImage: "trash")
}
}
}
}
NavigationLink{
ChartsView(ofType: .BarChart, data: data)
} label: {
Text("Generate").font(.largeTitle).foregroundStyle(.linearGradient(colors: [.orange, .yellow, .blue, .purple], startPoint: .topTrailing, endPoint: .bottomLeading))
}.padding()
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView(ofType: .BarChart, data: [
ChartsData(item: "testItem1", value: 10),
ChartsData(item: "testItem2", value: 20)
])
}
}
I know how to use Virtualization now
But I don't know how to write interface in AppKit
So I should find a way to embed a NSView(the VM's UI) in a SwiftUI View
However
I couldn't find any reference on how except NSViewRepresentable which, of course, will not work
I know there must be a easy way to do this
But I'm just can't find it...
any help is appreciated
I know this is really easy
I want to get the absolute path for the current app
And I can achieve using
String(reflecting: Bundle.main.bundleURL)
But what outputs isn't like /User/xxx/.....
but file:///User/xx/...
so
what can I do to get a absolute path in /xxx/xxx/xxx format?
thanks
It says there's an error uploading the image so I can't get a image up here in a moment
EDIT AFTER RESTARTING SAFARI:
Oh no still won't work
I remembered there's a message that says that you cannot modify this video or whatever at the end of every session. So, if I trim the video and send it to my friend, is it allowed?
Bonus: where can I find the background music for every daily debrief video (if I can)?
The requested version of macOS is not available. Please check if your Mac is compatible with this software.
How can I make it work?
jsonString = """
["foo", "bar"]
"""
let decoder = JSONDecoder
var whatIWant = decoder.decode(Array<String>.self, jsonString)
for i in whatIWant {
print(i)
}
EDIT:
Minor syntax mistake ignore this thread sorry everyone
I'm in China, and if I sign up for a digital lounge or lab, It's either me or Apple staying up all night. So, what's the case to activities for areas not in the same time zone as USA?
How could I create an icon with an alpha/beta/dev badge?
like this⬇️
I add searchable to my SwiftUI List
But the search TextField isn't showing
Here's my code
NavigationView {
List(searchResults, id: \.self) { item in
NavigationLink {
LegendDetailView(item: item)
} label: {
HStack {
Text(item.name).padding(1)
Spacer()
Image(systemName: "chevron.right").imageScale(.small)
}
}
}
}.searchable(text: $searchText)
No idea why this error occurred, and I suspect that it's me putting initialization in the wrong place.
struct TodosDocument: FileDocument {
var todo: Context
@AppStorage("defaultText")
var defaultText: String = defaultContent
var content: String
var erroreousFileContent: Bool = false
init(content: String = defaultContent, defaultText: String = defaultContent) {
self.defaultText = defaultText
self.content = content
do {
self.todo = try JSONDecoder().decode(Context.self, from: content.data(using: .utf8)!)
} catch {
print("ERROR \(error)")
fatalError()
}
}
static var readableContentTypes: [UTType] { [.TodoType] }
init(configuration: ReadConfiguration) throws {
guard let data = configuration.file.regularFileContents,
let string = String(data: data, encoding: .utf8)
else {
throw CocoaError(.fileReadCorruptFile)
}
self.content = string
do {
self.todo = try JSONDecoder().decode(Context.self, from: data)
} catch {
self.todo = try JSONDecoder().decode(Context.self, from: defaultText.data(using: .utf8)!) // <- here
}
}
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
let data = content.data(using: .utf8)!
let i = JSONEncoder()
i.outputFormatting = .prettyPrinted
let content = Context(title: todo.title, items: todo.items)
do {
let dat = try i.encode(content)
return .init(regularFileWithContents: dat)
} catch {
fatalError("Cannot write content \"\(data)\" with \(configuration): \(error)")
}
}
}
My iPhone SE 1st will be stuck every 30 secs or so
I think it's sth because it's a second-handed one
I've used Instruments but can't find anything
Anyone HELP
Thanks🙏
My SceneKit Game failed with a
com.apple.scenekit.scnview-renderer (10): signal SIGABRT
The error was marked on the line
@main
Here's the log navigator:
2022-05-25 15:24:18.829319+0800 MyWorldiOS[9022:293392] Metal API Validation Enabled
validateRenderPassDescriptor:899: failed assertion `RenderPass Descriptor Validation
MTLRenderPassAttachmentDescriptor MTLStoreActionMultisampleResolve store action for the depth attachment is not supported by device
PixelFormat MTLPixelFormatDepth32Float cannot be a MSAA resolve target
'
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/MyWorld-aayoxjgvyfzbxvgqnvylzgvlwkyr/Build/Products/Debug-iphonesimulator:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/MyWorld-aayoxjgvyfzbxvgqnvylzgvlwkyr/Build/Products/Debug-iphonesimulator
validateRenderPassDescriptor:899: failed assertion `RenderPass Descriptor Validation
MTLRenderPassAttachmentDescriptor MTLStoreActionMultisampleResolve store action for the depth attachment is not supported by device
PixelFormat MTLPixelFormatDepth32Float cannot be a MSAA resolve target
'
CoreSimulator 802.6 - Device: MyPhone (EBB1ECDE-8AD7-4418-84AF-0B761E0A2EA7) - Runtime: iOS 15.4 (19E5234a) - DeviceType: iPhone 12
(lldb)
I'm not sure what else should I put in here