Skip to main content

Posts

Showing posts from November, 2015

iPad Pro: Resurrecting the single-device multiplayer game

Back in the mists of time when the first iPad was released there quickly followed a range of games with multiplayer modes for 2-4 players. Some used the sides of the screen, some the corners, and others split the screen in two. The size of the iPad Pro, which is closer to the size of a gaming board than any other iPad thus far, started me thinking about whether all those old games would still run in iOS 9.1 on the Pro, and what they'd be like. It turns out that the games I remember playing back on the iPad 1 (with a single exception) still run and are well suited to the larger iPad with far less finger clashing (and lag) than before. Multiponk by Fingerlab (£2.29/$2.99) This first game took me a while to track down because I couldn't remember the title but sifting through the bottom of my purchased list (for the oldest apps I own) I located Multiponk, a 1-4 player game deflecting ball bearings to stop them getting past your bat. It's a must play for those seeking a

Bytes for Beginners: Representation of negative numbers in binary using Swift (two's complement)

When I initially wrote the bytes for beginners series of posts I never got around to discussing the representation of negative numbers in binary or how we might use Swift to understand this. So let's begin now with bit casting, which is the act of transforming a bit of one type into something of another type. Here's an example, we have a UInt8 (an unsigned 8-bit integer), which can store any number from 0 to 255 and we want to cast it to an Int8 (a signed 8-bit integer), which holds a number from -128 to 127. unsafeBitCast(UInt8(128), Int8.self) // -128 unsafeBitCast(UInt8(255), Int8.self) // -1 What is happening here is easiest explained by Dr. Math : The numbers 0 to 127 are positive; numbers 128 to 255 represent -128 to -1. So if we think of this in binary terms String(128, radix:2) // 10000000 String(255, radix:2) // 11111111 then 10000000 in what is known as a  two's complement representation (or Int8's language) is -128, where in the language of UInt

Random numbers in Swift: wherefore art thou arc4random_uniform (Xcode 7.1.1, iOS; update with info on SecRandomCopyBytes; update Xcode 8 beta 6, Swift 3)

** Jump to Swift 3 code ** Two years ago the case was closed, NSHipster in his wisdom told us to use arc4random_uniform for random numbers but then Apple go and remove it from the Darwin.C.stdlib header file in Xcode 7. While it still works, this makes it feel kind of dirty to use it. Has it been removed for a reason? Or is it simply waiting to be put back once bugs are ironed out? The issue has been identified on Apple's forums but no definitive response appears. (Thanks to  @mofodox for drawing my attention to its absence and prompting this investigation.) This prompted me to look around at the other available random functions in the stdlib, and here's some code that I started throwing together. srand(1) // seed the starting point rand()%100 // restrict the upper value lrand48() mrand48() random()%100 random()%100 + 1 // set upper and lower values var ccc = UInt16(10) seed48(&ccc) // seeding a 48 function lrand48() mrand48() For an explanation I turned to IBM

Creative Cloud Workarounds: Failure to recognise installed apps or reinstall from Creative Cloud app

I've been using Creative Cloud since it was first released and it's not always (well, in truth, never really) been a perfect relationship. In the early days there were the syncing bugs that made it impossible to utilise the free cloud storage (which at one point was whisked away for a few months, if I remember correctly), then there was the bug that forced me to reformat an iMac because the Adobe Crash Daemon was eating all the hard-drive space. Now I have a MacBook where the Creative Cloud app refuses to acknowledge the existence of the installed Adobe apps, and any attempt to remove and reinstall results in the install stalling around 42%. This has left me with two options, a fresh formatting of yet another hard-drive or AirDropping apps from a desktop iMac to the MacBook. I've chosen to AirDrop for now, which has until my latest attempt worked perfectly with simply dragging the AirDropped app folders into Applications. There was just one glitch this time (which was ca