Post

Replies

Boosts

Views

Activity

Reply to you don't have permission to view it
OK, if that wasn't odd enough... as a work around I made a Data.dataset folder in the apps assets and copied-in a few files to read. Only, they also say "you don't have permission to view it" referring to Assets.xcassets! Yes, this folder was drag-n-dropped from the old project into this new project. Yet if I create a new folder in the project and copy the data into it, I have no permissions as well. No permissions within my own project, anywhere! Hmm. Security gone awry.
1d
Reply to SCNGeometry and .copy()
as an attempted work-around I created a global array of mySCNGeometry.copy() which should have allowed the materials to be changed independently as stated in the Developer Documentation. They are in fact all the same geometry whereas changing any one "copy" changes them all.
1w
Reply to SCNGeometry and .copy()
OK, I have just learned that objc methods can be called with Swift. Most examples are of custom functions or methods. How can I call the existing objc version of .copy() since Swift's doesn't work? Thanks fyi: I could never grasp objc and stopped programming during that period. Please be generous with example code.
1w
Reply to SCNGeometry and .copy()
curiously, when I use .copy() on an SCNGeometry the geometry?.geometrySourceChannels, geometry?.elements, and geometry?.materials are all == to the original but the test whether the geometries themselves are equal returns false. How can a copy not equal its original? Idk what else to test for "as missing" from the copy() .
1w
Reply to SceneView camera viewpoint restoration
SceneKit and SwiftUI are both imported. The documentation shows SceneView is a member of both yet after SceneView is initiated any attempt to access ".defaultCameraController" gives the error "This property is defined on SCNView and may not be available in this context." And indeed, is not. So I'm guessing the SwiftUI-SceneView overrides the SceneKit-SceneView and it has no ".defaultCameraController" nor a camera as far as I can tell. Every search involves importing AVFoundation which seems like another can of worms. Converting to ARKit, likewise. If the user chooses to manipulate the viewpoint, then he'll just have to restore it himself.
Nov ’24
Reply to SecureCoding roadblock?
FYI, I append JSON files millions of times per file. Here's the code: func saveBAToJSON(BA: myCustomClass) { let fileName = "created from BA" let ArchiveURL = getArchiveURL(fileName: fileName, ext: "JSON") var ArchiveDirectoryPath = fileDirPath let localFileManager = FileManager() do { let resources = try? ArchiveURL.resourceValues(forKeys: [.fileSizeKey]) let fileSize = resources?.fileSize ?? 0 /* The JSON file is appended many times and it must be limited in size otherwise memory is over taxed. maxFileSize is a global var that is machine specific. */ if fileSize > maxFileSize { let dirContents = try! localFileManager.contentsOfDirectory(atPath: ArchiveDirectoryPath) var elemFiles = 0 /* If a file would exceed MaxFileSize, start a new file copying it and appending an incremented counter to the name. */ for elem in 0..<dirContents.count { if dirContents[elem].contains(fileName) { elemFiles += 1 } } try FileManager.default.copyItem(at: ArchiveURL, to: getArchiveURL(fileName: fileName+"-\(elemFiles)", ext: "JSON")) try FileManager.default.removeItem(at: ArchiveURL) } } catch { print("\(Date.now):\(#file):\(#line) saveBAToJSON():fileSize", error) } do { let myJSONencoder = JSONEncoder() myJSONencoder.nonConformingFloatEncodingStrategy = .convertToString(positiveInfinity: "+Infinity", negativeInfinity: "-Infinity", nan: "NaN") var data = try myJSONencoder.encode(BA) if let fileHandle = try? FileHandle(forWritingTo: ArchiveURL) { defer { fileHandle.closeFile() } /* This is the main trick: truncate the repeating JSON components from the top of file to be appended, strip the JSON components at the end of the file to append-to (after converting to base64) replacing it with a comma (in my case). Write to file. */ let truncateCount = UInt64(36 + filename.count + String(BA.myCustomClassElement1).count) /* you must count chars in your specific JSON's to get this right. I'm sure this could be coded to adapt to any JSON file. */ let strippedRange = data.range(of: Data(base64Encoded: "my base64 encoded repeating components at end-of-file" )!) let commaData = Data(base64Encoded: "LA==")! data.replaceSubrange(strippedRange!, with: commaData ) let end = try fileHandle.seekToEnd() if end > truncateCount { try fileHandle.truncate(atOffset: end - truncateCount ) try fileHandle.write(contentsOf: data ) } } else { try data.write(to: ArchiveURL, options: [.atomic, .noFileProtection]) } } catch { print("\(Date.now):\(#file):\(#line) saveBAToJSON():fileSize", error) } } Share and Enjoy homage Eskimo
Feb ’24
Reply to simple? filename sort
Armed with Scott's clue, ".localizedStandard", here's what works: after collecting [URL] with "contentsOfDirectory(at:", parse-out a [String] from the URL components. apply .sorted(using: .localizedStandard) and use in Picker() from Picker() use the return value and re-assemble a path to use with "URL(fileWithPath:" finish-off with JSONDecoder() Gives a nice Finder-style Picker list and opens the file. Thanks Scott
Feb ’24
Reply to precompiler test for cpu count
Is this work entirely CPU bound? No GPU's involved, so I guess so. The app does nothing outside of the machine upon which it runs. Once the database is generated the app just becomes a viewing instrument. This reply is two weeks late because for two weeks the machine was busy generating useless data. lol. (Down from a 300 year estimated compute time, so yay, progress!) We can probably close this thread because I have no need to generate data on unknown machines. Thanks.
Jul ’22