Tuesday, June 26, 2012

Monotouch Gotcha : Dispose all outlets

If you have used winforms than you should be familiar with this pattern. Whenever you are done with a window be sure to call Dispose of any other windows that you have a reference to. The reason is that the windows are natively linked to OS windows and in your Dispose you are supposed to release any references to native resources.

In monotouch, even outlets are native objects. So be careful with them. In fact the default monotouch templates point you in the right direction as shown : 

The ReleaseDesignerOutlets automatically adds the code to release any outlets that are created using Interface Builder inside of Xcode:

Of course non-native (managed) resources are not your responsibility : http://stackoverflow.com/a/6620835/390330 

Monday, June 25, 2012

Useful Mac OSX shortcuts for a windows developer

Here is a table of ways things are done in macosx vs. how they are done in windows. Mostly the Ctrl key is replaced by command key. And the windows key is also replaced by the command key.

What : windows 7 : Mac OSX Lion
Address bar browser : ctrl  L : command D  
Run (search on windows, spotlight on macosx) : winkey : command + space 
Copy / cut / paste : ctrl c / x / v : command c / x / v
Delete / backspace : delete / backspace : fn + delete / delete 
Close current application : alt F4 : command Q 
change windows :  alt tab : command tab 
scroll through tabs in safari : : control tab 
home and end page : ctrl home / ctrl end : fn left / fn right
home and end line : home / end : command left / command right OR ctrl A (stArt) / ctrl E (End)
Move backward / forward  one word : ctrl left / ctrl right  : option left / option right

Different windows of same application (like safari):
command+backquote (i.e. ` the key under ~) to toggle between different windows of the same application. Alt + tab like windows does not work between windows of same application. 

What : Windows Explorer : Finder 
delete a file : delete : command delete
rename a file: F2 : enter
open a file: enter : command down (actually go down one level)
go up one level : backspace (actually go back) : command up

The Help menu: 
You can select any menu item using the help menu item added to all applications. Press command + ? (i.e. command + shift + /) to open the help menu and get focus on the search menu item. Just type in the menu item content and you will get an option to select the menu item.

Keyboard shortcuts for MonoDevelop: 
Some are inspired by Emacs. Most menu options have their shortcuts mentioned which is great effort by the MonoDevelop team . The commands I used most often :

Build : command B
Debug : command return
Stop debugging : command shift return
Step Into / step Over / step oUt : Shift command I / shift command O / Shift command U
Intellisense : Control Space

Most shortcuts from here work : http://maccork.com/2011/02/26/monodevelop-keyboard-shortcuts/ 
But occasionally you need to change between control and command keys. Also whenever alt is mentioned you are supposed to use the option key.

Creating an outlet : Control click and drag from main view to assistant editor.
Additional shortcuts for Xcode development can be found here : http://ijoshsmith.com/2010/09/18/basic-xcode-keyboard-shortcuts/ 

Sunday, June 24, 2012

The best version of Macbook Air 2012

 My specs and reason

Why macbook air?

So I decided it was going to be a macbook air. Not a macbook pro because 
a.) If I would play games, I would use a desktop Or better, a gaming console. I only played two games on my dell XPS, max payne 3 (for old times sakes since I played the first two during my undergrad) and prototype. Don't need the heavier graphics card. 
b.) Weight. I envied other people lugging around their laptops while I shied moving my expensive yet awesome laptop. I hope to move more with my macbook.


A cold boot of mac + running chrome alone takes the ram to 2.5GB. The only ram options are 4GB and 8GB. I plan on running cutting edge Windows and .NET runtimes in a VM. So 8GB it is. Not to mention it was only a 100$ more for the ram upgrade. Also operating systems are probably going to demand more ram, Although I hope not since they will be slower if they do no matter how fast the ram gets.


Did not upgrade the processor. That has never been a bottle neck for me. And I feel my current dell with first generation core i7 is super awesome still in processing power. The Air is more powerful than this. Plus the upgrade isn't that much 1.8 to 2.0 still dual core. Hopefully the lower version runs cooler too and uses less battery. I have found no one that would recommend spending on the processor. 


Upgraded the SSD from 128GB to 256GB for 300$. I put a lot of thought into this. Reasons: 
a.) I don't plan on buying another laptop for at least a year. Possibly two. And I hate using two systems. 128GB is not going to last even half a year. And the end of the year I can delete most of the data I have. But most stuff needs to stay with me for a year. 
b.) I want the portability of the macbook air, an external harddisk kills it. 
c.) Windows 7 took 50GB after windows update on my last refresh install of windows. And I haven't even installed visual studio yet. If I want to run both operating systems, 128 is not even an option. 
d.) The upgrade cost from the primary non apple retailer OWC (http://www.macsales.com/) is 300$ which is comparable to what apple is charging. Yes I can sell the 128GB SSD when I upgrade but finding a customer is not fun. Not to mention it voids any apple warranty. And you spend a lot of time making sure you transfer the data you need. And securely wipe it. Just a hassle that saves a 100$ in total. Not worth it.

Moving to a Macbook from Windows

My previous rig: I have been using a dell xps studio 16 as my main laptop for the past year. It has been awesome all the way. It cost only 1100$ and came with impressive specs like a quad core CPU and 1GB dedicated GPU. I primarily used Visual Studio 2010 and develop in .NET.

Like many people I feel that it was time I tried the "other" popular platform that users were loving. The Mac/iOS family. I would like to point out I already use iPhone as my main phone. I also have an iPad which resulted in an explosion in the amount of reading I got done in the past 2 years. Simply because of the ease of closing one book when I no longer feel the author or feel overwhelmed with the information and opening the another one instantaneously.

But I have never owned or even used a Mac before. And that just feels not right for a geek. The reason why I never bought one before was two fold: 

I live and breathe C#

No longer an issue thanks to Mono guys. http://xamarin.com/
I am an engineer and appreciate code beauty and code evolution. C# satisfies my urge for programmers lives being made easy by other programmers. If no ones lives are getting easier programmers aren't focusing on the right kinds of problems.

I like the freedom of hardware choice

Still an issue. But unfortunately there are some major discrepancies in my windows hardware :  The webcam on my dell was not the awesomest. But more importantly : There is a delay when I try to record and live listen audio plugged into line in. Even my P2 desktop didn't have this problem. Compare this with what mac gives you : http://www.apple.com/ilife/garageband/ Being a (hobbyist) musician having a system guaranteed to work (like all apple products) as advertised is a safety that I enjoy over mix and match hardware choice. 

I never put the Dell XPS studio 16 on my lap because of known overheating and motherboard frying incidents. And didn't even move around with it much because of weight and because of fear of a harddisk crash.

The macbook air is the best ultrabook you can buy right now. And the 11inch, 128GB SSD, 4GB base version is comparable in price to windows ultrabooks.

In short Macbook Air is the best "laptop" you can buy. You can make yourself a better desktop. But a better ultra-portable laptop is impossible to make on your own. 

Friday, June 15, 2012

Monotouch means business

What is the worlds largest medical technology company? Medtronic (Thats what google says. 
And thats what they say)

Do they have iPad applications used in hundreds of hospitals / medical centers? Why yes ... of course : http://www.apple.com/ipad/business/profiles/medtronic/

They used objective-c for this right? Wrong. http://www.infoq.com/news/2011/04/Mono-iPad

Details : http://vagabondrev.org/2011/04/20/monocross-the-technology/
And here is a nice presentation for people that like videos : http://www.infoq.com/presentations/The-Rise-of-Mono-in-the-Enterprise

Something to think about the next time someone says "Well you can use C# for iPads as well".
Of course there is nothing stopping someone coming up with saying "Well you can use Java for iPads as well" or is there

Tuesday, June 5, 2012

MonoTouch / Mono for Android (MonoDroid) links

My increasing list of links for learning and using monotouch / mono for android:

Video Tutorials
From xamarin. New videos every week! http://www.youtube.com/xamarinhq