Post not yet marked as solved
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)")
}
}
}
Post not yet marked as solved
I'm trying to add a quick look preview extension to my app.
But
I can't find any reference on this
On a earlier thread (https://developer.apple.com/forums/thread/704155)
everyone seems to misunderstand my question.
I MEAN THE QUICK LOOK YOU CAN TOGGLE IN FINDER THAT WILL SHOW YOU A PREVIEW OF A DOCUEMNT
I don't want to add the tag QuickLook because that's not I want to do.
Post not yet marked as solved
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
Post not yet marked as solved
I'm doing a app that needs a toolbar but it wont come out:
ContentView()
.toolbar {
ToolbarItem {
Button {
data.data.append(TodoItem())
} label: {
Image(systemName: "plus")
}
}
}
Post not yet marked as solved
I know there should be a easy solution to this mess but I JUST CAN'T FIND IT AHHHHHHHHHH
cd ......
error: Build input file cannot be found: '/Users/***/Library/Developer/Xcode/DerivedData/ColorLibrary-hakdntgphjogwuawcvuxomfrjzex/Build/Products/Debug-iphonesimulator/ColorKit iOS.app/ColorKit iOS' (in target 'ColorKit iOS' from project 'ColorLibrary')
Post not yet marked as solved
I want to include a button that could export some data but I'm stuck:
I want a NSSavePanel open up and when I choose the pass and click save the JSON file will appear but it didn't.
code:
Button {
let export = exportToJSON(toExported(data.data))
let openPanel = NSSavePanel()
openPanel.message = "Choose the exported path:"
openPanel.begin { response in
if response == .OK {
print("\(openPanel.url!)")
url = openPanel.url!
let fileManager = FileManager()
let success = fileManager.createFile(atPath: "\(url)", contents: export)
debugPrint(success)
}
}
} label: {
Image(systemName: "square.and.arrow.down")
}.padding().buttonStyle(.plain)
console:
file:///Users/***/Documents/Untitled
false
Post not yet marked as solved
Still about appstorage
Can a store a @StateObject in @AppStorage?
I can't do this:
@AppStorage("Data") // No exact matches in call to initializer
@StateObject private var Data = TodoData()
Post not yet marked as solved
I'm using SwiftUI on Mac Catalyst:
@main
struct TodoApp: App {
@StateObject private var eventData = TodoData()
var body: some Scene {
WindowGroup {
ContentView().environmentObject(eventData)
}
#if os(macOS)
Settings{
TodoSettings()
}
#endif
}
}
Post not yet marked as solved
I can now how define part of the about page but how about the whole?
Thanks
better in swiftUI
How can i write an About page in swiftUI about my app? I cant find any documentation on it
Post not yet marked as solved
I'm trying to follow the Date Planner tutorial and the symbol picker went really weird.
I changed sth, and the whole app stoped working
I changed it back, it still wont work.
SymbolPicker code:
struct PickerView: View {
@State var item: TodoItem
@State private var showingPopover: Bool = false
var columns = Array(repeating: GridItem(.flexible()), count: 6)
var body: some View {
LazyVGrid(columns: columns){
ForEach(SymbolOptions.symbolNames, id: \.self){ symbol in
Button {
item.symbol = symbol
} label: {
Image(systemName: symbol).foregroundColor(item.color)
}
}
}
}
}
Post not yet marked as solved
How can I store a struct in @AppStorage?
I've been trying
struct TodoItem: Codable, Hashable, Identifiable {
var id: UUID = UUID()
var name: String = "New Todo"
var description: String = "Description here..."
var done: Bool
}
@AppStorage("todo") var todo: [TodoItem] = [] // No exact matches in call to initializer
Any help is appreciated🙏🙏