iPhone 6 and 6 Plus side by side Paper Comparison

So on September 9th (as of time of writing thats last night) Apple announced (among other things) the new iPhone 6 and iPhone 6 Plus… Both are which are larger than the any predecessor. I won’t go into details of what each phone does / has… as i’m sure you can find that information anywhere on the Internet :). The biggest question on everyones minds is….

Which should I buy?

So, I was curious about the sizing of the new devices, therefor I made a really quick and dirty paper prototype with the precise dimensions. What it shows… the 6 Plus is a beast, larger, but somewhat smaller than a Samsung Galaxy Note II, but probably a commuters powerhouse, a halfway house between the traditional sized iPhone and iPad. Whereas the iPhone 6 is a welcomed and comfortable size increase on the iPhone 5/5S/5C generation.

Samsung devices in the Apple Spaces

Now next to the original devices

IMG_1330 iPhone sizing

 

Despite the iPhone 6 Plus being ginormous… I think thats the one i’ll be getting… Having to commute 1 hour a day on a train and being an overall geek… it suits me well 🙂

For more info on the specs and sizing of the new iPhones I suggest visiting the apple specs webpage.

 

Mockacino a lightweight ruby/sinatra API Mocking script

Hi Guys, so i’ve been working on a new app recently for a client of mine, currently there is no API… so in the meantime I decided to knock up a quick few lines of ruby to get a mocking api up and running… to explain this better, I need not do more than paste my README.md here.. Enjoy 🙂

Mockacino

A very simple and easy to use MOCK API server that serves static JSON written in ruby/sinatra.


NOTE: This is a super simple, super fragile MOCKING SERVER Intended so you can test routes and mock an API with static jso whilst you’re still building the real production API. DO NOT EVER use this in production… Seriously. It breaks a lot and will if you try… DONT. Absolutely 0 effort went into it, therefor 0 Warranty. Use if you dare.

DOCS:

Folder structure defines API calls…. return.json is what gets served.

site_root ->;
    [ http method ] ->; [ api call route ] ->; [ json response contents of call return.json ] 

e.g.

site_root ->;
    GET ->; users ->; return.json
    POST ->; users ->; create ->; return.json

If you have static assets you wanna reference in the json, plonk them in the ASSETS folder

e.g.

site_root ->; file.jpg

You can call http://yourhost:port/ASSETS/file.jpg

Here’s the directory structure of the sample project included here

mockacino.rb  
./site_root/ASSETS
./site_root/GET
./site_root/POST
./site_root/GET/sheep
./site_root/GET/sheep/create
./site_root/GET/sheep/return.json
./site_root/GET/sheep/create/return.json

Which supports calls like…

http://localhost:4567/sheep
http://localhost:4567/sheep/create

And gives responses from the static result.json file like…

{
    "sheep": [
        {
            "id": "1234",
            "name": "Dolly Two",
            "url": "http://mike.kz/sheep1234",
            "assets": {
                "small_image": "http://cloned.sheep.com/ASSETS/small.jpg",
                "large_image": "http://cloned.sheep.com/ASSETS/large.jpg"
            }
        }
    ]
}

Usage:

gem install sinatra
ruby mockacino.rb
 

Brisk a simple lightweight Networking Framework written in Swift


This is gonna be a short and sweet blog post… I’ve been working on a little pet project to practise and learn some Swift, so I thought, what do I use the most in projects these days… its networking. I’ve published on github.com my first attempt Brisk, its no where near complete and only has basic functionality right now, but if it becomes interesting i’ll pick up the effort and add more, until then, its a great educational exercise, you can check it out here and be sure to contribute back 🙂 it should work on both OS X and iOS and is MIT Licensed.

 

Swift the new Language for writing Cocoa and Cocoa Touch Apps

swift programming language

Introducing Swift

I’ve been at WWDC 2014 all week and one of the major announcements from Apple was a new programming language they’ve been working on named “Swift”, immediately it flashed me back to a really old WWDC where they announced an experimental language they were playing with named “Dylan” but I could be wrong.

Swift attempts to deliver a fast modernised language that looks and behaves as an interpreted language such as Ruby or Python but has all the power of a compiled language such as C++/Objective-C. From what i’ve seen on the interweb and twitter, there seems to have been a mixed reception from developers, but overall its looking more positive than not… My stance is… i’m gonna read more than 60 pages and wait more than 48 hours before declaring either my love or hate for Swift :)… If you’ve seen the blogosphere lately, you’ll understand what I mean.

Apple have released a publicly available (so i’m guessing not under NDA) Swift book on the iBook Store thats lengthy, doesn’t assume you’re an 8 year old and gives a decent overview of the Swift programming language, in what seems is from a “answer all of your questions and thoughts” approach, with some examples and exercises along the way.

I’ve attended the Swift labs almost everyday this week armed with questions, thoughts, suggestions and generally the engineers have been great at responding to everything. As a result i’ve filed radars, been convinced i’m not crazy and had some insight into the future of the language.

My main bone of contentions so far are:

  • No sensible/pretty way to selectively expose method A vs method B.
  • The threading model is still a little undefined and incomplete.
  • Autocomplete and LLDB seem to still be a very much work in progress.
  • Downcasting syntax is overly verbose.
  • Did I do it wrong? or did Xcode just shit itself?

However having said that, Swift was released early to us the developers, in order to get feedback/suggestions and help Apple build it to how we want… lets not forget, i’ve had (at the time of writing) 96 hours experience in Swift and its only been public for around the same amount of time… so a lot is likely to change.

What I like so far:

  • Generally a nicer more modern syntax
  • Less “falling back” to C for common things
  • Less unnecessary verbosity *(most the time)
  • Pretty seamless “bridging”/”interoperability” (or whatever the term should be) to existing Objective-C code
  • Namespacing, Modules & Frameworks
  • Explicit typing support with some intelligence from the compiler too
  • An emphasis on “tell the compiler as much as possible”

As soon as I figure out whether or not we’re allowed to talk about more, i’ll go into more detail on some of these points and post some sample code. I’m currently working on an iOS Framework written in pure swift that I’m sure people will enjoy, i’ll be posting it on GitHub in the near future here it is now, but its probably far away from prime time and perhaps a little useless 🙂 but a great way to learn Swift!

As always, thoughts and criticisms should be constructive and not defamatory and furthermore, have your own opinion, no one you follow on twitter is an expert on this yet 🙂 so don’t be afraid to voice your opinions and join in the healthy discussion.

If you wanna chat about it more, i’m @ArmstrongAtWork on twitter.

 

 

 

Objective-C iOS Code Style Guidelines (Part #1)

I move around on different projects a lot and work with different developers every few months. One thing I’ve noticed is people picking up bad habits from blogs and Stack Overflow posts that get very popular despite their quality (this is not a blanket statement of course)… On the other hand however, I’m able to share experiences with other developers and pickup some good tips in the process. One bone picking point is always what convention to use, when, where and most importantly… Why!

Something i’ve been asked for a few times recently and something I continually tweak as my own preferences and style changes is my Objective-C iOS Code Style Guideline doc. I thought i’d share it here for everyone to use, love and consume. All I ask is that you don’t steal it as your own and that you perform any discussion on twitter using #mike.kz or message me @italoarmstrong 🙂

These guidelines of course are my own personal preferences, which have developed over many years and will continue to change, even as writing this point, I changed my mind on a few points in the below guide. So take inspiration from it, rather than thinking “this is correct way of doing it” as its not. Thats usually the point in a “guideline”.

… 

 

Instantly gain insight on someone else’s iOS App Architecture with MADebugTools

Just a quick post to say i’ve posted my first piece of code in over 5 years to GitHub. Its a clever little Objective-C iOS Category on UIViewController that seemlessly overlays a UILabel on every single view controller managed view with the class, nib or storyboard name that is used. Great for debugging old or inherited projects with minefield architectures. It uses some cool libobjc runtime techniques to accomplish this, but implementing the category is a case of dropping it into your project and Build+Go!

Category in Action

Grab the source code here as usual, follow me @italoarmstrong on twitter 🙂

 

 

The __block specifier in Objective-C and Why its so mis-understood

I’ve seen a lot of source code recently where people are mis-using the __block “specifier” that ships with modern Objective-C runtimes. I’ve always had the opinion that if you are to use __block for an Object then you should design around it and avoid, reserving its use for primitives. Regardless of that, here is a summary of my understanding of __block to share with any other keen readers who may be interested.

__block is used as variables outside the scope of a block become readonly once inside a block. For example

 int num=1;
void (^someBlock)(void) = ^{
num = 2;
};
someBlock();

Would cause a compiler error asking for the __block specifier to be used. so in this case you can try:

 __block int num=1;
void (^someBlock)(void) = ^{
num = 2;
};
someBlock();

and num will contain the correct value after block execution.

Straight forward right? So what about the following example:

 __block NSMutableArray *someArray = @[@"Hello",@"World"];
void (^someBlock)(void) = ^{
[someArray addObject:@"Goodbye"];
};
someBlock();

It’s wrong… you don’t need __block in this case… why? because you’re not assigning a value to the captured “variable” someArray, rather you’re just sending a message. I often see this and wonder why.

The __block specifier is actually a storage-class specifier, to give you an idea of what this means, the following are also storage-class specifiers in C. extern, typedef, static and so on.

Why don’t I like __block a great deal then? Read on for more…

… 

 

Manage your KVM Hypervisor Remotely on your iPhone / iPad

Recently I began experimenting with KVM virtualisation in the Linux Kernel. Its a great technology that if your CPU supports VT-x / AMDV offers almost (really, almost) bare metal level performance inside Virtual Machines. It works on most Linux flavours and has a couple of handy management tools such as virsh and virt-manager. However, one thing I thought was always lacking and annoying me was of course, the ability to manage my Hypervisor from my iPhone / iPad when on the move! Time for an experiment I thought; then out came “KVM Remote”

KVM Remote on the iPad and 3 Different Remote Hypervisors

Its universal so works on both the iPhone and iPad and is extremely bleeding edge right now, but works! and is incidentally the first App i’ve made that doesn’t have selfish fiscal intentions, so theres another great reason to download it from the AppStore now!

P.S. i’ll be updating it regularly adding more features as requests come in.

 

How to turn off Auto Layout Automagically on Xcode 4 post iOS 6

I’m sure i’m not the only one who is annoyed at the fact that, even though my project Deployment Target is set as iOS 5.0… Xcode finds it neccesary to enable Auto Layout on all newly created XIB’s regardless… causing Runtime exceptions that can be pesky and hard to find if not testing looking. So I started thinking how to disable this once and for all…

After monitoring the state of my disk, before and after ticking the infallable box in IB, I realised that Xcode is actually using some xml files to enable/disable this feature, however, there are a few locations and its a little pesky… i’d document it all here, but I don’t have it to hand and can’t remember… so maybe later… but until then, here is a little tool I made that performs a simple regexp on some of your Xcode installation files to make sure Auto Layout is disabled 🙂 NOTE: You’ll have to re-run this tool if you update/re-install Xcode.

Download: AutoLayoutAnnoysMe.zip

 

 

How to Unlock almost any iPhone without any jailbreak or accessory

So… some of you may have already seen this, if you didn’t then, here it is 🙂 its pretty cool, it works… but has one caveat… Its a TEMPORARY unlock… i.e. it will unlock your phone sure, but once your TMSI (Temporary Mobile Subscriber Identity) is refreshed, you will have to repeat the process again… in the UK and US i think this happens when you switch the phone on/off or travel over a large geographic area… however it could potentially happen whenever…

Instructions on how to unlock are after the break 🙂

  1. Grab your iPhone
  2. Insert a supported Sim Card… so, if your phone is locked to Tmobile, put a Tmobile sim in there …