3 ms·
I wonder how they deal with things like creating user interfaces (and the outlet/action pattern), passing blocks, exceptions or creating their own classes, some
by miki123211 3y ago
I wonder how they deal with things like creating user interfaces (and the outlet/action pattern), passing blocks, exceptions or creating their own classes, something that you have to do quite frequently because of Apple's heavy use of the delegate pattern. The runtime does provide class creation functionality, so it's very much doable in C, but it requires a lot more code than doing it the official way. Creating classes in this manner is also an imperative action, so you need to keep track of whether your class has already been registered and return the existing instance if necessary.
- astrange 3y agoYou should not use exceptions in ObjC unless it's truly exceptional; most system code (and all ARC code by default) is not exception-safe and will leak objects if thrown through. And Swift will insta-crash if it sees one.