Post

Replies

Boosts

Views

Activity

Reply to Why does Array's contains(_:) method cause an error when comparing an optional value with a non-optional value in Swift?
My guess for the first is that the compiler in the first performs type inference and analyses ["hello", "world"] as array of optional. let result = ["hello", "world"].contains(Optional("hello")) // ✅ Works fine But in the second, let stringArray = ["hello", "world"] let result = stringArray.contains(Optional("hello")) // ❌ Compile-time error you explicitly declare stringArray to be [String]. Then in second line, compiler balks at it.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’25
Reply to How to integrate data from a web service into an array
That's because dataTask has not completed when you return. Look here to see how to wait until it has completed: https://stackoverflow.com/questions/38952420/swift-wait-until-datataskwithrequest-has-finished-to-call-the-return Write the sendRequest function, func sendRequest (request: NSURLRequest,completion:(NSData?)->()){ NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in if error != nil { return completion(data) } else { return completion(nil) } }.resume() } And use it inside var quotes. The completion will return output
Mar ’25
Reply to Most wanted Xcode features…
Wanted Feature : Get a warning when compiling if an IBOutlet is not connected. Pain point: It may happen to forget a connection and not see it (notably because in some cases, Xcode is mislead to show a connection that does not exist in this project). That's crash at runtime. Feasibility: When using storyboard, Xcode notes when an IBOutlet is connected or not to the storyboard object. So it must be easy to have it detected at compile/build phase.
Mar ’25
Reply to iOS Screenshot prevention Whatsapp
I tested on a WhatsApp conversation and could get a screen capture. What page is this ? If that could help: https://www.reddit.com/r/ios/comments/14yyvzo/can_i_disable_screenshot_detection/?rdt=61137 Note: have you tested to take a photo of the screen with another iPhone ? Does it work ? If so, even if you prevent direct screen capture, there are simple workaround…
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’25
Reply to Why does Array's contains(_:) method cause an error when comparing an optional value with a non-optional value in Swift?
My guess for the first is that the compiler in the first performs type inference and analyses ["hello", "world"] as array of optional. let result = ["hello", "world"].contains(Optional("hello")) // ✅ Works fine But in the second, let stringArray = ["hello", "world"] let result = stringArray.contains(Optional("hello")) // ❌ Compile-time error you explicitly declare stringArray to be [String]. Then in second line, compiler balks at it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to Cannot snapshot view warning
10 years later… with Xcode 16.2, same error message. I do not call snapshotView.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to tableView.dequeueReusableHeaderFooterView(withIdentifier: ) crashes on iPad only
Found it. My mistake. I had a test for iPad in the viewDidload. I inadvertently put the register in the iOS section ; so it did not apply for iPad !
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to Developing a driver to read HFS disks on MacOS Sonoma and newer
Many thanks ffor the information.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to How to edit a question?
You cannot beyond 1 hour after posting. If it is critical to get it deleted, ask forum administrator. You may try to just mark your own post as 'Duplicate', or 'other cause' (not spam, nor inappropriate, that could cause you problems later) ; usually, post is rapidly deleted.
Replies
Boosts
Views
Activity
Mar ’25
Reply to ForEach loop in a Map doesn't work
@DuBu error messages are, IMHO, a real weakness of SwiftUI. Messages are at best not helpful, at worst misleading.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to Capturing self instead of using self. in switch case in DispatchQueue causes compiler error
Thanks Scott. I filed a bug report: Mar 13, 2025 at 3:24 PM – FB16853197 I'll leave the thread open for a while, in case some compiler engineer notices it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to How to integrate data from a web service into an array
That's because dataTask has not completed when you return. Look here to see how to wait until it has completed: https://stackoverflow.com/questions/38952420/swift-wait-until-datataskwithrequest-has-finished-to-call-the-return Write the sendRequest function, func sendRequest (request: NSURLRequest,completion:(NSData?)->()){ NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in if error != nil { return completion(data) } else { return completion(nil) } }.resume() } And use it inside var quotes. The completion will return output
Replies
Boosts
Views
Activity
Mar ’25
Reply to Most wanted Xcode features…
Wanted Feature : Get a warning when compiling if an IBOutlet is not connected. Pain point: It may happen to forget a connection and not see it (notably because in some cases, Xcode is mislead to show a connection that does not exist in this project). That's crash at runtime. Feasibility: When using storyboard, Xcode notes when an IBOutlet is connected or not to the storyboard object. So it must be easy to have it detected at compile/build phase.
Replies
Boosts
Views
Activity
Mar ’25
Reply to my first post about swift language
Welcome to the forum. I hope your next posts will be more interesting and useful 😉
Replies
Boosts
Views
Activity
Mar ’25
Reply to Just want to check if
Welcome to the forum. You can access, but of course to a limited scope if you have no account. Why this question ?
Replies
Boosts
Views
Activity
Mar ’25
Reply to iOS Screenshot prevention Whatsapp
I tested on a WhatsApp conversation and could get a screen capture. What page is this ? If that could help: https://www.reddit.com/r/ios/comments/14yyvzo/can_i_disable_screenshot_detection/?rdt=61137 Note: have you tested to take a photo of the screen with another iPhone ? Does it work ? If so, even if you prevent direct screen capture, there are simple workaround…
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Mar ’25
Reply to App is marked as a blood alcohol content calculator
"Promillewert" Do you effectively reference to blood alcohol content ? If so, the problem is the app itself, as explained by reviewer. Just changing the wording by speaking of estimation will most likely not be enough. It remains a blood alcohol value. And this has to be provided by approved hardware (there are likely legal liability behind this).
Replies
Boosts
Views
Activity
Mar ’25
Reply to Immediate crash of Apple Watch simulator when typing a key
The bug cannot be reproduced anymore (Xcode 16.2, Watch simulator Series 9 45mm 10.0 or Series 6 45 mm OS 10.4). It seems solved ; may be thanks to MacOS update to Sequoia 15.3.1 (24D70). I closed the bug report as well.
Replies
Boosts
Views
Activity
Mar ’25
Reply to Change app language on Apple Watch simulator
Thanks a lot. That's so simple, once you know.
Replies
Boosts
Views
Activity
Mar ’25