- New Antibiotics Research Direction — most people don’t know that we can’t cultivate and isolate most of the microbes we know about.
- Swift now Open Source — Apache v2-licensed. An Apple exec is talking about it and its roadmap.
- Deep Forger User Guide — clever Twitter bot converting your photos into paintings in the style of famous artists, using deep learning tech.
- Prudent Engineering Practice for Cryptographic Protocols (PDF) — paper from the ’90s that is still useful today. Those principles are good for API design too. (via Adrian Colyer)
"swift" entries
Four short links: 4 December 2015
Bacterial Research, Open Source Swift, Deep Forger, and Prudent Crypto Engineering
Parallax scrolling for iOS with Swift and Sprite Kit
Learn how to add this popular visual effect to your iOS project.
Up until the mid 1990s, the pinnacle of video game graphics was parallax scrolling: the use of multiple scrolling backgrounds, which created a sense of depth and perspective in the game. When you’re being a 2D game in Sprite Kit, you can create this effect by creating multiple sprites, and managing their position over time.
In this example, we’re creating a scene where there are four components, listed in order of proximity:
- A dirt path
- Some nearby hills
- Some further distant hills
- The sky
You can see the final scene below:
Translating your Objective-C project to Swift
A step-by-step approach to using Swift with Objective-C.
If you’ve got an existing app written in Objective-C, migrating it into Swift is an excellent exercise for learning Swift, experimenting with Swift, and deciding whether to adopt Swift on a full-time basis. I’ve performed this migration with several real apps, so here are some tips culled from my actual experience.
Hybrid targets
You’re surely not going to translate all your code into Swift at once; you’re much more likely to translate one class at a time. As soon as you add a Swift file to your Objective-C app target, you’ve got a hybrid target: some classes are written in Swift, while other other classes are written in Objective-C. Thus, declarations in each language will need to be visible to the other language. Before you start, it’s a good idea to understand how this visibility works.
Recall that an Objective-C class declaration is conventionally spread over two files: a header file (.h) containing the @interface
section, and a code file (.m) containing the @implementation
section. If a .m file needs to know about a class, it imports the corresponding .h file.
Visibility of Swift and Objective-C to one another depends upon this convention: it works through .h files. There are two directions of visibility, and they must be considered separately.
Multipeer Connectivity on iOS 8 with Swift
Discover, connect, and transmit data between devices.
Multipeer Connectivity is a means of identifying and connecting services together, and allows for very easy passing back and forth of data with minimal setup. If you are thinking that this seems similar to Bonjour, you are correct; however, Bonjour is for service discovery, not connection or transmission. Multipeer Connectivity handles everything in one neat package.
Multipeer Connectivity is comprised of a few different components, but it works by having applications advertise their services asking if anyone is available to connect. The service browser listens for these advertisements and can request to create a connection between the devices. If the connection is accepted, a session is created with every one inside the session being represented by a peer object.
To demonstrate how this works, we’ll make a simple chat application using Swift, Apple’s new language.
New Swift language shows Apple history
Still reflects conventions going back to original adoption of Objective-C
Like many Apple programmers (and new programmers who are curious about iOS), I treated Apple’s Swift language as a breath of fresh air. I welcomed when Vandad Nahavandipoor updated his persistently popular iOS Programming Cookbook to cover Swift exclusively. But I soon realized that the LLVM compiler and iOS runtime have persistent attributes of their own that have not gone away when programmers adopt Swift. This post tries to alert new iOS programmers to the idiosyncrasies of the runtime that they still need to learn.
Four short links: 9 September 2014
Go Text, Science Consensus, Broadcast Fallacy, and In-Browser Swift
- bleve — A modern text indexing library for go.
- Scientific Consensus Has A Bad Reputation—And Doesn’t Deserve It (Ars Technica) — a lovely explanation of how informal consensus works in science. NB for anyone building social software which attempts to formalise and automate consensus.
- TiVo Mega — 24TB of RAID storage, six tuners for capturing broadcasts. Which is rather like building the International Space Station and then hitching it to six horses for launch. Who at this point would make a $5k bet that everything you want to see on a TV will be broadcast by a cable company?
- runswift — an in-browser client for compiling and running basic Swift functionality.
Four short links: 4 June 2014
Swift on GitHub, HTTP APIs, PGP in Gmail, and Comments vs Community
- Swift on GitHub — watch a thousand projects launch.
- HTTP API Design Guide — extracted from work on the Heroku Platform API.
- End-to-End PGP in Gmail — Google releases an open source Chrome extension to enable end-to-end OpenPGP on top of gmail. This is a good thing. As noted FSF developer Ben Franklin wrote: Those who would give up awkward key signing parties to purchase temporary convenience deserve neither.
- Close Your Comments; Build Your Community (Annemarie Dooling) — I am rarely sad when a commenting platform collapses, because it usually means the community dissolved long before.