Plain Old Stan

Wednesday, February 20, 2019

At some point I started to have dismal swift autocomplete delays in xCode 10 and slower compile times. Having googled this and that and optimizing what I could I also found into these type of warnings:

My first guess was that longer tuples are causing the problem. I changed this part to use structs, no joy.

One more part in the code gave me another hint:

Looked to me as if just adding up literals via "+" would be tricky for swift compiler's type checking.

If you ask on using string interpolation with \() - it didn't solve the problem. Plus I don't like these messy strings when they get longer.

I have no good words for the guys that work on Swift programming language and its design/tools. I don't think this part and types of optimization should really ever bother us, regular devs.

Bad, bad, bad.... I wish I could have loved Swift more. I love the language even if I don't think it is superior that much to Objective-C. Moving to it from Objective C with all new and updated stuff, but this is simply bad.

P.S. You can find a really good digest of Swift compile time optimizations here:

Looks to me as a broken "contract" and invariant. One would really expect the consistent behavior as it was since iOS7 and having the width of the string calculated as zero for zero font size and zero it should be downwards? Also string width jumping from about approaching zero values to 97.166016 when value got a bit on below zero looks inconsistent. Probably a missing unit test :)!

For me it looks like a bug and I'm reporting it to Apple now. Hopefully it will be fixed to the same consistent behavior as it used to be on iOS 7 - 10.

Defensive coding is like an alloc/release for me, I try to make it right and upfront, but doing static analysis later I found myself being "mentally away" way too often.

Tuesday, April 11, 2017

Didn't expect this to be such a problem, but once you tap into the UINavigationController things become hairy.

Requirement:

When user leaves a screen by tapping on a "back" in navigation bar and there are changed data in the screen I should ask for a confirmation and keep user at the current UIViewController if she decided to continue editing the data.

Once, I was trying to solve the keyboard accessory to be shown each time for each UITextField on shouldBeginEditing by writing a category for a UITextField. And here is something I learned in a hard way:

And was not I lucky? It really makes sense, no private APIs, framework's UIViewController gets the chance to do its stuff always. What I wanted to improve though was that "safeDelegate" property and the way it is established. So I added a new method (into UISafeNavigationController.m):

[UPDATE] In the end I had to rework the final part presented here - showing the confirmation as the way it is presented was not releasing the controller correctly and was not cleaning up the views as well. Quite bigger effort is required to get it right and it is not that generic in the end. But this is a good start! :).

Sunday, April 9, 2017

Today, some dialyzer stuff, but mainly debugging with Elixir was my study subject and so first I ran into iex telling me "Could not find 'wxe_driver.so'" on running :debugger.start(). Then I read that debugger starts anyway, so I tried simple :int.ni(Module), but was greeted with "no beam found for Elixir.Module". Read more and it pointed to Erlang version being lower than 19. Really iex and elixir --version were telling its 18 that is being started. Using brew upgrade erlang or elixir, brew reinstall - same thing. A year ago I installed erlang from the official installer here (https://www.erlang-solutions.com/resources/download.html). Looked there and there is an even version manager for the Erlang on OSX now?! Cool:

This surely helped to have version of erlang as 19.3 for elixir now and all the debugger stuff worked as expected.

Also, just in time for reading the book mentioned above comes an article from Saša Jurić: To spawn, or not to spawn? Definitely going to validate the book suggested solution/architecture with what Saša Jurić is writing.

Done with learning for today, back to creating some added value to my customers!