Post

Replies

Boosts

Views

Activity

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
Reply to SwiftU Document-based app error: "The document could not be opened"
I'm guessing, but this sounds like a sandboxing issue. In order to create a new file, you need to have the com.apple.security.files.user-selected.read-write entitlement set to true. But a file chosen programmatically by a Recents menu isn't user-selected. If your Recents logic is storing a path to a file outside of your app's bundle or its own, sandboxed Documents folder, your program won't be able to open that file. If you store your recents as security-scoped bookmarks, it should work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure
the problem appears to lie with the second parameter you pass to the TextField view builder. You must have a var user somewhere - what kind of object is user, and does it really have a property called user inside it? I'm using the @State wrapper because it is convenient for state variables which outlive the ContentView itself, but it often isn't useful in a real application. An instance of your User struct will normally live in your data model. I can get your code to compile if I write the following. Note there is more than one way to put an Int into a TextField. struct User: Codable { var firstName: String var lastName: String var isAdmin: Bool var storeNumber: Int var teamMemberNumber: Int var userApproved: Bool var userCreated: Bool } struct ContentView: View { @State private var user = User(firstName: "first", lastName: "lastName", isAdmin: false, storeNumber: 24, teamMemberNumber: 42, userApproved: false, userCreated: false) var body: some View { Form { Section(header: Text("Employee Name")) { Text(user.firstName) TextField("First Name", text: $user.firstName) TextField("Last Name", text: $user.lastName) } Section(header: Text("Employee and Store Info")) { TextField("Store Number", value: $user.storeNumber, formatter: NumberFormatter()) .keyboardType(.numberPad) TextField("Team Member Number", value: $user.teamMemberNumber, formatter: NumberFormatter()) } } } } and I can reproduce your error by replacing the last line with this one TextField("Team Member Number", text: Int($user.user?.teamMemberNumber)) the TextField expect to the text: parameter to be a binding to String, not an Int. Instead of complaining about that, the compiler complains about the Form declaration. The usual initializer for Form is this one public init(@ViewBuilder content: () -> Content) while an extension on Form defines this one public init(_ configuration: FormStyleConfiguration) The parameter to init which you write after Form might be a View builder, and might be a FormStyleConfiguration. If the expression is malformed, the compiler has to make a guess about what you meant to write, here it guessed wrong, gives you a misleading error message and doesn't point out the real source of the error (the declaration of TextField a text: parameter which is mismatched). The compiler does keep getting better at pointing out errors. If you file a bug on this Apple might fix it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
Reply to MAC address
iOS 7 release notes are archived here https://developer.apple.com/library/archive/releasenotes/General/WhatsNewIniOS/Articles/iOS7.html#//apple_ref/doc/uid/TP40013162-SW1 search for "MAC address" on that page
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’23
Reply to Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure
what code do you have a problem with? The unformatted code, or the code in the code block? The unformatted code works for me, but I had to replace $user.user?.firstName ?? "" with $firstName, where I declared a @State private var firstName = "Joe", and similarly for lastName. The formatted code shouldn't compile, because Int() returns an Int, while ``TextField's text: parameter should be a Binding<String> Try simplifying your code to something you can post as a complete sample. That alone may lead you to a solution. If it doesn't, post the complete sample here and indicate clearly what is not working (you said "in the title on the following form", but there is no "title" field). Also mention what platform (macOS, iOS etc) you are targeting, and what Xcode version you are using.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
Reply to How to compress an AVAudioPCMBuffer to m4a file format without writing to disk?
I just had a quick glance at the OpenAI Whisper API - the translation and transcription endpoints expect a file, not a stream. Your path of least resistance is likely to be to create a RAM disk using hdiutil. hth, Stuart
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
May ’23
Reply to Mac M2 pro libusb read/write performance
are you sure that the device you are communicating with is enumerating at the same speed on each platform?
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to scrollTo() leads to invalid UI in VStack in iOS 16
set the anchor to nil. The documentation for scrollTo: says If anchor is nil, this method finds the container of the identified view, and scrolls the minimum amount to make the identified view wholly visible.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to [SwiftUI] Slider text is not appearing at all
If you target macOS, the associated Text() fields appear. On iPadOS, they do not. I guess you have to describe the labels separately if that's the look you want. It would be nice if this behavior were documented somewhere.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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.
Replies
Boosts
Views
Activity
May ’23
Reply to SwiftUI - ScrollView with LazyVGrid and onTap, scrolling randomly by itself
maybe it is no help to you, but there's no funny behavior here (iPhone 14 Pro simulator on M1, Xcode 14.3 14E222b) ). I just copy/pasted your code and changed its name to ContentView.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
May ’23
Reply to Cannot convert value of type in extension
or let precisionNumber = (pow(10, places) as NSDecimalNumber).doubleValue
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to SwiftU Document-based app error: "The document could not be opened"
I'm guessing, but this sounds like a sandboxing issue. In order to create a new file, you need to have the com.apple.security.files.user-selected.read-write entitlement set to true. But a file chosen programmatically by a Recents menu isn't user-selected. If your Recents logic is storing a path to a file outside of your app's bundle or its own, sandboxed Documents folder, your program won't be able to open that file. If you store your recents as security-scoped bookmarks, it should work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure
the problem appears to lie with the second parameter you pass to the TextField view builder. You must have a var user somewhere - what kind of object is user, and does it really have a property called user inside it? I'm using the @State wrapper because it is convenient for state variables which outlive the ContentView itself, but it often isn't useful in a real application. An instance of your User struct will normally live in your data model. I can get your code to compile if I write the following. Note there is more than one way to put an Int into a TextField. struct User: Codable { var firstName: String var lastName: String var isAdmin: Bool var storeNumber: Int var teamMemberNumber: Int var userApproved: Bool var userCreated: Bool } struct ContentView: View { @State private var user = User(firstName: "first", lastName: "lastName", isAdmin: false, storeNumber: 24, teamMemberNumber: 42, userApproved: false, userCreated: false) var body: some View { Form { Section(header: Text("Employee Name")) { Text(user.firstName) TextField("First Name", text: $user.firstName) TextField("Last Name", text: $user.lastName) } Section(header: Text("Employee and Store Info")) { TextField("Store Number", value: $user.storeNumber, formatter: NumberFormatter()) .keyboardType(.numberPad) TextField("Team Member Number", value: $user.teamMemberNumber, formatter: NumberFormatter()) } } } } and I can reproduce your error by replacing the last line with this one TextField("Team Member Number", text: Int($user.user?.teamMemberNumber)) the TextField expect to the text: parameter to be a binding to String, not an Int. Instead of complaining about that, the compiler complains about the Form declaration. The usual initializer for Form is this one public init(@ViewBuilder content: () -> Content) while an extension on Form defines this one public init(_ configuration: FormStyleConfiguration) The parameter to init which you write after Form might be a View builder, and might be a FormStyleConfiguration. If the expression is malformed, the compiler has to make a guess about what you meant to write, here it guessed wrong, gives you a misleading error message and doesn't point out the real source of the error (the declaration of TextField a text: parameter which is mismatched). The compiler does keep getting better at pointing out errors. If you file a bug on this Apple might fix it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to MAC address
iOS 7 release notes are archived here https://developer.apple.com/library/archive/releasenotes/General/WhatsNewIniOS/Articles/iOS7.html#//apple_ref/doc/uid/TP40013162-SW1 search for "MAC address" on that page
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure
what code do you have a problem with? The unformatted code, or the code in the code block? The unformatted code works for me, but I had to replace $user.user?.firstName ?? "" with $firstName, where I declared a @State private var firstName = "Joe", and similarly for lastName. The formatted code shouldn't compile, because Int() returns an Int, while ``TextField's text: parameter should be a Binding<String> Try simplifying your code to something you can post as a complete sample. That alone may lead you to a solution. If it doesn't, post the complete sample here and indicate clearly what is not working (you said "in the title on the following form", but there is no "title" field). Also mention what platform (macOS, iOS etc) you are targeting, and what Xcode version you are using.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’23