iOS Simple Keychain Storage with ARC

iOS Simple Keychain Storage

I’m frantically busy lately coding for iOS. Security is always an interesting aspect to handle. You’d expect Apple to make these things easy, but using Keychain seems to be a bit headache inducing, making the ordeal mysterious and scary.

There’s a great tutorial available on Brad’s Beef that demonstrates simple password management using a Keychain wrapper (SFHFKeychainUtils by landerson). This keychain wrapper however is not ARC compliant, and brings with it a mess of compiler errors.

Luckily there’s some clever developers that are nice enough to share their ARC compliant code on StackOverflow. You can find the header and implementation files here on this StackOverflow thread.

For easy access, I’ve made a copy of the files available here for download:

To add an item to the Keychain:

Adding to Keychain

To remove an item from the Keychain:

Removing from Keychain

After adding the files to your project, make sure you include the Security Framework in your project too. From there on, you can follow Brad Beef’s tutorial using ARC.

Posted in ARC, Keychain, iOS | Leave a comment

Logo design for IVCNZ 2012

I was asked to design a logo for the 27th International Conference on Image & Vision Computing New Zealand. IVCNZ is New Zealand’s premier academic conference on all aspects of Computer Vision, Image Processing, Visualisation, and Computer Graphics. You can read more about the conference on the IVCNZ 2012 Conference Website.

IVCNZ logo transparent

They were looking for a logo that encapsulated the conference focus, as well as a design that could work on t-shirts. I made 2 alternative versions that work on black, white or blue t-shirts.

IVCNZ logo on black
On black

IVCNZ logo on white
On White

The logo consists of a bionic eye (Vision), with the iris resembling a camera shutter (Image), surrounded by a cog (Computing). The cog represents mechanism to relate aspects of robotics. It could also be interpreted as mechanical eyelashes, which ties in with the bionic eye. It also resembles the letter C for computing or conference.

I made a few scribbles on paper, then assembled the logo using Blender. Here’s an exploded view of the logo:

IVCNZ logo in Blender

I look forward to seeing my design on the conference t-shirts. :)

Posted in 2D Art, 3D Art, Blender | Leave a comment

Writing files to Windows NTFS with Mac OS X Lion

If you’re new to Mac OS X, or if you recently installed Windows 7 with Bootcamp and Mac OS X Lion, you will find that Mac OS X does not support writing your files to NTFS formatted hard drives. This becomes particularly impractical if you have Windows 7 installed and wish to transfer files to your Windows partition.

With the following easy three steps, you will have seamless NTFS writing support:

MacFuse
1. Download and Install MacFuse

MacFuse allows you to extend your current Mac OS file system with 3rd party file systems.

NTFS-3G
2. Download and Install NTFS-3G

NTFS-3G is a 3rd party file system that gives NTFS writing support. It requires MacFuse.

NTFS-3G Fix
3. Install NTFS-3G fix

If you are running Mac OS X Snow Leopard, then this fix is not required for you. However, NTFS-3G causes ‘timeout errors’ on Mac OS X Lion. This patch fixes these timeout errors.

All you need to do now is restart your computer, and you have full NTFS writing support on your Mac. This includes partitions, external hard drives and flash devices that are formatted to NTFS.

NOTE: This solution may not work on Mac OS X Mountain Lion. Paragon NTFS and Tuxera NTFS provide paid solutions with Mountain Lion support.

Source: MacInformers

Posted in Boot Camp, Lion, Mac OS X, NTFS, Snow Leopard, Windows 7 | 3 Comments

Mac Eject – Device Eject for Mac

I find ejecting removable media on Mac such a distraction – open a Finder window and scrolling down, or minimizing everything and dragging to the Trash. There must be an easier way.

I had a look around the App Store and found a few apps of interest, but none really offered me all the features I was looking for. So I coded an app together that does just that.

MacEject

MacEject is a light-weight app that lives in the status bar. You can use it to quickly eject removable media such as USB drives, SD cards, external hard drives, DVDs and more. You can also eject all removable media devices with one click, and even force-eject stubborn devices.

MacEject Menu

If a device can’t eject because Finder claims it’s in use, it will highlight and let you know.

MacEject Warning

If you’re sure nothing should be using a device, you can use ‘force-eject’ to remove any media that won’t eject. Be warned that this could potentially damage files that are currently being written to on the device.

This app is free for download, and will hopefully be out on the App Store in the future. It’s been tested for Mac OS X 10.7 Lion, but should run on Mac OS X 10.4 and newer. If you have any problems or feedback, please leave a comment below :)

UPDATES

Version 1.1 – Jun 28 2012

  • Added support for external hard drives and Time Machine drives.

MacEject Icon 32  Download (v1.1, 460KB, zip archive)

Posted in App Icon, Cocoa, Free App, Lion, Mac OS X, XCode | Tagged | 5 Comments

Prometheus

Prometheus - David and the Star Map

Prometheus is a 2012 sci-fi action horror film by Ridley Scott. The story follows the crew of the Prometheus, on a mission to discover the origins of mankind on a distant star with ancient civilisations. Themes explored in the film include questions regarding origin and existence, the meaning of life and survival instinct. The film contains a fantastical overload of visual effects and intense atmosphere. The artwork was inspired by H. R. Giger’s work (also used in the Alien saga films) and is accompanied by the chilling soundtrack of Marc Streitenfeld.

Prometheus was Scott’s first 3D film and contains approximately 1,300 digital effect shots. The shots were produced by multiple studios; Moving Picture Company was the lead visual effect studio with 420 shots and remaining effects were relayed amongst New Zealand’s Weta Digital, Fuel VFX, Rising Sun Pictures and others.

I’ve compiled a list of stills and concept art images that illustrate some of the thought processes involved in the making of this film. Scientists including NASA experts and artists across a range of disciplines contributed to realising this amazing world in the late 21st century. If you haven’t yet seen this thought-provoking visual spectacle, I highly recommend viewing it :) I haven’t had the pleasure of seeing it in 3D yet, though I’m sure it will only add to its magnificence! Note: be sure to see the film before viewing the art below to avoid spoilers!

Prometheus - Head

Prometheus - Engineer Juggernaut

Prometheus - Prometheus Spaceship

Prometheus - Group

Prometheus - Ship

Prometheus - Juggernaut

Prometheus - Buggy

Prometheus - Bike

Prometheus - Controls

Prometheus - ATV

Prometheus - Sandstorm

Prometheus - Xenomorph

Prometheus - New Alien Parasite

Prometheus - Ship Concept

Prometheus - Engineer Temple

Prometheus - Make Up

Prometheus - Alien Helmet

Prometheus - Alien Concept

Prometheus - Engineer Pilot Room

Prometheus - Hanging Alien

Prometheus - Alien Birth

Prometheus - Xenomorph Born

Prometheus - Temple

Prometheus - Landing

Prometheus - Jockey

Prometheus - Ascend

Prometheus - Landscape

Sources:

Review and stills: damngoodcup.com
Stills: Prometheus Movie on Photobucket
More stills: Prometheus Movie (media directory)
Scans from the official Art Book: Prometheus France
Technical Information: Wikipedia – Prometheus (Film)
Videos: prometheus-movie.com

Posted in 2D Art, 3D Art | Tagged | 5 Comments

Apples and Oranges: An Infographic

People love infographics. Particularly, we love boring data presented in interesting flavours to make it more digestable. Jess Bachman and the team at Smarter.org have done just that, to prove that you can indeed compare apples and oranges. Backed by meticulous research and the magic of science, of course.

Apples to Oranges.

Infographic by Smarter.org

Posted in Infographics, Inspiration | Leave a comment

Eat Your Greens.

Eat Your Greens.

Remember kids, eat your greens.
Occasionally I need some creative outlet, and I usually build something in 3D. I’m a bit strapped for free time, so I made this using The Gimp, an open source alternative to Photoshop. I wanted to focus on incorporating unusual elements to create a convincing creature. I also wanted to give it a more professional or polished look. The result is a ‘motivational’ poster for kids to eat their vegetables.
I don’t really have a section in my website for 2D art, so I’ll post it here for now. Once I get around to building a new website, I’ll find a home for it all :)

Posted in 2D Art, Inspiration | Leave a comment

Bringing App Icons into XCode

Making an app icon is such a simple yet critical aspect of the app design process. A well-designed app icon makes a good first impression; a badly designed app icon is an eye-sore on your desktop. As I’m putting the finishing touches on my app, I decided to put the app icon in place.

Solid Noise Synthesizer App Icon

My app has a wooden control board theme (procedural noise can be used to make wood textures), so I decided to incorporate this into the icon. I also added the ribbon that graces each view and wrapped it around ‘photos’ of noise; the app is great for making textures and videos of noise. The result is a neat icon that represents the look and feel of the app well. You can read more about Solid Noise Synthesizer in my Software Developer Portfolio.

Making an app icon is the first step. The next step is getting it working in your XCode project. Luckily this is a cinch.

Icon Composer

Hidden in the Developer > Applications > Utilities folder, you’ll find Icon Composer. This simple drag-and-drop app allows you to create a multi-resolution icon file for your app. Simply drag your icon to the resolution slots – you can provide icon varieties to suit various resolutions. Save the icon file in a convenient place – you now have an Apple Icon Image (.ICNS) of your app icon.

To set the icon for your app, open your XCode project and go to the project settings. Under TARGETS, click on your app name. Under the summary tab, you will find your Mac OS X Application Target information.

XCode Targets App Icon

Right-click on the app icon space and choose “Select File”. Locate the saved icon image and XCode will take care of the rest. Run your app to test: you should now see your App Icon bouncing on the Dock!

You’ll find that you can tell XCode to take a simple image file – it will correctly display the image as an icon within the project, but will not register the image as an icon for your app when you run it. It is therefore important to convert your image file to an icon file to ensure your app can show its icon!

Posted in App Icon, Cocoa, Explaining noise, Icon Composer, Mac OS X, Noise for the Masses, Procedural noise, Solid noise, Solid noise synthesis, XCode | 1 Comment

Temporal Distortion

Photographer Randy Halverson created a spectacular time-lapse video of galaxies including our own Milky Way dancing across his native Dakota skies. You can find galleries as well as extended cuts at Dakotalapse.

“What you see is real, but you can’t see it this way with the naked eye. This is the result of thousands of 20-30 second exposures, edited together to produce a timelapse. This allows you to see the Milky Way, aurora and other phenomena, in a way you wouldn’t normally see them.”

Take a moment out of your busy day to marvel at the beauty of our universe. Harness the blessing that you exist in this amazing world, and realise how insignificant your obstacles really are. We are part of something truly astonishing and magnificent.

Dakotalapse

“In the visible world, the Milky Way is a tiny fragment; within this fragment, the solar system is an infinitesimal speck, and of this speck our planet is a microscopic dot. On this dot, tiny lumps of impure carbon and water, of complicated structure, with somewhat unusual physical and chemical properties, crawl about for a few years, until they are dissolved again into the elements of which they are compounded. They divide their time between labour designed to postpone the moment of dissolution for themselves and frantic struggles to hasten it for others of their kind.”

Bertrand Russell

Posted in Documentary, Inspiration | Leave a comment

Making an NSImage of an NSOpenGLView

OpenGL Teapot

I was working on a Mac OS X project that required extensive use of custom NSOpenGLViews subclasses. The views were used to display some OpenGL content and allowed the user to save the view as an image. A convenient way of going about this is creating an NSImage of the view, which can easily be saved to file later.

I restructured the program using Apple’s BasicCocoaAnimations sample code. When testing the integration, I noticed that my routine for creating an NSImage stopped working. Every time I tried saving the view, I’d end up with a completely transparent image. I initially thought it was related to glReadPixels, but I managed to narrow it down to a call in the MainWindowController:

[[[self window] contentView] setWantsLayer:YES];

- switching to a layer-backed configuration. Disabling it fixed the problem but ruined the interface. I had to find a solution.

I tried many approaches, including switching to a layer-backed NSOpenGLView (using CAOpenGLLayer and LayerBackedOpenGLView examples); I even wrote my own NSOpenGLView as a custom subclass of NSView. This seemed like far too much work to solve the problem, and coincidentally, none of the attempts were successful. I was confident that the problem was related to an inconsistent rendering context. Trawling forums, I noticed a few people remarking that it is a bug in Apple’s frameworks. It seemed like saving NSOpenGLViews in a layer-backed window using glReadPixels wasn’t meant to be.

It dawned on me that I needed a way of controlling the rendering context. After investigating NSOpenGLPixelBuffers (which are deprecated as of Mac OS X 10.7), I decided to pursue Framebuffer Objects. FBOs can be used to render into an offscreen context without the overhead of rendering to the screen. This is useful when frames need processing for image filters or effects. In our scenario, it is useful because we know exactly where our NSOpenGLView is rendering to. They are surprisingly easy to implement, and luckily offered a solution to my long-term problem.

Here is a code snippet from my program that will set up and draw to a Framebuffer Object, ensuring that we know exactly where the view is rendering to and glReadPixels is reading from. The end result is a correctly flipped NSImage. I hope this will be useful for your projects, and saves you the time that I spent searching for an answer!


- (NSImage*) image
{

NSRect bounds = [self bounds];
int height = bounds.size.height;
int width = bounds.size.width;

NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:width
pixelsHigh:height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:4 * width
bitsPerPixel:0
];

// This call is crucial, to ensure we are working with the correct context
[[self openGLContext] makeCurrentContext];

GLuint framebuffer, renderbuffer;
GLenum status;
// Set the width and height appropriately for your image
GLuint imageWidth = width, imageHeight = height;
//Set up a FBO with one renderbuffer attachment
glGenFramebuffersEXT(1, &framebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
glGenRenderbuffersEXT(1, &renderbuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, imageWidth, imageHeight);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, renderbuffer);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT){
// Handle errors
}
//Your code to draw content to the renderbuffer
[self drawRect:[self bounds]];
//Your code to use the contents
glReadPixels(0, 0, width, height,
GL_RGBA, GL_UNSIGNED_BYTE, [imageRep bitmapData]);

// Make the window the target
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
// Delete the renderbuffer attachment
glDeleteRenderbuffersEXT(1, &renderbuffer);

NSImage *image=[[[NSImage alloc] initWithSize:NSMakeSize(width,height)] autorelease];
[image addRepresentation:imageRep];
[image setFlipped:YES];
[image lockFocusOnRepresentation:imageRep]; // This will flip the rep.
[image unlockFocus];

return image;

}

Posted in Cocoa, Framebuffer Objects, Lion, Mac OS X, NSOpenGLView, OpenGL | 5 Comments