Inferred types make code cleaner and less prone to mistakes, while modules eliminate headers and provide namespaces. To best support international languages and emoji, strings are Unicode-correct and use a UTF-8
// Swift 2structCreditCard { number: UInt64, expiration: NSDate }letPaymentMade ="PaymentMade"// We can't attach CreditCard directly to the notification, since it// isn't a class, and doesn't bridge.// Wrap it in a Box class.classBox<T> {letvalue:Tinit(value:T) {self.value =...
Conceptually, a task is a unit of work that can be run asynchronously. More specifically, an instance oftheTasktypeprovides an environment where you can execute asynchronous functions or methods. Tasks can be arranged hierarchically, allowing you to run several tasks in parallel. This approach is ...
I guided it, step by step, like a teacher correcting a clueless student. It made stupid mistakes. I called them out. Five, six attempts later, it spit out something usable. The result? Astounding. A tool I’d never have built before. Not because I couldn’t understand it—there’s ...
This can lead to mistakes where due to the length of the mangled names one will look at the wrong function. Using the following command, one can find the mangled name of the function in the current frame: (lldb) image lookup -va $pc Address: CollectionType3[0x0000000100004db0] (...
Unlike in Objective-C, with Swift, we are not required to use self to access a class’ or struct’s properties inside a method. We are only required to do so in a closure because it needs to capture self. Using self where it’s not required is not exactly a mistake, it works just...
Can someone point out my mistakes here? Or am I on the wrong track here? Or is there another way to read data from a database? I have an API file on my server (no Localhost) <?php // Create connection $con=mysqli_connect("my-mysql-domain.com","usernmae","password","database"...
I suppose that is the line we walk here. Vibe marketing is to do it but not fully grok it. And for my money? That’s a fantastic place to start. Far less a gamble here than it is with shipping production code. When it comes to this stuff, it’s not the mistakes that will kill...
I think that properly designing the models or entities of a domain is one of the biggest contributors into good code, and the lack of it makes everything way harder than it should be. Thankfully Swift is a great language that allows us to express almost everything we need to in a very...
The problem is that our Node type is a struct rather than a class, so we’ve created some inconsistency here: when Sophie was added to my list of children I got a unique copy of her node, and when later we added Taylor to Sophie’s children that didn’t affect my data – my copy...