Posts

Post not yet marked as solved
2 Replies
86 Views
I have a structure TodoItem struct TodoItem: Codable, Hashable, Identifiable {     var id: UUID = UUID()     var item: String     var done: Bool = false } And I have an array of them, and I’d like to find out a way to calculate(in a array) how many are done; that is, myArray.count / itemsDone .count is easy, itemsDone can be achieved like this: extension Array where Element == TodoItem {     var itemsDone: Double {         var done: Double = 0         for i in self {             if i.done { done += 1 }         }         return done     } } but it didn’t. struct ContentView: View { @State var todos: [TodoItem] … ProgressView(value: todos.itemsDone / todos.count) // Error My Playground won’t let me copy the error(no idea why) and my family’s iPad is in Chinese so one is Chinese. I’ll try it on Xcode and see if I can find out more. will update with the error. EDiT nor will this work: ProgressView(value: todos.itemsDone, total: todos.count)
Posted Last updated
.
Post marked as solved
2 Replies
344 Views
My code: struct PopoverMessage: View {     var body: some View {         VStack(alignment: .leading) {             Text("You need to launch this game at Teminal.")                 .font(.title)                 .fontWeight(.light)             Divider()             HStack {                 Text("Help me generate launch command ")                     .fontWeight(.thin)                 Image(systemName: "rectangle.portrait.and.arrow.right.fill")                     .resizable()                     .foregroundColor(.gray)                     .frame(width: 10, height: 10)             }.padding(10)         }     } } works while struct PopoverMessage: View {     var body: some View {         VStack(alignment: .leading) {             Text("You need to launch this game at Teminal.")                 .font(.title)                 .fontWeight(.light)             Divider()             HStack {                 Text("Help me generate launch command ")                     .fontWeight(.thin)                 Image(systemName: "rectangle.portrait.and.arrow.right.fill") .weigh                     .resizable()                     .foregroundColor(.gray)                     .frame(width: 10, height: 10)             }.padding(10)         }     } } don't and displays a error message Trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure Here's the text in the diagnostics sheet: trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure ---------------------------------------- CompileDylibError: Failed to build ContentView.swift Compiling failed: trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure /Users/wangkeshijian/Documents/.myFolder/.system/TerminalAdventure/TerminalAdventure/ContentView.swift:12:37: error: trailing closure passed to parameter of type 'CGFloat?' that does not accept a closure         VStack(alignment: .leading) {                                     ^ SwiftUI.VStack:4:12: note: 'init(alignment:spacing:)' declared here     public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil)            ^ // my comment here: it seems that SwiftUI, under some sort of strange bug, did notrecognize my initializer ================================== |  BuildInvocationError |   |  /Users/wangkeshijian/Documents/.myFolder/.system/.Downloads/Xcode14-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -F /Users/wangkeshijian/Documents/.myFolder/.system/.Downloads/Xcode14-beta.app/Contents/SharedFrameworks -enforce-exclusivity=checked -DDEBUG -sdk /Users/wangkeshijian/Documents/.myFolder/.system/.Downloads/Xcode14-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk -target x86_64-apple-macos12.4 -module-cache-path /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -swift-version 5 -enable-bare-slash-regex -I /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Products/Debug -F /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Products/Debug -emit-localized-strings -emit-localized-strings-path /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/Objects-normal/x86_64 -c -j4 -serialize-diagnostics -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-generated-files.hmap -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-own-target-headers.hmap -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-all-target-headers.hmap -Xcc -iquote -Xcc /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/TerminalAdventure-project-headers.hmap -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Products/Debug/include -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/DerivedSources-normal/x86_64 -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/DerivedSources/x86_64 -Xcc -I/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/DerivedSources -Xcc -DDEBUG=1 -working-directory /Users/wangkeshijian/Documents/.myFolder/.system/TerminalAdventure /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/Objects-normal/x86_64/ContentView.1.preview-thunk.swift -o /Users/wangkeshijian/Library/Developer/Xcode/DerivedData/TerminalAdventure-fdqrafmgjltnvaesvnkdwzpsebjf/Build/Intermediates.noindex/Previews/TerminalAdventure/Intermediates.noindex/TerminalAdventure.build/Debug/TerminalAdventure.build/Objects-normal/x86_64/ContentView.1.preview-thunk.o -module-name TerminalAdventure_PreviewReplacement_ContentView_1 -Onone -Xfrontend -disable-modules-validate-system-headers -gline-tables-only
Posted Last updated
.
Post not yet marked as solved
1 Replies
54 Views
macOS Ventura 13 beta 2 I'm coming over with a really strange issue with my cursor. It'd move toward the right-down by itself one pixel a time: right down right down It really freaked me out *laugh* I'll try attaching a video. FB submitted.
Posted Last updated
.
Post marked as solved
1 Replies
58 Views
I have a structure TodoItem struct TodoItem: Codable, Hashable, Identifiable {     var id: UUID = UUID()     var item: String     var done: Bool = false } How can I use AppStorage on [TodoItem]?
Posted Last updated
.
Post not yet marked as solved
0 Replies
122 Views
Feedback is filed. Trying to look into the Core.swift. diagnostics: Unsupported: 'Consumer for unconverted(_StringProcessing.DSLTree._AST.Atom(ast:  ---------------------------------------- CrashReportError: Fatal Error in Core.swift UtilityScript crashed due to fatalError in Core.swift at line 77. 'try!' expression unexpectedly raised an error: Unsupported: 'Consumer for unconverted(_StringProcessing.DSLTree._AST.Atom(ast:  ))' Process: UtilityScript[3141] Date/Time: 2022-07-02 03:56:17 +0000 Log File: <none> Application Specific Information:     dyld [         dyld config: DYLD_LIBRARY_PATH=/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/UtilityScript-frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug DYLD_FRAMEWORK_PATH=/Users/wangkeshijian/Library/Developer/Xcode/DerivedData/UtilityScript-frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug     ]     libswiftCore.dylib [         _StringProcessing/Core.swift:77: Fatal error: 'try!' expression unexpectedly raised an error: Unsupported: 'Consumer for unconverted(_StringProcessing.DSLTree._AST.Atom(ast:  ))'         /AppleInternal/Library/BuildRoots/0cc5e7ad-e86f-11ec-ac50-3e2aa58faa6a/Library/Caches/com.apple.xbs/Sources/swiftlang_overlay_Platform/swift-experimental-string-processing/Sources/_StringProcessing/ConsumerInterface.swift:200     ]
Posted Last updated
.
Post not yet marked as solved
0 Replies
61 Views
How can I achieve a source code editor in SwiftUI like Xcode, highlighting all the keywords and things like that. I've tried Regex + AttributedString... To hard... Anyone has any idea?
Posted Last updated
.
Post not yet marked as solved
0 Replies
103 Views
I have a swiftUI app after I decided to add a document type After I opened the infos tab I clicked on "documents" and Xcode crashed. I've filed a bug (FB10465644). Any way so I added the imported & exported document and now its won't work. I ran the executive in my app and it gave me this: .....frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug/UtilityScript.app/Contents/MacOS/UtilityScript ; exit; SwiftUI/AppWindowsController.swift:1103: Fatal error [1]    30982 illegal hardware instruction   Saving session...completed. [Process completed] in Xcode: SwiftUI/AppWindowsController.swift:1103: Fatal error 2022-06-26 13:26:19.042228+0800 UtilityScript[31108:471855] SwiftUI/AppWindowsController.swift:1103: Fatal error (lldb)  HELP I'VE NEVER THIS BEFORE I JUST WANT TO KNOW IF It"S MY BUG OR SWIFTUI'S AND I JUST WANT MY APP DONE🫠 info.plist: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>BuildMachineOSBuild</key> <string>22A5286j</string> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleDocumentTypes</key> <array> <dict/> </array> <key>CFBundleExecutable</key> <string>UtilityScript</string> <key>CFBundleIdentifier</key> <string>-----</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>UtilityScript</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSupportedPlatforms</key> <array> <string>MacOSX</string> </array> <key>CFBundleVersion</key> <string>1</string> <key>DTCompiler</key> <string>com.apple.compilers.llvm.clang.1_0</string> <key>DTPlatformBuild</key> <string>14A5228q</string> <key>DTPlatformName</key> <string>macosx</string> <key>DTPlatformVersion</key> <string>13.0</string> <key>DTSDKBuild</key> <string>22A5266o</string> <key>DTSDKName</key> <string>macosx13.0</string> <key>DTXcode</key> <string>1400</string> <key>DTXcodeBuild</key> <string>14A5228q</string> <key>LSMinimumSystemVersion</key> <string>13.0</string> <key>NSHumanReadableCopyright</key> <string>-----</string> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.plain-text</string> </array> <key>UTTypeIcons</key> <dict/> <key>UTTypeIdentifier</key> <string>-----</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>.utlscript</string> </array> </dict> </dict> </array> <key>UTImportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.plain-text</string> </array> <key>UTTypeIcons</key> <dict> <key>UTTypeIconText</key> <string>utilityscript</string> </dict> <key>UTTypeIdentifier</key> <string>-----</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>.utlscript</string> </array> </dict> </dict> </array> </dict> </plist>
Posted Last updated
.
Post not yet marked as solved
1 Replies
80 Views
I have this: struct TableRow: View { @Binding var data: TodoItem var body: some View { ... } } and this: List {     ForEach(data) { datum in         TableRow(data: ???) // <- what goes here?             .swipeActions {                 Button(role: .destructive) {                     data.delete(datum)                 } label: {                     Label("Delete", systemImage: "trash")                 }           }     } }
Posted Last updated
.
Post marked as solved
1 Replies
78 Views
I want to change a binding value to just a normal one. How?
Posted Last updated
.