I was experimenting with methods of debug logging in Swift and came across an interesting find. If you use the __FILE__ , __FUNCTION__ , __LINE__ and __COLUMN__ “macros” as default function parameter values in Swift the value is set to the file, function etc of the caller rather than the details of the called functions location. This means you can automatically pass information about a…
I like to use CodeRunner to test out quick snippets of code. I have added Swift as a supported language. I did this by adapting the Objective-C compile.sh script that is used by CodeRunner to compile Objective-C with clang . Hopefully the next release of CodeRunner will support Swift out of the box with a better compiler script and syntax highlighting. In the CodeRunner Preferences add a new…
With the release of Mavericks, Apple have brought the capabilities of Core Bluetooth in line with those of iOS. In particular Mavericks can now function as a peripheral thanks to the inclusion of the CBPeripheralManager class. However, Apple have chosen not to include support for iBeacons in Mavericks. iBeacon support on iOS 7 has been implemented as part of the Core Location framework but Core…
Update 13th April 2013: This now works on Mountain Lion (10.8.3). Thanks to a tip, I have now worked around the problem of write-protected memory pages. See the GitHub repository for the working code. Note: From the title of this post you will see that I ultimately failed to get the pt_deny_attach kernel module to work in Mountain Lion. This was due to write protected memory in the kernel.…
For a while I have been using a Bash Terminal Prompt which is normally green but turns red if the last process failed. I have just discovered a prompt which includes the current git branch and I have updated my prompt to include both of these functions. My terminal prompt now looks like the following screen capture (I’m currently using the Solarized Light theme): You can add the following…
Several new features were added to the Apple LLVM Compiler 4.0 to allow the use of Objective-C Literals and object subscripts. This means that it is now possible to use the following shorthands to create and access elements of an NSArray . Objective-C Literal and Subscripting Syntax 1 2 3 NSArray * array = @ [ @"World" , @"Hello" ]; NSLog ( @"%@ %@" , array [ 1 ], array [ 0 ]); During compilation…
I’m sure you’ve always wanted to be able to create a UITableView with the following code: UITableView initWithFrame: style: 1 2 UITableView * tableView = [[ UITableView alloc ] initWithFrame: frame style: UITableViewStyleGangnam ]; UITableViewStyleGangnam I was inspired to write the following after my trip to /dev/world last month. Gangnam Style was one of the memes during the…
I recently gave a presentation at the AUC’s /dev/world conference. The video recording of my presentation, Adventures in the Objective-C Runtime , is now available on the AUC website at http://auc.edu.au/2012/08/objective-c-runtime/ . I have included the presentation abstract below: Adventures in the Objective-C Runtime The Objective-C language is dynamic, many decisions are deferred from…