iOS, Objective-C, Swift, Design and Whatever Comes in Mind

Swift 4 Change: Limit a Protocol Adaption to Reference-Type-Objects

Often I need to declare a protocol and need a weak reference to it. It is quite common in the delegation pattern.

In order to store a weak reference, the implementing type needs to be a reference type. Therefore, the protocol must limit the type of its implementation so that only classes can implement it.

Swift 4 now introduced a new, preferred way to declare a class-only protocol: ​AnyObject​.

However, the old way, where you have to use the ​class​ keyword still works fine. Prior to Swift 4, there were some subtle differences between these two keywords, which has been removed in SE-0156 - Class and Subytpe existentials.

So now you can declare a protocol like this:

Only objects can implement it, so the compiler will prevent the following code form beeing compiled:

In addition to that, the protocol can still be used by a weak reference, like

The old way, the ​class​ keyword is not yet deprecated, but you can start accustom yourself to using ​AnyObject​ now.

The information in this article are taken from here.

"Swift 4 Change: Limit a Protocol Adaption to Reference-Type-Objects".

WWDC18: Update to my Submission

As the day came, I was really looking forward to, I got this email:

Image of the email form apple

I got a scholarship and therefore I will go to WWDC 🎉!
It took my breath away and I needed a few moment to realize it. I will be one of approximately 300 students.

After my first astonishment calmed, I thought about all the things that I have to manage as soon as possible. For example, I never possessed a passport – I had no need for it. Now it is one of the most urgent things on my list, as the fabrication needs about four weeks.

I did a little research and made a phone call. As it turned out, there is a thing called ‚express passport order‘, which costs more than the regular one but will get me the urgently needed passport in about four days.
This weekend, I will place that order. When my passport arrives, I can start to go for a ESTA-visa.

In the meantime, I booked my flight to San Jose. It will departure from Frankfurt am Main and will bring me right to San Jose without any intermediate landing, which is great.

Lodging will be provided by Apple so fortunately I do not need to care about it, yet.

Oh, I am so exited about this opportunity!

If you want to follow me on my journey, follow me on twitter. I would also love to meet with as many cool persons as I can, so please also contact me 🙃

"WWDC18: Update to my Submission".

WWDC18: My Scholarship Submission

I promised to publish my WWDC 2018 Scholarship submission. Using this blogpost, I want to explain what my submission is about. You can find it over here at GitHub.
As always, I appreciate any kind of feedback. 😊

About this Playground

Screenshot of the playground.

This playground is designed to teach developers the basics of digital color representation. It starts with human biology and uses math to bridge its characteristics to the computational, digital space.
The user can interact with a custom color picker. By tuning a color, one can experience the relationships between theory and practice in a straightforward way.
In addition to that, the user can open a camera view that makes it tangible what it means to have a wider color space displayed.

My code makes heavy use of UIKit and CoreAnimation. I created a completely custom HSB-Color picker by subclassing UIControl. By using its functionality, the user is able to interact with the color space in a direct way. The tuned color is then presented in a 2D diagram which contains every perceptible color.
The theoretical aspect of this work is contained in the non-interactive part of the playground, accompanied by graphic illustrations.

After the user has familiarized themselves with the digital representation of a color and what a color space really means, one opens a live feed from the devices camera.
There, AVFoundation is used to capture the video data. Then, a CIFilter is used to manipulate the pictures. A CIKernel has been written by using the CIKernel-language, that highlights every color which is exclusively contained by the P3, but not by the sRGB color space.
When the user wanders around with the playground open, one can discover which colors of the surrounding need a P3-display to be captured accurately.

In summary, the project at hand gives the user the theoretical background to understand what a color space is, where its limitations are and why there is a need for a wider color space.

"WWDC18: My Scholarship Submission".