On my earlier post, “Smarter Numbers”, we talked about using operator overrides in swift to extend the functionality of framework classes.
There’s a bit more to it than what was discussed in the article, but we’ve decided to keep it as a separate post due it’s less “orthodox” usage: Swift also allows you to, in what could be considered as a controversial feature, create custom operators. This means that not only can you change the behaviour of the language. you can also change the language itself*.
Continue reading “Smarter Numbers. Annex 1: Custom operators.”
When it comes to iOS app Development, I find one of the most commonly used framework class is NSNumber.
Which is ironic, because it’s a pretty dumb class. Really… there’s not much you can do with it except store numbers and check for equality. Albeit it being all over the place, it’s a pretty useless wrapper object. Whenever we need to edit the wrapped value we need to go through overly complicated statements like this:
number1 = NSNumber(float: number1.floatValue + number2.floatValue)
Fortunately for us, Swift is AWESOME.
Continue reading “Smarter Numbers”