Code-free
Code-free

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 +, then . . .

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

Swift: Pointers everywhere

Unsafety? More like FUnsafety

Russ Bishop
June 27, 2014

Edit: Updated with new information to clarify that UnsafePointer<T> expects the number of instances of T, not the size in bytes.

Today let's discuss UnsafePointer<T>. Perhaps you want to use a fancy function like OSAtomicIncrement32 to keep a running counter across threads and GCD queues, without any locking, blocking, or race . . .

Read More

Swift: withUnsafePointerToElements

There is no escape, only vectors

Russ Bishop
June 26, 2014

Swift Array<T> is easily convertible to a C-style array, but much like the world of Garbage Collection, we have to be aware of object lifetimes.

A Swift Array is just a small stack-allocated header struct that points at heap-allocated memory to hold the elements. When you mutate an array, that header struct may change. If the array is . . .

Read More

Swift: Manual retain/release

Old school

Russ Bishop
June 26, 2014

While creating ThreadLocalSlot<T>, I needed to call the posix posix_getspecific and posix_setspecific methods. Not only that, I needed to store an Objective-C object in a plain old void*. How can we accomplish that in Swift?

The key is Unmanaged. It contains magic sauce to let us turn an AnyObject into a COpaquePointer, which is . . .

Read More

Swift: Making Tuples Equatable

Lots of copypasta

Russ Bishop
June 23, 2014

Until we get a first-class macro system, this involves a lot of copypasta, but it does work:

@infix func == <T:Equatable> (lhs: (T), rhs: (T)) -> Bool { return lhs.0 == rhs.0 } @infix func == <T:Equatable, T2:Equatable> (lhs: (T,T2), rhs: (T,T2)) -> Bool { return lhs.0 == rhs.0 && lhs.1 == rhs.1 } @infix func == < . . .

Read More

Bigger iPhone and side-by-side iPad apps

Apple screams loudly, no one pays attention

Russ Bishop
June 23, 2014

Apple is telling us without telling us to get ready ASAP: Bigger iPhone screens and/or iPad side-by-side applications are coming and you should get ready.

The new size class mechanism and the resizable simulator are practically screaming at us to get with it.

My suggestion is to get comfortable with Auto Layout and make your views . . .

Read More

Archive
  Subscribe by Email and Never Miss a Post