Sharing a simple lesson and insight learnt when chasing a mysterious issue

Image for post
Image for post
Image is from Unsplash

No stub for method `XXX()`

In my workplace, recently we faced occasional test errors that happened only when run in test suite, even though individual test runs fine.

No stub for method `XXX()` using parameters (). (NSInternalInconsistencyException)

This kept me scratching my head for some time, but recently I found out that it is basically happening due to leak of the mock objects (and other objects stems from tests). If you are as naive iOS developer as…


How you can download hundreds of images via script at once + include them in your iOS project

Quite some time, I have been using a very handy tool created by Hardik Vasa called googleimagesdownload . This tool allows you to download multiple images from Google at once via command line. The following command will download 10 cat images, for example.

% googleimagesdownload -k cat -l 10


Image for post
Image for post

This blog post has been going viral for the past weeks in iOS community. It talks about potential iOS performance optimisations, backed by sound technical argument.

One of the optimisations talks about UILabel in UITableViewCell/UICollectionViewCell. You can read the original blog for detail, but here is the gist :

  • It is even more costly when the UILabel cannot be rendered in monochrome, e.g., using attributedText.
  • It could save you megabytes by nilifying labels’ text when you don’t need them. (Specifically in tableView(_:didEndDisplaying:forRowAt:) or
    collectionView(_:didEndDisplaying:forItemAt:)
    )


Leveraging CoreGraphics and UIKit techniques for fun and profit

In early December 2019, ShopBack GO released a Scratch Card feature that adds a little bit of fun to our users’ shopping experience. It has been a resounding success, with thousands of users scratching cards every day.

Image for post
Image for post
Example of our Scratch Card Voucher

Since this small feature can be easily decoupled and can benefit others, we have open-sourced the functionality. You can check it out below.

https://github.com/shopback/ScratchCard

In this article, I share my approach to implement the scratch card interface for iOS. I believe the tricks I learnt can be applied to other types of interfaces too.

Structure


Two blazingly simple ways to organize your complex collection of data

Recap

In the first part of this tutorial-style article, we completed the first section of the demo app, using UICollectionViewCompositionLayout. In this second part of the article, we will finish the demo, and also demonstrate how to create the equivalent in SwiftUI.

Image for post
Image for post

UICollectionViewCompositionLayout

If you remember, there are three different classes/concepts:

  • NSCollectionLayoutGroup
  • NSCollectionLayoutSection

Let’s look at the second section now!

Cat Foods Section

The…


Two blazingly simple ways to organize your complex collection of data

If you have used our GO section of our ShopBack app, you probably might have noticed that our home screen is vertically scrollable as a whole, yet some rows on the top are horizontally scrollable.

Image for post
Image for post
ShopBack GO home screen

To implement this type of interface that mixes vertical scrolling and horizontal scrolling, before iOS 13, it meant you need to implement nested UICollectionView, by setting inner UICollectionViewinstance(s) in outer UICollectionView's cell(s). …


Safely store sensitive information in the repository to share them with your colleagues and also CI/CD

Image for post
Image for post

When you make an app that consume any resource over network, it will most likely hold sensitive information, like API key or API secret.

For example, TMDb API is a handy API with which you can query movie information with number of different filters. You can create an app that shows list of movies like below in a jiffy. Yeah, it’s really handy.


Challenge

As a frontend developer, you take pride in implementing whatever cool design your designer brought to you. For that, you want to prepare your mindset by making it a habit to look at cool designs and think about how to implement it.

I have recently encountered a cool design in Instagram :

Image for post
Image for post
Design by Adam Zielonko (http://gotinst.gotceleb.com/m/Bt2qC_lnYNL)

There are quite a few cool factors like speed animation of progress bar, or map-button-transforming-into-three-buttons etc. However, in this article, I want to focus on the animation of the line path, which is at first used for progress bar, but later transformed as a path on the map.


Achieving a unified custom look throughout the app with simple tricks

Image for post
Image for post

What we want to do

In iOS, there is a mechanism called UIAppearance to define an app’s global configuration. For example, you can set a consistent background color of the navigation bar with just one line :

UINavigationBar.appearance().barTntColor = UIColor.blue
UILabel.appearance().font = UIFont(named: "Gills Sans", size: 14)


Seemingly easy technique, which benefits from good mental model to untangle the kinks

Infinite Scroll by Josh & Eliza, WWDC 2011

The technique of infinite scroll for iOS is known for years, although it has been considered difficult at times even today. First time I heard about it was in WWDC talk by Josh & Eliza in 2011.

Normally, when you left swipe on a scroll view, you get the impression that your screen flows toward the left. However, iOS is just giving you that impression by moving the view port to the opposite direction. In the next example, only lime green part of the scroll view was…

Yuichi Fujiki

Coding in Swift, want to learn Flutter, a Dad, a Rock Climber, learning Parkour and Guitar

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