Brendan Molloy is a user on You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Brendan Molloy @piecritic

I could really use some help with macOS UI work for this Mastodon client I'm working on. I'm struggling ridiculously with the core concept of NSTableView cell resizing.

Please boost.

Β· Web Β· 77 Β· 10

@piecritic wish you the best of luck friend, if I weren't swamped I'd be all for helping ✌️

@eurasierboy ahhh doing it in iOS is so much easier though, ahahaha. The Cocoa API has not only been left to rot, but is badly documented as well, and actually has broken parts since it "evolved" that nobody has documented either.

Some things like "intrinsic height doesn't work unless you do view.stringValue = view.stringValue before checking it" is seriously voodoo nightmares.

@piecritic yeah, can't say I've had an experience in macOS dev that didn't leave a bad taste in my mouth. You hit the nail on the head on the piss poor documentation πŸ˜”

@eurasierboy one thing you could help me with without doing anything is just telling me the approach you took to parsing the `content` field of the Status entity. :D

@piecritic stripped all the tags using an NSScanner πŸ˜›

@eurasierboy LOL that is what i was going to do. fuck

@piecritic it's hardly optimal but given everything is 500 char or less (not including the tags but you get the point) it works Good Enoughβ„’. It'd be nice if we'd be able to just get a clean string to begin with though

@eurasierboy we could ask @Gargron nicely for an opt-in query flag that makes it plain text? ;)

@piecritic @eurasierboy Maybe NSAttributedString initialized with the HTML?

@eurasierboy I have found a bunch of HTML parsers that are similar to Nokigiri written in Swift that I will probably use once I give up on this terrible WebKit NSAttributedString parsing hack I've undertaken as a short term nightmare.


I think, as in iOS UITableView, you would use implement NSTableViewDelegate with tableView(_:heightOfRow).

I'm sure you probably have already found this, but Ray Wenderlich has a NSTableView tutorial here:

@erico it doesn't behave as it's documented at all, as it was designed before auto-layout was implemented, and they interact in such insane ways you need to be really in tune with the intricacies to get it to work consistently.

I have it "working", but it doesn't work properly on resize, and some toots will be the wrong size for no reason, while others are fine...

@erico also NSTableView does not support the premise of estimated heights and UITableViewAutomaticDimension.

I've found hacks that try to implement this, but none of them work in the general case, and it's driving me totally insane!

@erico I appreciate the feedback but I have also searched for this for the last almost two weeks in Google as well, and tried very many things, lol.

The problem is that height measurement is so very inconsistent none of these approaches work, as I have no fucking idea what the random lifecycles are that are fighting each other.

@erico I'd be more specific and less hand-wavey if I hadn't just completely broken the UI after trying a UICollectionView approach haha.

@piecritic hey, I'm an ex-iOS dev but I may help

@charlag every part of that toot is perfect.

@piecritic my journey was Android -> iOS (Swift!) -> (for the short time) Android -> iOS and Android (another guy leaves) and now I'm going to do Android only in another place

@charlag my company does Kotlin on Android to make it not totally suck. :)

@piecritic yeah, I brought Kotlin here too and it rocks. I miss some protocol stuff from Swift and that optional types are not real but apart from that it rocks, so many good design decisions

@charlag don't buy into that lie. Kotlin nullable types are real in Kotlin, as much as Swift nullable types are real in Swift.

Objective C can break those constraints just as well as Java can in Kotlin.

@piecritic I didn't mean that you can break it. Ofc you can. I meant that there's actually no optional types at runtime and you cannot make optional type from non-optional by hand

@charlag you've broken me. What do you mean by "cannot make optional type from non-optional by hand" at runtime?

@piecritic sorry, I probably hurry too much and cannot explain stuff properly.
suppose you have
let x = "Masto!"
How do you make a String? from x?
In Swift, you can
in Kotlin, you cannot, there's no
enum Optional<T> { ... }

@charlag I thought that might be what you are saying, but I can't think of the use case.

If you really need that you can just do this:

fun String.optional(): String? {
return this

@piecritic there was one case when I wanted to use Rx like that

.map { Optional(t) }
.filter { it != nil }

but I had to go with something like

@charlag why were you passing an optional out of a map? I usually use flatMap to get _rid_ of optionals in Rx.

In RxSwift, RxOptional's filterNil.

@charlag btw, I can keep an eye out for Kotlin opportunities for you if you like. Tell me which continent you exist within and I'll ping you. :D

@piecritic oh my, that sounds awesome. I live in St. Petersburg, Russia but I would love to go remote (our move out of here)

@charlag ha, my first iOS contractor was from Ukraine and is now in the UK (which I made terrible ISO puns about).

@charlag when hiring Kotlin devs, we could only find people in Russia, Ukraine or Vietnam. Nowhere else!

@piecritic yeah, yeah, I know :D No one calls it by island name here, tho, but by city name, Kronshtadt.
And lighthouse on the is from there ofc

@charlag you should create a kapt implementation of an optional enum that overrides all instances of Type? in a codebase and call it Kronshtadt just to spite everyone.

@charlag how often do the apps you work on rely on HTTP APIs for a majority of functionality?

@piecritic oh almost always I guess? I worked with awful API here...

@charlag right, so I use OpenAPI for literally everything now, and I have a Kotlin output.

You might want to play with it.

tl;dr you define a REST API in a YAML file, run it through a script, and get a Retrofit/OkHttp typesafe API + models out of it. xD

... and I haven't published the generator to github yet and only just realised omg.

@piecritic that's pretty cool, thanks for sharing!

@charlag yeah! It saved me about 1 month of real work time, and took about 1 week of real work to implement!

@charlag lol 33% of my iOS codebase is generated. Ever done localisation on iOS? ... yeah.

So I went around and it's awesome.

@charlag tl;dr my localisation library/generator can support Sami languages even if iOS doesn't. ;)

@piecritic !!
sorry, I think I have to work, was nice to talk

@charlag haha fucking timezones xD enjoy your day.

@charlag the best part is you aren't shitting a brick about accidentally implementing the API slightly wrong, because if it broke, the template is broken, or the generator is broken _on every platform at the same time_, so the bug is found really fast.

@charlag so I have one input, that can output a Swift, Kotlin and JS API. I generate my server's test API from the same specification that i use for mapping my routes to functions on Node.js... so many layers of self-testing.

@charlag but yeah, I didn't really think about the lack of a real Option type (like what Rust and Swift have) until you just said it.

@piecritic too bad I didn't get a Kotlin-specific job and I have to write Java now, I guess, but hey, back to the basics

@charlag btw, Kotlin is going native, targeting LLVM and planning to natively support Objective C libraries, so Kotlin for iOS is coming soon!.

@charlag and I unfortunately am adept at both, and it smells.

@charlag there isn't actually all that much crossover with iOS UIKit and Cocoa AppKit.

Superficially yes, but in practice everything is actually hell.

@piecritic please don't make the client "10.12 or later". Support older systems. TIA. :)

@nicoladagostino no chance. Use the web app if you want to stay in the past with no security updates on your OS, sorry.