| Grand Central Station, Manhattan, New York, NY |
The musing and sometimes not so wise words of Jonathan Dalrymple, Global Traveller, Programmer, Financial Rocket Scientist, Conspiracy Theorist, Part-time comedian, full-time funny man and whatever else i randomly decide to do.
Friday, September 16, 2011
Friday, September 09, 2011
i took a picture [Rastaman edition]
Wednesday, September 07, 2011
Making UIImages with blocks
So i made it awesome, and as everyone knows to make your code awesome you add some blocks to it.
My problem was simple, i was faced with the need to create two CGBitmapContext, for the uniformed the following code is required to prepare a bitmap context for drawing.
So after a bit of thought, i decided what i really wanted was a method that did all of this for me, and meant that i didn't have to worry about constantly checking the code for leaks (DRY), and that was pleasant to look at and i came up with the above. The block that you pass in is given a fully formed CGBitmapContext, and the method returns a UIImage generated from that context. Almost like a UIView/CALayer.
So now your thinking, "Yeah, thats cool, but why the [INSERT FOUR LETTER WORD] would i want to use it ?" Well young grasshopper, have you ever wanted to mask a image in code? You know to do those trendy rounded corners ... well yes you can use CALayer's however the idea of using those off the main thread makes me uneasy, and we all know the cool kids do things in the background.
The above actually creates a rounded rect on the fly, and masks the image with it. It's made to be used in a category on UIImage. But look closer, yep thats right kids, no boiler plate, ZERO, NADA, 另, SQUAT (i think you get the point)!
I should take a moment to mention that the awesome code for the rounded rect comes from the awesome Oliver Drobnik, i have the utmost respect for this guy, not just for this snippet, but if you've ever seen his Rich text label and it's associated projects, you'll understand why real soon.
Friday, September 02, 2011
Friday, August 26, 2011
I took a picture [HOLLYWOOD edition]
Friday, August 19, 2011
I took a picture [中文 edition]
Friday, August 12, 2011
I took a picture [Apollo 11 Edition]
Friday, August 05, 2011
I took a picture [Israel Edition]
Tuesday, August 02, 2011
Waipo Valley Hike
However since i've been on the Big Island i've made an effort to try and relax, and actually have a vacation. Its not like i'll be having another one anytime soon. Being an iPhone developer and having loads of time off aren't compatible ideals.
So yesterday i started creaming myself on the prospect of visiting Waipo Valley, however it seemed so distance, and far from anywhere that it may as well have been on another planet. Initially i dismissed it, and decided instead to head for Akaka falls, a lovely 400ft waterfall only 20 minutes bus ride away.
However when my bus got to Akaka falls i didn't get off. It was a beautiful day, my camera was charged and my memory card was empty. I rode all the way to Waimea, in the north of the island, glimpsing the Towering Mount Kea, on the left and the steep coast to my right.
Though my consumption and research using the fantastic Offmaps i had learnt about a trail, just to the north of Waimea, that appeared to reach the valley. There is a more direct trek, that takes you to the head of the valley, however this is several Kilometers outside of town (READ not near the bus stop). So i decided to go a slightly different way, that allowed to me to go through town.
After walking though a residential neighbourhood to the north of the town. I found the entrance to the trail (above). Like all good hikers, i just ignored it and marched on.
And there it was, 2000ft straight down, almost 4 miles in the middle of nowhere. I was at photographic "pay dirt". After about 10 minutes of this beautiful vista, i high tailed it out of there, rain clouds where all around, and this is the last place you want to be when it rains, especially considering that i wanted to salvage what was left of my trainers.
Overall i learnt a couple of things about my hike.
- Never give up
- Carry more food & water
- Get hiking boots
- Hawaii (Especially the Big Island) is beautiful.
Monday, August 01, 2011
Hawaii: Oahu & Hawai'i (aka The Big Island)
Having flown into Oahu, i spent most of my time in Waikiki, Honolulu. As i was warned it was chock full of Japanese tourists showing off their Canon's and Nikons. I have nothing against my friends from the land of the Rising Sun, however i do suffer from a serious case of Lens envy.
After 6 days in the Japanese version of the Costa Del Sol, i've flown to Hilo, on the big island, aka Hawai'i. Today, i felt like an idiot for even spending more than two days in Oahu.
Firstly the big island, is well, BIG. The road that runs around the entire coast is almost 300 miles long. I spent today in the car with some good people from Holland, we barely explored a quarter of the island. This place is huge.
This is an example of the rainforest like terrain. It even has a canopy that the Brazil Rainforest would be jealous of. Really makes me look forward to the day i finally set foot on the continent of South America, Un dia, un dia.
Then there is the black volcanic rocks. While i know the landscape was formed by magma, it almost seems as if it's been scared by it. I've been fortunate enough to see some amazing things. But this is truly fascinating.
Saturday, July 30, 2011
Auto incrementing version numbers in Xcode
I don't think anyone actually enjoys editing a plists, whether its in Xcode plist editor or the down and dirty XML. So has a result it was the perfect opportunity to get familiar with xcode's build process, and how to tie external scripts into it.
I use 3 segment version numbers (1.1.1), where the first digit is the major version, second digit is the minor version, and the 3rd digit is the build. For the benefit of the team, i wanted to have the latest commit hash in the build number so that people could quickly reference it and know whats going on.
With some direction from this post by Duane Sibilly i was able to hack together the below.
Friday, July 29, 2011
I Took a Picture [Hong Kong Edition]
Friday, July 22, 2011
i Took Picture [LA Edition]
Wednesday, July 20, 2011
The Mighty Pacific
Friday, July 15, 2011
Sunday, July 10, 2011
This is what 16k miles looks like
Monday, July 04, 2011
The Golden Gate
This was some what of a rambling post, but i just wanted to share some of these awesome pictures.
Tuesday, May 24, 2011
Core Data & Multi-Threading, part 1337
So if you need to refer to an object on multiple threads you need to use it's NSManagedObjectID. Thats all well and good, but what if you need to call [NSManagedObjectContext save:] multiple times. Well in short it's gonna suck. Well thats cool you say, i can just use the id anyway ... Not quite. There are two types of ID's, permanent and temporary.
Now in my experience Core Data seems to get confused when you use temporary ID's to look up objects on another NSManagedObjectContext. So really to stop these conflicts we need to get a permanent id, but we need to obtain one of these ID's without saving the NSManagedObjectContext.
Well are you ready for the magic ... Shazam
[NSManagedObjectContext obtainPermanentIDsForObjects: error:]
This awesome method will take an array of managed objects, and give them permanent ID's. From my brief tests the overhead is minimal compared to the traditional save method.
Thats all i've got for today, keep on trucking.
[]'s 4 life
Monday, May 09, 2011
Asynchronous Core Data searches with Blocks
I was recently fortunate enough to be able to drop iOS 3 support on a project. This meant that i could start to play around fully with Blocks on iOS. One thing that has always got on my nerves is that there is no built in support for asynchronous Core Data searches.
Previously i tried to wrap up potentially long operations in a special FRCoreDataOperation a subclass of NSOperation. However this was a pain, as i would then have to subclass it or modify the parent class to provide me with a simple callback when the task was complete.
What i really longed for was the way in which you make Ajax requests in jQuery, that of course requires closures, which are of course provided in the form of Blocks. So after hacking around for a bit i came up with this.
Now this is my first real time using blocks outside of simple things like iteration etc. It means that i can do
Now here's the part where i pat myself on the back. The callbacks are executed on the main thread, after the async fetch request is completed. Plus it gets better, The NSArray, for the onComplete block contains a list of the returned objects that are registered with the NSManagedObjectContext for the main thread, or in other words the NSManagedObjectContext you used to perform the fetch.
Once i touch down in the valley i plan to extend this to manage saves as well, making the basic CRUD operations with Core Data "scroll like butter".




