Post

Replies

Boosts

Views

Activity

SceneKits future
I have developed an app using SceneKit since Swift came out. Now SwiftUI is out and uses structs rather than classes. SceneKit is a cascade of classes. As a newbie, I am concerned that my code might be obsolete through depreciations soon after publication and I'd rather get ahead of the issues now. So, is SceneKit long-term viable? My first attempts at converting my custom classes to structs seems impossible without Apple leading the way. If I understand correctly, I can make a struct whose only member is an instance of a class, but the benefits of the struct, e.g., minimal memory, processing time, etc., are lost.
13
0
7.2k
Mar ’20
swift Process() return values
How do I access a returned value from a Process(), in this case 'which'... var sips_path : String? //MARK: locate sips on local machine let which_sips = Process() which_sips.executableURL = URL(fileURLWithPath: "which") which_sips.arguments = ["sips"] do { sips_path = try which_sips.run() } catch let error as NSError { sips_path = "/usr/bin/sips"; print("Failed to execute which_sips", error) }line 8. gets compiler error "Cannot assign value of type '()' to type 'String?'" I believe, but cannot prove, 'which' returns a string. .run() throws and throws are for errors only, right? So where is the result of calling which?It seems I should use a closure to use $0 but it's already in one...line 9. intends to assign a default path.
13
1
7.1k
Mar ’20
How to get a count of the characters allowed for use in url passwords in any language.
The documentation states CharacterSet and CharacterSet.urlPasswordAllowed are each a set, assuming a Swift set. As such I should be allowed to append ".count"."However, I get a compiler error: "Value of type 'CharacterSet' has no member 'count'".Inserting this into my code:for char in CharacterSet.urlPasswordAllowed { print(char) }compiler error:Type 'CharacterSet' does not conform to protocol 'Sequence'Which indicates CharacterSet isnota Swift set.Inserting this into my code:print(CharacterSet.urlPasswordAllowed)prints output to debugging area:<CFCharacterSet Bitmap>How then can I get a count of the characters allowed for use in url passwords in any language?I assume Apple has this set defined for every language that has a system font defined.
6
0
1.1k
Feb ’20
SwiftUI Button() .frame()
struct ContentView: View { @State private var newSetState = true var body: some View { VStack { if self.newSetState || !self.newSetState { HStack { Text( ... Text( ... }.font(.largeTitle).lineLimit(1).fixedSize() HStack { Text( ... Text( ... Text( ... }.font(.largeTitle).lineLimit(1).fixedSize() Button("emoji", action: { self.newSetState.toggle() } ) .font(.largeTitle) .frame(width: 36, height: 86, alignment: .center) } } .padding([.top, .leading, .trailing]) .frame(width: 280, height: 280, alignment: .center) }}I'm guessing my previous post was kicked because of the emoji symbol.The issue remains: Button() does not respond to the frame() method, as all my other views do. Indeed, if I create a Text() view, .font(.largeTitle) is sufficient to "grow" the view. The VStack{} responds to .frame() adjustments. The result of the above code produces the emoji in .largeTitle format but its top is cropped even though it is well inside the frame. The shadowed button behind it is shorter and wider and itself only accepts taps. That is to say, the copped emoji extends above the button in its background but is cropped well below the frame bounds.I am currently attempting to code a substitute Button() of my own until Apple can correct this. ;-)
6
0
8.2k
Feb ’20
SwiftUI Button().frame()
macOS ProjectApple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)Target: x86_64-apple-darwin19.3.0struct ContentView: View { @State private var newSetState = true var body: some View { VStack { HStack { if self.newSetState { Text(...... } }.font(.largeTitle).lineLimit(1).padding().fixedSize() HStack { if self.newSetState { Text( ...... } }.font(.largeTitle).lineLimit(1).padding().fixedSize() Button(LocalizedStringKey("🔄"), action: { self.newSetState.toggle(); self.newSetState.toggle() } ) .frame(width: 36, height: 36, alignment: .center) } }}Button functions, i.e., causes body to cycle again, but I cannot change its size. If set to .font(.largeTitle) as the Text that procedes it, the emoji gets its top truncated, even if frame is 136x136. (attempted to paste .png here, rejected). Apennding .scaledToFill() or .scaledToFit() does nothing.If I should post a bug to Apple, please post a url "how to:".
0
0
916
Jan ’20
NSAlert fails
I am a newbie here, first request. This is called-from and declared inside my viewcontroller class: func NrangeAlert() { let alert = NSAlert() alert.messageText = "N out of range" alert.informativeText = "use a number between 1 and 92" alert.alertStyle = .warning alert.addButton(withTitle: "OK") alert.runModal() print("Select a number between 1 and 92") }but fails to show the alert. It compiles.XCode Version 11.3.1 (11C504)Swift -versionApple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)Target: x86_64-apple-darwin19.2.0It successfully prints to the debugger area.What am I missing?
4
0
698
Jan ’20