Post

Replies

Boosts

Views

Activity

Reply to How to operate a image file
a URL can point at a local file (the scheme is 'file', so such URLs begin "file://"). For example, if you use NSOpenPanel on macOS to enable the user to select the file(s) to open, you'll get an array of URLs from the panel. See https://developer.apple.com/documentation/appkit/nsopenpanel. NSImage supports jpeg format input.
Topic: Programming Languages SubTopic: Swift Tags:
May ’23
Reply to How to operate a image file
the search terms you are looking for are NSImage (macOS) or UIImage (iOS/iPadOS). Images have methods for loading from and writing to a URL. Images can be rendered into a CGContext. CGContexts provide access to their pixel buffers (and various higher level operations which manipulate those buffers).
Topic: Programming Languages SubTopic: Swift Tags:
May ’23
Reply to communicating between agent and app
Well, as with most engineering questions, the answer begins with "it depends". It depends what the data is, and what a user is going to do with it. Generally, you shouldn't hit the file system if you don't need to. What you're building (an agent with a separate UI process) is quite advanced for someone new to programming. You asked, "how would I update the UI to reflect the changes"? If you're new enough to programming to have to ask this question, you should probably start with a simple, single-process application. Once you know how to make a UI respond to changes in your data model, you can work on pushing those changes from another process.
Topic: Programming Languages SubTopic: Swift Tags:
May ’23
Reply to Calculating the Real-World Distance Between middleTip and wrist
Vision points are normalized. Vision has no idea how far away your image subject is. You might be able to use information from the TrueDepth camera (if present, and in use) to derive subject distance, or you can infer this information if you know the size of the subject and the angle of the camera's viewport (it might be digitally zoomed and scaled). Bear in mind that the hand may not be parallel to the plane of the sensor - if you hold your hand at 45 degrees to the sensor it is going to look 29% shorter.
Topic: Spatial Computing SubTopic: ARKit Tags:
May ’23
Reply to SwiftUI - ScrollView with LazyVGrid and onTap, scrolling randomly by itself
ah. thanks for the video, I wasn't scrolling far enough but I couldn't tell where I was. I modified your code so it is easier to see what cell you're at. I couldn't reproduce it with an array of only 30, or even 100 Ints. But with 150 (as below), I can press on C14 and the scroll position will jump so that I'm looking at E14. Your code doesn't modify the scroll position, so this looks like a bug to me. struct ContentView: View { let strings: [String] = ["A", "B", "C", "D", "E"] let ints: [Int] = Array(1...150) @State var selectedCell: String? var body: some View { ZStack { ScrollView { VStack { ForEach(strings, id: \.self) { string in VStack { HStack { Text(string) Spacer() } LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())]) { ForEach(ints, id: \.self) { int in VStack { Text(string + String(int)) Spacer() } .frame(minWidth: 0, maxWidth: .infinity) .frame(height: 200) .background( RoundedRectangle(cornerRadius: 5) .fill(int % 2 == 0 ? .orange : .green) ) .onTapGesture { self.selectedCell = string + String(int) } } } } } } .padding() } if let selectedCell { VStack { Spacer() Text(selectedCell) Spacer() Button { self.selectedCell = nil } label: { Image(systemName: "x.circle") .resizable() .scaledToFit() .frame(width: 30) } } .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) } } } } the good news is that it seems you can work around it by making the second VStack persist, regardless of whether you are displaying a selection or not. Modify the second VStack like this (remove the if let selectedCell condition) VStack { Spacer() Text(selectedCell ?? "you don't see me") .foregroundColor(selectedCell == nil ? .clear : .black) Spacer() Button { self.selectedCell = nil } label: { Image(systemName: "x.circle") .resizable() .scaledToFit() .frame(width: 30) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to Send 'next slide' event to external device via keynote? Maybe via AppleScript?
what, ultimately, drives the presentation forward? Presumably the presenter - how? Rather than have Keynote tell the switcher what to do, have the presenter tell a script what to do. That script tells Keynote what to do, and tells the switcher what to do. Keynote has a compatibility suite of Apple Events including start, show next, show previous.
May ’23
Reply to Dialog Display in AppleScript
maybe this will help you get started: try set theReply to (display dialog "this is my prompt" buttons {"Cancel", "first thing", "second thing"} default button 1) if the button returned of theReply is equal to "first thing" then display dialog "you chose the first thing" else if the button returned of theReply is equal to "second thing" then display dialog "you chose the second thing" else display dialog "you chose nothing" end if on error e number n display dialog e & " (" & n & ")" end try
Topic: App & System Services SubTopic: Core OS Tags:
May ’23
Reply to DriverKit provisioning issues
"Shall I have DriverKit in the Distribution section?" no, you should not expect to see DriverKit there. DriverKit isn't a method of distribution. Xcode should be able to make your app for ad-hoc or development distribution automatically. It will generate certificates and profiles for you. Make sure that is working first, before creating a profile for App Store distribution. For App Store distribution, you need to be the account holder (not merely an Administrator) to make a profile containing a restricted entitlement such as com.apple.driverkit.transport.usb. That's probably what is leading to your "unexpected error occurred" on the Portal.
Topic: Code Signing SubTopic: Entitlements Tags:
May ’23