and how to track UISlider events without setting up multiple action handlers

Photo by Donald Tong from Pexels

The Requirement

I started implementing an AVPlayer with standard capabilities. The user can play, pause, and drag the slider (implemented with an ) to seek a point in the video.

While dragging, the player will stop updating the slider with the current progress derived from . Usually, this is done by setting up an observer with :

Instead, the will be used to calculate and reflect the progress pointed by the user’s dragging. Once the user releases the slider, we use to continue playing the video from the time converted from :

Tracking the Slider events

On the slider…


Building your own Action Sheet in Swift

Photo by Skitterphoto from Pexels

We should all be familiar with the action sheet that iOS uses in the system settings and Apple native apps:


The time zone localization tips missing from Apple’s official documentation

I came across a requirement from the product team earlier today where they want to display a UTC date in the format: , and it should be localized to the device’s active locale.

After some research, it is clear that the Foundation framework already comes equipped with the common operations you would do with time zones.

According to Apple’s documentation, you would use a to :

defines the behavior of a time zone. Time zone values represent geopolitical regions. Consequently, these values have names…


Separating the logic inside the table view’s data source will make your code reusable and easier to maintain

an empty table

The Requirement

I don’t need to have expert knowledge in user experience to realize that users don’t like to be left in ambiguity. Users require an immediate and clear visual indicator of the current state of the product they are using. In real life, when there is nothing on the table, we leave it tiny like that. But in an app, we want to show some custom content when the table view is empty to tell the user about that.

If you work in a team with designers, it is their responsibility to give you, the developer, instructions on what to display…


How I went from working around code to making code work for me

The Before

When I first started writing Swift (beginning of 2019), it was very obvious that Alamofire made making API calls a lot simpler than using the stock URLSession. I was basically copying code samples from Alamofire’s official documentation and pasting them verbatim into my code to modify bit by bit until they all compile and pass my manual testing.

It was not until a year later I began to realize there’s (always) a better way of writing the code, in this case, API requests with Alamofire. How I came to the realization? …

Jianyuan Chen

I read, write, work out, and try to stay hungry.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store