Posts

Post marked as solved
15 Replies
4.0k Views
This comes up a lot (for years) and has me buggered. class Act: Codable { var a: Uint32 var b: [UInt32]?... var z: [UInt32]? init( ...vars...)}I want to do a simple sum on .nonzerobitCount for every var a through z.I can write code to check,e.g.,10. if Act.b != nil {for index in 0..<Act.b!.count { if Act.b?[index] != nil { totalBits += Act.b?[index].nonzeroBiCount } } }but even with copy and paste this is exhausting and cludgy.
Posted Last updated
.
Post marked as solved
6 Replies
844 Views
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.
Posted Last updated
.
Post marked as solved
1 Replies
450 Views
to Claude31:you see that our post has been kicked again.Could it be anything other than the emoji symbol?I will use the Swift unicode syntax, e.g., \u{1F504} from now on.
Posted Last updated
.
Post not yet marked as solved
6 Replies
7.6k Views
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. ;-)
Posted Last updated
.
Post not yet marked as solved
0 Replies
848 Views
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:".
Posted Last updated
.
Post marked as solved
4 Replies
569 Views
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?
Posted Last updated
.