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

Image from Unsplash

In the last post, I shared a demonstration and a lesson that you always have to nil out instance variables in tearDown method in your XCTestCases. (You don’t need to go back to my last post if you landed here first. The bold statement above is the only thing you need to remember, really)

In this post, I will share another interesting case/lesson, which is specific when using Cuckoo.

Conclusion

Let’s start from conclusion this time. Sometimes, tonil out instance variable is not enough to evade from leaking mock…

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

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)

Certainly we have this Cuckoo stub somewhere in our test, but not in the failing test.

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

That was… until a month ago unfortunately 😢 (It is Mar 1, 2020 at the moment of writing). Apparently, google has changed the format of Google Image search results page and the scraping…

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 :

  • Internally, UILabel is just a bitmap. Thus, it is more costly than you would think.
  • 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:)
    )

But…

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.

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.

UICollectionViewCompositionLayout

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

  • NSCollectionLayoutItem
  • NSCollectionLayoutGroup
  • NSCollectionLayoutSection

NSCollectionLayoutItem represents the size of each UICollectionViewCell, and NSCollectionLayoutSection represents the same for the section. NSCollectionLayoutGroup is something in between to allow creating a flexible layout in each section.

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.

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

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 :

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

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

However, if you apply the same approach to the font like this:

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

all the UILabel instances will indeed have “Gills Sans”, but with 14pt size as well. I don’t think any app would want to have only 14pt fonts throughout the app. …

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