UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Pro tips for UIKit performance

Recorded – watch the full episode on YouTube.

If you were to give one piece of advice to help improve performance, what would it be? What's the key performance tip to take away?

Janina Kutyn: This is not as concrete as I think would be helpful, but I think it's just important to think about all the operations that are happening in your code. Did you write code that will cause a lot of rounding of corners and transparencies that need to be composited over each other? Is that what your code is doing? Did you write code that's causing a lot of layout passes?

I think, even if you're not going to optimize your code, it is good to be aware of where something can go wrong in your code. So if you're seeing issues, you know where to go to optimize later when you are running into them.

I don't know if that was a very helpful tip. “Just think about performance, why don't you?”

“I think, even if you're not going to optimize your code, it is good to be aware of where something can go wrong in your code. So if you're seeing issues, you know where to go to optimize later when you are running into them.”

Paul Hudson: It is hard because we all have such different use cases. This is why you're saying, “think about where your code might go wrong." But it could be anywhere when you think about the full spectrum of applications out there. It’s challenging. And this is why so many projects out there have this Not Invented Here syndrome. We don't want to pull in dependencies. We want to do it ourselves in our own code using our solution to it even though something like SDWebImage, for example, has thousands of lines of code to handle all sorts of corner cases and known bugs and so on, that our solution would also have, we still feel better about pulling in nothing and writing it ourselves because we kind of control it. We know what's going on there.

And that's where performance becomes very hard to predict because you've written your own library for doing this and this and this and this. It could be anywhere in this constellation of code you've written. So it is challenging.

This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.

Listen on Apple Podcasts

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.