Post

Replies

Boosts

Views

Activity

Strange addition
// I have a object "CentralProcesser". I can get the user and system usage of the CPU. I want to get the total. let system: Double = CentralProcesser.current.usage.system // 10.8746757975 or something like that let user: Double = CentralProcesser.current.usage.user // 23.24123412424 or something like that // And now I add them together, right? let total: Double = system + user // nan Why?
1
0
865
Aug ’22
Why?
I wrote an app that users can create utilities using terminal commands I'm experiencing a bug that's driving me crazy: I have an array of utilities, and by extension, I made Array<Utility> and Utility RawRepresantable: Part of the declaration for Utility public init?(rawValue: String) {     guard let data = rawValue.data(using: .utf8),           let result = try? JSONDecoder().decode(Utility.self, from: data)     else { return nil }     self = result } public var rawValue: String {     var encoder = JSONEncoder()     encoder.outputFormatting = .prettyPrinted     guard let data = try? encoder.encode(self),           let result = String(data: data, encoding: .utf8)     else {         return ""     }     return result } extension for Array<Utility> extension Array: RawRepresentable where Element: Codable {     public init?(rawValue: String) {         guard let data = rawValue.data(using: .utf8),               let result = try? JSONDecoder().decode([Element].self, from: data)         else { return nil }         self = result     }          public var rawValue: String {         let encoder = JSONEncoder()         encoder.outputFormatting = .prettyPrinted guard let data = try? encoder.encode(self),               let result = String(data: data, encoding: .utf8)         else {             return "[]"         }         return result     } } And now, because of some strange SwiftUI bug (FB11401294) When I pass a binding down a view hierarchy such as List or ForEach they update weirdly. I implement an "edit" feature for my utilities so I will not directly use binding but to call a function that takes an inout of Array<Utility>, the original item, and the item after being edited: func replace(_ sequence: inout [Utility], item: Utility, with replace: Utility) {     var raw = sequence.rawValue     print(raw)     let rawReplaced = raw.replacingOccurrences(of: item.rawValue, with: replace.rawValue)     print(item.rawValue, replace.rawValue)     print(rawReplaced)     sequence = [Utility].init(rawValue: sequence.rawValue.replacingOccurrences(of: item.rawValue, with: replace.rawValue))!     print(sequence) } And the problem is it works and after implementing another completely different feature it stopped working from my debugging, the input of the function is correct and the problem is inside the function. But, as the error seems to be on this line: sequence = [Utility].init(rawValue: sequence.rawValue.replacingOccurrences(of: item.rawValue, with: replace.rawValue))! Now i have completely no idea why this works last time and won't now This line of code works completely well in playgrounds and is now freaking me out Help anyone?
1
0
1.3k
Sep ’22
Build input file not found
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/xxx/Library/Developer/Xcode/DerivedData/ColorLibrary-hakdntgphjogwuawcvuxomfrjzex/Build/Products/Debug-iphonesimulator/ColorKit iOS.app/ColorKit iOS' (in target 'ColorKit iOS' from project 'ColorLibrary')
2
0
660
May ’22
sth wrong with .searchable
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)
2
1
880
May ’22
"Access to list denied" message in the run console
What I want: I'm learning developing by building a document-based todos app and just want my code to run. What I get: My app went stuck every time I open a document So I create a new project and moved all of my code there Nothing changes I think that's because I added Touch Bar support so I clear Touch Bar code off Still nothing changes, but in the LLDB console there's a message: 2022-06-06 09:17:14.098990+0800 Todos[5747:307926] [default] Failed to get state for list identifier com.apple.LSSharedFileList.ApplicationRecentDocuments Error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (Access to list denied) UserInfo={NSDebugDescription=Access to list denied} And I think there's sth to do with App Sandbox, and I added some File Access configuration. Nothing changes Then I realized I forgot to add a development team in the new project Nothing ALSO1: when I changed the Signing Certificate to Development The message in the LLDB console disappeared. I couldn't find any reference on it. ANY HELP IS GREATLY APPRECIATED!!!!!!
2
0
1.7k
Jun ’22
Sth about WWDC
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)?
2
0
511
Jun ’22
Strange Bug
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>
2
1
685
Jun ’22
SpriteKit Game
OK I'm trying to make a sprite(model.Emmiter) that shoots balls(EnergyBalls) and the balls wont emit at the touch location: import SpriteKit import GameplayKit class Sprites {     var Emmiter: SKSpriteNode = .init(imageNamed: "Emmiter") } class GameScene: SKScene {     var model: Sprites = .init()     var Emmiter = Sprites().Emmiter     var playableRect: CGRect = .zer     var lastTouch: CGPoint = .zero     override func didMove(to view: SKView) {        Emmiter.position = CGPoint(x: size.width / 2, y: size.width/* view.frame.minY + 100 */)         print(Emmiter.position)         self.addChild(Emmiter)     }               func touchDown(atPoint pos : CGPoint) {         lastTouch = pos         let rotation = -atan2(             lastTouch.x - Emmiter.position.x,             lastTouch.y - Emmiter.position.y         )         Emmiter.run(             .rotate(                 toAngle: rotation,                 duration: 0.25             )         )         fireEnergyBall(atPoint: lastTouch)     }          func touchMoved(toPoint pos : CGPoint) {     }          func touchUp(atPoint pos : CGPoint) {     }          func fireEnergyBall(atPoint location: CGPoint) {         let EnergyBall = SKSpriteNode(imageNamed: "Energy")         EnergyBall.position = Emmiter.position         print(EnergyBall.position)                  let fly: SKAction = .run {             EnergyBall.run(.move(to: location, duration: 1))             DispatchQueue.main.asyncAfter(deadline: .now() + 1) {                     EnergyBall.un(.sequence([.scale(to: 0, duration: 0.125), .removeFromParent()]))                 }         }         EnergyBall.run(fly)         self.addChild(EnergyBall)     }     override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {         let rotation = -atan2(             touches.first!.location(                 in: self             ).x - Emmiter.position.x,             touches.first!.location(                 in: self             ).y - Emmiter.position.y         )         Emmiter.run(             .rotate(                 toAngle: rotation,                 duration: 0.25             )         )         fireEnergyBall(atPoint: touches.first!.location(in: self.view))     }          override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {     }          override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {     }          override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {     }               override func update(_ currentTime: TimeInterval) {              } }
2
0
964
Aug ’22