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) It successfully prints to the debugger area.What am I missing?
Post
Replies
Boosts
Views
Activity
yes, a macOS project. DOH! You're right, it never executed.It does present the alert WHEN EXECUTED! lol
BTW it printed to the debugger area by way of other triggers to print it there. All now call the NrangeAlert().Thanks!
Yes, to refresh with every tap.If yours is not cropped, I'm stunned. I wish I could post a .png of it (worth a thousand words).I solved my problem by making my own button in a new file declaring:struct TempButton: View { var body: some View { HStack { Text("\u{1F504}") } }}then replacing Button() in ContentView{}... TempButton() .onTapGesture { self.newSetState.toggle() }.font(.largeTitle).padding()And it looks and works well. Was I correct that my previous post was removed because it had an emoji symbol in it?
Just read this: (very helpful)https://forums.developer.apple.com/thread/97547...so yes, probably kicked for emoji symbol.To Claude31:"Where is the shadowed button in your code ?"the "shadowed button" I see in preview and in running code IS the Button(), Apples Button(), with the emoji as the label for it. I say shadow because while in Preferences:Fonts&Colors:Theme:Default(Dark), the Button() shows as a slightly darker grey than the background, and the emoji overlays it."Only thing I observe is that button reacts only on a limited height, not the full 286 of frame height."That's why I set the emoji's frame to 86 high because the emoji is square and less than 40, i.e., .largeTitle. My preview frame, the blue rectangle, shows that the emoji has plenty of room to grow above its cropped level.Maybe Apple is contemplating depricating Button() because it is so easy to make ones own. In any case, I'm running.Thanks. :-)
Ah... moved under App Frameworks. I was wondering if I was posting in the right forum.(newbie)Thanks!Actually since creating my own Button(), i.e., not using Apples', I'm running.I don't know how to close this discussion, nor indeed, if it should be closed.Ummm... just to clarify though. Are you able to use, in any code, Apples Button("🔄", action: {print("emoji trial")}).font(.largeTitle) and have it not be cropped?I have tried to do so in various views and they are all cropped. I've tried in a separate project that has no other methods compounding, and this emoji is still cropped.You've had me thinking... so I tried .font(.largeTitle) on existing Button()'s throughout my projects, and it crops. Appending .frame() is inconsequential.
Thanks for the excellent info. You are a good man for helping us!It is much more difficult than I imagined and would more than triple the code of my little app if I implemented their "scan of all unicode code units". |-) I'll just keep my less expensive method of generating chars.Thanks again.
Wow! Thanks Eskimo.I intended to use 'which' to locate sips as a convenience if other OS's had it somewhere other than /usr/bin/ , which may not be true. I could just continue to stipulate that the user provide it there. Since 'which' itself must be in /usr/bin , I guess I'm OK with that stipulation.Nevertheless, your answer taught me what I sought, and more. Should I execute a Process() in the future, that prints to stdout, I'll know how to do it. Thanks again.
Sorry for not replying sooner, but I just discovered "Content" on this forum and how to use it. I'm a newbie.My simple app uses arc4random to generate password characters. I currently feed it a range of several thousand (Int) to ensure any languages, e.g., Chinese which I hear has thousands of characters, have all possible characters. This is inefficient, although effective. I thought if I had the fixed range, or count of characters allowed in passwords, I could reset to that range for that language.I had no knowledge of the RFC's relation. I'll look into it. Thanks.In practice, over-ranging arc4random might just improve its unbreakablity with that extra degree of proprietary info (the range). It is wasteful but not so slow as to notice or annoy.btw: newbie is not in the spell checkers dictionary. Curious.Thanks for your help.
After further investigation, .frame() may not be to blame;-) , but .font(.largeTitle) that fails.Create your own button as shown above if you need .font(.largeTitle)
in order of response:to Claude31:line 04:- b is not nil so b? is useless, use b!- how could b![index] be nil ?It might be that not all b are occupied, e.g., just the first in the array. My fault for not specifying every detail: towit, e.g., b can have up to four members in the array, or none.line 05:- you had a typo : nonzeroBiCount instead of nonzeroBitCountSorry, yes a typo. This is not copied directly from my code but constructed just for this inquiry.to OOper:Yeah... I can't think of another way to "not use optional arrays".I love seeing your mystical syntax code. I'll try it. I'm not fluent with closures. I've used them of course, but still find them mystical.to all:I have failed in my request. I am looking for a way to "for loop" through Act's vars [a, b, c, ...,z] so I can apply any of the above methods.I have tried in vain to use enum.I have also considered making the vars a...z another level in the array so that the class Act has just one var, call it alpha then I could:for mychar in alpha{ insert line 10 here }But this would be a major rewrite of my app. I thought there might be a better way to loop through the members of the class.
I have rechecked my code, you are right about line 04 being useless, b[index] cannot be nil because it was included in the Act.b!.count.Thanks!
I took a closer look at your line 06" var bToz : [[UInt32]?] = [b, c, d, z] // You have to type all var names "If I make Act.a:[UInt32], even though it would hold just one UInt32, a var aToz could be added within the class declaration: var aToz: [[UInt32]?] { return [ a, b, c, d...., z] } The beauty of which is that it needs no initializer, so my init's throughout the code are not affected. All I had to do was put brackets, [ ], around every existing reference to Act.a Not as painful as I thought it might be.Thanks for the inspiration!
Just to be clear, I can now code a for-loop to go through just-the-vars-I-want:class Act: Codable { var a: [Uint32] var b: [UInt32]?... var z: [UInt32]? var aToz: [[UInt32]?] { return [ a, b, c, d...., z] } init( ...vars...)}...100. for member in Act.aToz { if member != nil {for index in 0..<member!.count { totalBits += member?[index].nonzeroBitCount } } }A further benefit is that when my "class Act" is written to a JSON file, the computed var "aToz" is not in it, not even a mention of it. So the file size is not "doubled" by adding the computed var! Love it.I want to rework : "let totalBits = act.b?.reduce(0, {$0 + $1.nonzeroBitCount}) ?? 0" and use it eventually... it's beautiful!
"b is an optional array (not an array of optionals."UhOh. You're right again. I have to rethink this. The array Act.a must exist and be non-nil, but all other vars Act.b thru z need not have values. Nor arrays then? Might I need optional arrays of optionals? Now I feel like I stepped in something. :-(