Answer by Steven Fisher for Using 'if let varName {...}' in Swift when...
The code does make sense, actually. if let word unwraps the outer variable word (which is an optional), making inner word (i.e. within the true component of the if) a non-optional string.You should be...
View ArticleSizing of SwiftUI's contextMenu preview
I've got an app presenting some messages. I'm trying to add a contextMenu on those messages, so holding on one of them presents a larger version of the avatar and options such as showing the user's...
View ArticleComment by Steven Fisher on Sizing of SwiftUI's contextMenu preview
Thank you. There's a few great techniques in your code that I didn't know about yet, and it certainly solves my problem!
View ArticleComment by Steven Fisher on How to change LocalizedStringKey to String in...
This doesn't answer the question. Also, doesn't this double dereferencing the key?
View ArticleInclude graphic only in debug build?
Is there a simple way to make sure a resource isn't included in the release build of my app using the Configuration switch?It's never used in the release build, but given it's nature I'd prefer to not...
View ArticleComment by Steven Fisher on How do I test a camera in the iPhone simulator?
Some interesting complaints here. If you're planning to ship without testing on a real device you're planning to ship an application that doesn't work. Sure it would be nice to simulate a camera, but...
View ArticleSwift lazy static member initialization
Starting from this code:class Formatters { static let shared = Formatters() var humaneNumbers: NumberFormatter; private init() { humaneNumbers = NumberFormatter() humaneNumbers.numberStyle = .decimal...
View ArticleAnswer by Steven Fisher for Android studio needs to be updated for Mac Monterey
There are two problems here:Android Studio uses Python 2, which Apple is committing to dropping in a future version of macOS. That's what the warning is saying, albeit in less technical terms. It's up...
View ArticleDoes my application "contain encryption"?
I'm uploading a binary for the first time. iTunes Connect has asked me:Export laws require that products containing encryption be properly authorized for export. Failure to comply could result in...
View ArticleAnswer by Steven Fisher for Adding top actions to bottom navigation activity...
As @ianhanniballake points out, there's some documentation specific to Fragments and App Bars: Working with the AppBarI don't want to just drop the link here, so here's how I read it (and if I got...
View ArticleAnswer by Steven Fisher for How to make NSOutputStream redirect to standard...
There's no need for Cocoa to provide its own constructor here because stdout is available as a "file." This doesn't seem to be documented, unfortunately, but works very well:NSOutputStream...
View ArticleInspect NSCache contents on iOS?
Is there a way to inspect NSCache's contents for debugging purposes?This would not be used in the App Store. I just would like to be able to see what's going on in there while debugging. The...
View ArticleMessaging a __weak object?
What happens if I send a message to a weak object? Does sending the message possess the object and hold it in memory until return?I'm thinking of this pattern:__weak MyObject *weakSelf =...
View ArticleHow to handle a mess of async operations?
I have a task for starting up in an Android app. It consistent of various subtasks, each of which has a completion. Some things need to run in sequence, others are just fire and forget… but I want...
View ArticleAnswer by Steven Fisher for How to update search results when scope button...
The behaviour you're expecting is logical and seems on the surface to be correct, but actually isn't. Thankfully, there's an easy workaround.Here's Apple's description of the method:Called when the...
View Articlexcodebuild: simulator or device?
How do I specify to xcodebuild (the command line tool) whether I want to build for the simulator or device?
View ArticlePod update integration only?
When you're updating cocoapods, you can update a single pod or all pods, either pod update or pod update <podname>. In both cases, it updates the configuration of the project, xcconfig files, and...
View ArticlePer target source in Android Studio Java? [duplicate]
I have a source file in my project at app/src/(product name)/util. I also have two possible build variants of my product. You could view this as white labeling, but it's really just for targeting a...
View ArticleHow to convert colors from one color space to another?
Is there a Cocoa Touch way to convert colors from one color space to another?At the end of this code:UIColor *grey = [UIColor colorWithWhite: 0.5 alpha: 1.0];CGColorRef greyRef = [grey CGColor];int x =...
View ArticleNSLog/printf specifier for NSInteger?
A NSInteger is 32 bits on 32-bit platforms, and 64 bits on 64-bit platforms. Is there a NSLog specifier that always matches the size of NSInteger?SetupXcode 3.2.5llvm 1.6 compiler (this is important;...
View Article