"A failure in the hot air department"
Showing entries tagged "swift". Full blog index.
Friday Q&A 2017-10-06: Type-Safe User Defaults at 2017-10-06 12:55
It's fun to re-imagine traditional techniques with a Swift twist. I've implemented a type-safe layer on top of the venerable
NSUserDefaults, and I'm going to discuss my little library today. Credit/blame for this idea goes to local reader José Vazquez, although he inspired it by accident while talking about something else.
Friday Q&A 2017-09-22: Swift 4 Weak References at 2017-09-23 00:57
Soon after Swift was initially open sourced, I wrote an article about how weak references are implemented. Time moves on and things change, and the implementation is different from what it once was. Today I'm going to talk about the current implementation and how it works compared to the old one, a topic suggested by Guillaume Lessard.
Friday Q&A 2017-08-25: Swift Error Handling Implementation at 2017-08-25 13:13
Swift's error handling is a unique feature of the language. It looks a lot like exceptions in other languages, but the syntax is not quite the same, and it doesn't quite work the same either. Today I'm going to take a look at how Swift errors work on the inside.
Friday Q&A 2017-08-11: Swift.Unmanaged at 2017-08-11 13:14
In order to work with C APIs, we sometimes need to convert Swift object references to and from raw pointers. Swift's
structis the standard API for handling this. Today, I'd like to talk about what it does and how to use it.
Friday Q&A 2017-07-28: A Binary Coder for Swift at 2017-07-28 12:44
In my last article I discussed the basics of Swift's new
Codableprotocol, briefly discussed how to implement your own encoder and decoder, and promised another article about a custom binary coder I've been working on. Today, I'm going to present that binary coder.
Friday Q&A 2017-07-14: Swift.Codable at 2017-07-14 13:57
One of the interesting additions to Swift 4 is the
Codableprotocol and the machinery around it. This is a subject near and dear to my heart, and I want to discuss what it is and how it works today.
Friday Q&A 2016-03-04: Swift Asserts at 2016-03-04 14:30
Asserts are really useful for checking assumptions in code to ensure that errors are caught early and often. Today, I'm going to explore the assert calls available in Swift and how they're implemented, a topic suggested by reader Matthew Young.
Friday Q&A 2016-01-29: Swift Struct Storage at 2016-01-29 14:57
classes tend to be straightforward for most people new to the language to understand. They work pretty much like classes in any other language. Whether you've come from Objective-C or Java or Ruby, you've worked with something similar. Swift's
structs are another matter. They look sort of like
classes, but they're value types, and they don't do inheritance, and there's this copy-on-write thing I keep hearing about? Where do they live, anyway, and how do they work? Today, I'm going to take a close look at just how
structs get stored and manipulated in memory.
Friday Q&A 2015-12-25: Swifty Target/Action at 2015-12-25 15:11
Cocoa's target/action system for responding to controls is a great system for Objective-C, but is a bit unnatural to use in Swift. Today, I'm going to explore building a wrapper that allows using a Swift function as the action.
Friday Q&A 2015-12-11: Swift Weak References at 2015-12-11 14:16
In case you have been on Mars, in a cave, with your eyes shut and your fingers in your ears, Swift has been open sourced. This makes it convenient to explore one of the more interesting features of Swift's implementation: how weak references work.
Friday Q&A 2015-11-06: Why is Swift's String API So Hard? at 2015-11-06 14:00
Welcome to a very delayed edition of Friday Q&A. One of the biggest complaints I see from people using Swift is the
StringAPI. It's difficult and obtuse, and people often wish it were more like string APIs in other languages. Today, I'm going to explain just why Swift's
StringAPI is designed the way it is (or at least, why I think it is) and why I ultimately think it's the best string API out there in terms of its fundamental design.
Friday Q&A 2015-07-17: When to Use Swift Structs and Classes at 2015-07-17 12:54
One of the persistent topics of discussion in the world of Swift has been the question of when to use
classes and when to use
structs. I thought I'd contribute my own version of things today.
Friday Q&A 2015-06-19: The Best of What's New in Swift at 2015-06-19 13:12
Apple made a lot of interesting announcements at WWDC this year about the release of Swift 2 and the new features in it, in among various other announcements of little interest. In addition to the announcement that Swift will be made open source, which is a huge deal all by itself, Swift 2 contains a lot of great new features which significantly improve the language. Today I'm going to talk about the most important ones, what they are, and why they're useful.
Friday Q&A 2015-04-17: Let's Build Swift.Array at 2015-04-17 13:42
Swift 1.2 is now available as part of Xcode 6.3, and one of the new APIs it includes allows us to build efficient data structures with value semantics, such as Swift's built-in
Arraytype. Today, I'm going to reimplement the core functionality of
Friday Q&A 2015-02-20: Let's Build @synchronized at 2015-02-20 14:26
Continuing the theme of thread safety from the previous article, today I'm going to explore an implementation of Objective-C's
@synchronizedfacility in the latest edition of Let's Build. I'm going to build it in Swift, although an equivalent Objective-C version would be much the same.
Friday Q&A 2015-02-06: Locks, Thread Safety, and Swift at 2015-02-06 14:23
An interesting aspect of Swift is that there's nothing in the language related to threading, and more specifically to mutexes/locks. Even Objective-C has
@synchronizedand atomic properties. Fortunately, most of the power is in the platform APIs which are easily used from Swift. Today I'm going to explore the use of those APIs and the transition from Objective-C, a topic suggested by Cameron Pulsford.
Friday Q&A 2015-01-23: Let's Build Swift Notifications at 2015-01-23 14:52
NSNotificationCenteris a useful API that's pervasive in Apple's frameworks, and often sees a lot of use within our own code. I previously explored building
NSNotificationCenterin Objective-C. Today, I want to build it in Swift, but not just another reimplementation of the same idea. Instead, I'm going to take the API and make it faster, better, stronger, and take advantage of all the nice stuff Swift has to offer us.
Friday Q&A 2014-08-15: Swift Name Mangling at 2014-08-15 14:20
It's been a long time since I wrote a Friday Q&A, but I'm back, with a brand-new post about a brand-new topic: Swift. Over the last few posts, Mike's gone into some detail about what Swift's internal structures looked like, but he's only touched very lightly on what the linker sees when it looks at Swift-containing binaries: mangled symbol names.
Friday Q&A 2014-08-01: Exploring Swift Memory Layout, Part II at 2014-08-01 14:22
Continuing the theme from the previous article, I'm going to continue exploring implementation details of Swift's memory layout. Today, I'm going to look at the memory layout of generics, optionals, and protocol objects.
Friday Q&A 2014-07-18: Exploring Swift Memory Layout at 2014-07-18 13:57
Welcome back to another exploration of Swift. Today I'm going to dig into some implementation details and explore how Swift lays out objects and classes in memory.
Friday Q&A 2014-07-04: Secrets of Swift's Speed at 2014-07-04 13:40
Friday Q&A 2014-06-20: Interesting Swift Features at 2014-06-20 13:17
Roughly six hundred million people have asked me to write something about Swift. I'm hoping to write a series of articles about various aspects of it. For today, I want to start things off by exploring a few Swift features that are interesting and unusual from the perspective of Objective-C, and why I think they're going to be good to have.