Post

Replies

Boosts

Views

Activity

Reply to Binary operator '/' cannot be applied to two '() -> [Double]' operands
Nobody can "fix" this without seeing the actual code that has the error, so please post that. Remember to use the "code block" formatting feature in the editor, and cut down the code sample to the bare minimum that still demonstrates the issue. But first, consider the error message: the compiler says you are trying to divide two operands which aren't actually numbers, but which are actually each a function or closure. Why is that? Are you intending to divide two numbers? If so, why does the compiler think they aren't numbers? Work backward from the point of the error to see how each operand is defined.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Implementing a RandomNumberGenerator for testing
I expected the sequence to be returned in order, from 0 to 9. This expectation is based only on the previous observed behavior, not on the documented behavior, so it turned out not to be a safe expectation. The issue is that there is no documented relationship between (1) the value returned from your RNG's next() method; and (2) the result of calling Array.randomElement(using:) or Int.random(in:using:). That is, exactly how those methods "use" your RNG is undocumented, and is therefore subject to change. Sounds like randomElement() formerly used your RNG's result directly as the index for the random element, but now it does something different. Both those behaviors are valid as they fulfill the documented API contract. (The documentation for randomElement() actually includes a note that emphasizes this undocumented-ness.) What do I need to do in the random number generator implementation to get it to work with arrays (and ranges) correctly? The current behavior is "correct", so let's change the question to: What do I need to do in the RNG implementation to achieve specific desired behavior in Array.randomElement(using:) both now and in future versions of the Swift library? The answer is: you can't. However, you may be able to achieve your testing goals by using your RNG in a different way, such as using it to generate pseudo-random array indexes directly, to replace usage of the system's randomElement() method. Or maybe you just want to iterate directly over the collection and perform testing logic on each element. It just depends on what you're trying to do.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Activity by app
You want to discover battery usage of details about other apps that the user has installed on their device? That's almost certainly never going to be supported, as it’s a massive privacy fail.
Topic: Privacy & Security SubTopic: General Tags:
Aug ’21
Reply to Xcode for Windows
Short answer: There is no native Windows version of Xcode. Longer answer: Depending on what you want to learn or accomplish, a quick Goog Bing search will turn up some interesting workarounds that may be useful in certain circumstances. However, if you're at all serious about app development for Apple platforms, there's no realistic alternative to just getting a Mac.
Aug ’21
Reply to MacOS Build doesn`t works
The screenshot seems to have disappeared from your post, but I saw it earlier and noticed that your project path contains spaces and commas. Not necessarily your problem here but it’s worth looking into. You need to be careful about that when writing custom build phase scripts, using 3rd party tools that have their own scripting, etc. (I find it easiest to just avoid using paths with spaces or other characters that can cause scripting headaches.)
Aug ’21
Reply to Accessing C functions from Swift/SwiftUI
It’s the extern "C" declaration. That's a C++ language feature, but the bridging header needs to be pure C (or Objective-C). If that code is in an external or shared header file then you can wrap it in an #ifdef __cplusplus guard. Or if it's directly in your bridging header in the project, you can just remove it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’21
Reply to Binary operator '/' cannot be applied to two '() -> [Double]' operands
Nobody can "fix" this without seeing the actual code that has the error, so please post that. Remember to use the "code block" formatting feature in the editor, and cut down the code sample to the bare minimum that still demonstrates the issue. But first, consider the error message: the compiler says you are trying to divide two operands which aren't actually numbers, but which are actually each a function or closure. Why is that? Are you intending to divide two numbers? If so, why does the compiler think they aren't numbers? Work backward from the point of the error to see how each operand is defined.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Screen time at 100%
Probably a tab in your Safari browser. Maybe it has some misbehaving JavaScript that makes Screen Time think you are actively interacting with it when you really aren't.
Replies
Boosts
Views
Activity
Aug ’21
Reply to Implementing a RandomNumberGenerator for testing
I expected the sequence to be returned in order, from 0 to 9. This expectation is based only on the previous observed behavior, not on the documented behavior, so it turned out not to be a safe expectation. The issue is that there is no documented relationship between (1) the value returned from your RNG's next() method; and (2) the result of calling Array.randomElement(using:) or Int.random(in:using:). That is, exactly how those methods "use" your RNG is undocumented, and is therefore subject to change. Sounds like randomElement() formerly used your RNG's result directly as the index for the random element, but now it does something different. Both those behaviors are valid as they fulfill the documented API contract. (The documentation for randomElement() actually includes a note that emphasizes this undocumented-ness.) What do I need to do in the random number generator implementation to get it to work with arrays (and ranges) correctly? The current behavior is "correct", so let's change the question to: What do I need to do in the RNG implementation to achieve specific desired behavior in Array.randomElement(using:) both now and in future versions of the Swift library? The answer is: you can't. However, you may be able to achieve your testing goals by using your RNG in a different way, such as using it to generate pseudo-random array indexes directly, to replace usage of the system's randomElement() method. Or maybe you just want to iterate directly over the collection and perform testing logic on each element. It just depends on what you're trying to do.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Deactivate Notifications Of Other Apps
Sorry, no. You may have seen apps that do this on Android, but on iOS there is no such capability.
Replies
Boosts
Views
Activity
Aug ’21
Reply to How can I download the simulator for 14.7.1
There isn't currently a simulator for 14.7.1, and generally there isn't a simulator for every OS release. Expect to see simulator releases that correspond to meaningful API changes but not for security patches or other user-facing feature fixes. So the simulator can never fully substitute for testing on a real device.
Replies
Boosts
Views
Activity
Aug ’21
Reply to Activity by app
You want to discover battery usage of details about other apps that the user has installed on their device? That's almost certainly never going to be supported, as it’s a massive privacy fail.
Topic: Privacy & Security SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Xcode for Windows
Short answer: There is no native Windows version of Xcode. Longer answer: Depending on what you want to learn or accomplish, a quick Goog Bing search will turn up some interesting workarounds that may be useful in certain circumstances. However, if you're at all serious about app development for Apple platforms, there's no realistic alternative to just getting a Mac.
Replies
Boosts
Views
Activity
Aug ’21
Reply to MacOS Build doesn`t works
The screenshot seems to have disappeared from your post, but I saw it earlier and noticed that your project path contains spaces and commas. Not necessarily your problem here but it’s worth looking into. You need to be careful about that when writing custom build phase scripts, using 3rd party tools that have their own scripting, etc. (I find it easiest to just avoid using paths with spaces or other characters that can cause scripting headaches.)
Replies
Boosts
Views
Activity
Aug ’21
Reply to Accessing C functions from Swift/SwiftUI
It’s the extern "C" declaration. That's a C++ language feature, but the bridging header needs to be pure C (or Objective-C). If that code is in an external or shared header file then you can wrap it in an #ifdef __cplusplus guard. Or if it's directly in your bridging header in the project, you can just remove it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’21