Sign in

If you are in the migration process from Objective-C to Swift language, you maybe need to subclass some new Swift class back in objc. Today I will show you how you can do this and why you shouldn’t.

Investigation

Let’s create our guinea pig class.

If you try to compile this code, you would be greeted by the “Cannot subclass a class with objc_subclassing_restricted attribute.” error. But wait, my class is not marked by any attribute! Or is it?

Let’s open the bridging header and find our class:


I’ve been fascinated by animations from the start of my software development career. When I started writing macOS applications using Cocoa, one of the first things I did was an animated button. Just an ordinary button. With some ripples when you click it. It looked like this:

NSGolova

MacOS and iOS dev. ObjC paradigm fan.

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