Code-free
Code-free

Swift: Should We Make Optionals Clearer?

Who wants to live without extensions

Russ Bishop
July 23, 2014

Optionals are great, but there are some improvements that might make code clearer and more explicit. I also want to acknowledge that in some cases you don't actually care if the value is nil or not, you just want to provide an alternate value if it is; that's usually called the null coalescing operator, but Swift doesn't currently . . .

Read More

Swift: Pointer Arithmetic

Abandon all hope of safety

Russ Bishop
July 22, 2014

Update: I originally did not make it clear but if Swift knows the type of the unsafe pointer then arithmetic will operate on sizeof(T) not on bytes! The same goes for alloc. So my example below with an UnsafePointer<Float32> will jump forward 25 * sizeof(Float32) bytes.

I've seen a lot of people wondering how to do raw . . .

Read More

Swift: Notable Beta 4 Changes

Prayers answered, denied

Russ Bishop
July 21, 2014

Here are some of the more notable Swift changes as of Beta 4:

Access Control

The new access control keywords are available:

modifier
private can only be accessed from the source file where defined
internal can only be accessed from the current target where . . .

Read More

Swift: Let's Query DNS

Interop in the real world

Russ Bishop
July 19, 2014

So far we've been going over some of the interop capabilities in Swift, but today I want to switch gears a bit and actually put this stuff to use. Along the way we'll discover some annoyances and take opportunities not available in Objective-C to remedy them.

Let's say we want to determine if a host is reachable. To do . . .

Read More

Swift: Implicit Pointers

The easy way

Russ Bishop
July 14, 2014

Today, let's look at Swift's implicit pointer support which can simplify our code quite a bit and works great when the callee doesn't keep the pointer alive or when it understands Objective-C and can handle retain/release/autorelease semantics. For some of the readers this will be extremely simple stuff, but I want to cover it for . . .

Read More

Xcode Exception Breakpoints

make the computer do the work

Russ Bishop
July 12, 2014

Improve your Xcode debugging experience with these 5 simple tips! Oh wait, I'm not selling a hocus-pocus miracle cure for cancer. [1] ahem

Many people are not aware of Xcode's powerful features for managing breakpoints during debugging. One such feature is the Exception breakpoint. Go to the Breakpoint navigator pane, click + . . .

Read More

Swift: Interop in Beta 3

Compilers are Toddlers

Russ Bishop
July 12, 2014

Compilers are toddlers. You can't reason with them, you can't plead with them. They do not understand human emotions (yet) and live only in the moment. Any obstacle or failure, no matter how minor, is a complete disaster. When they expect something you fail to deliver, they complain loudly and often in front of others, creating much . . .

Read More

Archive
   Subscribe by email and never miss a post.