Peter Steinberger

Moving on… Or How Waiting for a Visa Was the Best Thing That Ever Happened to Me.

A few days ago I booked my flight back to Austria. Starting on April 13, I’m a full-time indie again. You’re probably saying: “What?! You’re leaving the Bay Area? This is sad!” But I’m very excited about it.

I’m in a better situation than ever before. I finally figured out what I want to do with my life. I’m no longer enviously looking at other places. I learned what’s really important, and that you can’t just replace life-long friends.

Don’t get me wrong. I’m going to miss San Francisco. Really. It’s such a great city, with such an awesome spirit, unlike any other city I’ve ever been to. (And heck, half of my Twitter followers are here, so it was super nice to finally meet up with you guys!)

So why leave at all? Well, it just didn’t work out. I’m full of ideas and really, really want to work on my own stuff.

Back when I got my job offer at a WWDC party in 2011, I was in an entirely different position, working as a freelancer for some nice companies, but wanted a change. So the prospect of living in San Francisco, being part of the startup culture, and working together on something great, was very, very appealing. (Damn you, Hacker News!)

So, I accepted the offer and waited for my visa. Waited, and waited. I stopped doing freelance work because initially we thought it’d all be done in a month. Ha, how wrong we were. In the end it took more than six months! I even finished my bachelor’s degree during that time.

But it wasn’t only that. Suddenly my mind was free from all the freelance work (and the feeling of guilt when I didn’t work on it). Naturally, I filled that space up with other projects. And, partly inspired by some friends, I wanted to try the paid component business. So this happened. And while waiting for my visa, I created a viable business that’s now making more money than my full-time job possibly ever could.

Still, all gears were set for SF, so I took the gig. It became all about the experience now. I really believed I could do it. But then, managing a more than 40-hour job with basically another full-time job on the side is nearly impossible, and after killing myself for a while, I finally had to choose which is more fun. Well, let’s say it wasn’t a hard decision. (To be honest, it was in fact very hard. I hate letting people down, and of course while it was a business I was leaving, I also respected the people there, and had a hard time knowing I would be disappointing them and the high expectations they had for me.)

This all sounds so simple and logical now, but I really jumped into the whole business blind, yet landed on my feet. Support requests and ideas were exploding, and as revenue went up, so did the amount of time required to care about my product. Also, I was really looking forward to working with some well-respected people in the iOS scene, only to find out that they had already left the company before I arrived.

Lastly, NSConference gave me the final kick: such an amazingly great amount of inspiring people that genuinely love what they do – you can’t just go back to your 11-7 job after experiencing that. Also, meeting customers that use your product and really love it is the sweetest thing ever.

I have no regrets on trying it, and I’m very thankful for the opportunity the job gave me – in fact it’s one of the best things that ever happened to me! It gave me the guts to go full indie, without even thinking about it. It helped me to figure out what I really want to do with my life.

So, what’s next? Well, I’ve got big plans with making PSPDFKit even better… and then there’s this other app idea that’s crossing my mind way too often. I’m building this for myself, because I really, really want it. And in the past, every time I have done something for myself, it turned out to be a great success. If you want to hear more about it, you should follow me on Twitter.

And about San Francisco, I’ll probably be back pretty soon. ;)

Don’t Call willChangeValueForKey Unless It’s Really Needed

You’re using KVO, right? So you most likely have already written code like this:

Carefully encapsulate your calls within a call to willChangeValueForKey/didChangeValueForKey to “enable” KVO. Well, turns out, you just did shit work. There’s no reason to do the will/did dance, as long as you are using a setter method to change the ivar. It doesn’t need to be backed by an ivar or declared as a property. KVO was written long before there was anything like @property in Objective-C.

In fact, I have been writing iOS apps for about four years and didn’t know this. A lot of open-source code also gets this wrong. Apple has some good KVO documentation, where it explains the concept of automatic change notifications.

There is a reason why you want to manually add willChangeValueForKey: most likely changing a variable also affects other variables. The most popular example is NSOperation:

Sometimes you might also want to optimize how often you’re sending KVO notifications with overriding automaticallyNotifiesObserversForKey: to disable automatic change notifications for certain properties.

In this example, there might be expensive KVO observations when the image changes, so we want to make damn sure that KVO is only fired if the image actually is a different one than the image that is already set:

If you currently have such obsolete calls, they’re not doing any harm. Incrementally called, willChangeValueForKey doesn’t emit more notifications. Still, time to delete some code!

Update: Don’t forget that there are more ways that’ll save you manual calls to will/did, like using the little-known addition keyPathsForValuesAffecting(PropertyName), which utilizes some runtime magic to make KVO smarter. Here’s a real-life example of how I used that on AFNetworking, so people can register a KVO notification on “isNetworkActivityIndicatorVisible” and it’ll get sent every time activityCount is changed. (You’ll also see that I do some atomic updating that requires manual KVO.)

Reboot

I’ve rebooted my blog. I will add random bits about iOS development and some personal thoughts, especially since some of my friends complained that apparently I tweet too much (cough Amy cough) And they’re right. I love Twitter, but sometimes you just need more than 140 characters.

The old content has been moved into limbo. Most of it would have needed some update to be valid again, so you’re not missing a lot. That said, if you’re coming from Google and miss a particular thing, hit me up on Twitter and I might dig it up for you.