programming
The Developer’s Guide to Cell Content Configuration in iOS 14
Have you ever written table view code like this? override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath) let label = // … label.text = “Hello, world” return cell } Looks simple and innocent enough, but there’s something very wrong with it, philosophically speaking. This is …
The Developer’s Guide to Cell Content Configuration in iOS 14 Read More »
Control, Target, and Action in iOS 14
The target–action pattern is one of the oldest in Cocoa, and it’s used with some of the most important interface objects, namely controls (UIControl). That includes buttons (UIButton), switches (UISwitch), segmented controls (UISegmentedControl), and many others. It is also used with UIBarButtonItem because it’s button-like even though it isn’t a control (or even a view). …
Improvements in Testing in Xcode 12
Xcode 12, iOS 14, and Swift 5.3 bring with them a number of significant improvements in testing. If you live and die by tests — or even if you just wish you did — you’re going to be very happy to hear about these. Some of these changes actually appeared earlier, in Swift 5.2, Xcode …
Xcode 12 — What a Pane
As iOS programmers, we live and breathe and have our being within Xcode, so it makes sense to be as familiar as possible with its capabilities, and to take advantage of whatever innovations allow us to get work done. But, ironically, as a new version of Xcode is released, exactly when noteworthy new features are …
Swift 5.2: No More Unsafe Pointer References
When people upgraded to Xcode 11.4, a lot of complaints started to appear on StackOverflow that code of the following form was giving trouble (this is an odd way to write this, but just bear with me): let color = // some UIColor var r = 0 as CGFloat var g = 0 as CGFloat …
Get Started With Swift Packages
Encapsulating code so that you can share it between your own projects and with other programmers has always been a bit tricky in Xcode. You can write a framework easily enough, but sharing frameworks between apps is not simple, and it’s even harder to distribute your code to others as a framework, and for others …
Xcode Tip of the Day: Where Am I?
As soon as your app grows to more than a few view controllers, you can easily find yourself looking at code in Xcode’s code editor without a clear idea of where that code lives in your project as a whole. You know what code you are looking at, because the jump bar at the top …
The Joys of Logging
It’s no secret that I’m a huge fan of what I call “caveman” debugging, also known as logging. Real debugging involves breakpoints, stepping, examining the call stack, looking at variables, talking to LLDB; it’s powerful stuff, and should be part of every Xcode programmer’s toolbox. But sometimes the simplest way is to drop yourself a …