<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en"
   >
  <title type="text">Hwee-Boon Yar</title>
  <subtitle type="text">Thoughts, links and braindumps</subtitle>

  <updated>2012-01-30T04:49:03Z</updated>
  <generator uri="http://blogofile.com/">Blogofile</generator>

  <link rel="alternate" type="text/html" href="http://hboon.com" />
  <id>http://hboon.com/feed/atom/</id>
  <link rel="self" type="application/atom+xml" href="http://hboon.com/feed/atom/" />
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[I don't use Interface Builder]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/i-don't-use-interface-builder" />
    <id>http://hboon.com/i-don't-use-interface-builder</id>
    <updated>2011-08-27T22:48:00Z</updated>
    <published>2011-08-27T22:48:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[I don't use Interface Builder]]></summary>
    <content type="html" xml:base="http://hboon.com/i-don't-use-interface-builder"><![CDATA[<p>I don't use Interface Builder (IB). Not anymore.</p>
<p>Somewhere between going through the iPhone to iPad display transition, supporting both portrait and landscape orientation and building screens that are dynamic and parts of it animated, I discovered that life without IB is much sweeter.</p>
<h2>Why IB?</h2>
<p>IB lets you lay out your user interface visually, with inspectors to tweak the controls' properties. If you work with a designer who is not into programming, it is supposed to let you send the XIBs/NIBs to them and who can tweak it directly without requiring additional work from the developer.</p>
<p>If you have custom built components or do even a little bit of layout in code, your designer wouldn't be able to see how the UI looks like in IB. Also, tweaks could mean animate this button for 0.1 seconds longer which requires changes in the code to see the result.</p>
<h2>UI Reuse</h2>
<p>You need to keep 2 set of NIBs, 1 for iPhone and 1 for iPad. Controls may need to be laid out differently in different screens, or you might have more functionality when running on the iPad due to the additional screen real estate available.</p>
<p>But often, there is UI that is re-usable across the two screen sizes. Creating your view programmatically makes it much easier to share them. For example, you can detect or pass in the actual screen size.</p>
<p>When you have your views written in code, you can decompose them into functions, methods, classes. Much better than in IB which pretty much can't be reused.</p>
<h2>Portrait and Landscape Orientation</h2>
<p>Let's face it: the layout system in IB is quite primitive. It lacks the layout managers provided in systems such as Java and Smalltalk. If you use IB, you often do up the portrait mode screen in NIBs and then run code to adjust them when changing to landscape orientation. This mixing of IB and code makes things more confusing and hard to architect.</p>
<h2>Fine. So How Do We Do It in Code Instead?</h2>
<p>For each screen, I have a controller class and view class pair. Here's the controller class:</p>
<pre><code>@interface MyViewController : UIViewController

@property (nonatomic,retain) UIView* mainView;

@end

@implementation MyViewController

@synthesize mainView;

- (void)loadView {
    self.view = [[[UIView alloc] initWithFrame:
        [UIScreen mainScreen].bounds] autorelease];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |
        UIViewAutoresizingFlexibleHeight;
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.mainView.autoresizingMask = UIViewAutoresizingFlexibleWidth |
        UIViewAutoresizingFlexibleHeight;
    //self.mainView.delegate = self;  //good to have
    [self.view addSubview:self.mainView];

    /* TODO: controller is displayed for the first time, do things like
        load data, etc */
}

- (void)viewDidUnload {
    [super viewDidUnload];

    self.mainView = nil;
}

- (void)dealloc {
    /* Call -viewDidUnload here so all releasing of view resources is
        only done at 1 place. */
    [self viewDidUnload];
    //TODO: Release other owned ivars here

    [super dealloc];
}

- (MainView*)mainView {
    if (!mainView) {
        /* We use [UIScreen mainScreen].bounds instead of
            self.view.bounds so we don't create self.view as a
            side-effect. It's messy because creating self.view will
            trigger creation of self.mainView itself */
        self.mainView = [[[MyView alloc] initWithFrame:
            CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,
            [UIScreen mainScreen].bounds.size.height)] autorelease];
    }

    return mainView;
}

@end
</code></pre>
<p>And here's the corresponding view class:</p>
<pre><code>@interface MyView: UIView

@end

@implementation MyView

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        //TODO: assemble your subview and add them to self.view
    }

    return self;
}

@end
</code></pre>
<p>I often build a UIViewController and UIView subclass containing common code which serves as the base class for most view controllers and views in an application.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[Comments about Straits Times iOS app]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/comments-about-straits-times-ios-app" />
    <id>http://hboon.com/comments-about-straits-times-ios-app</id>
    <updated>2011-08-01T10:16:00Z</updated>
    <published>2011-08-01T10:16:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[Comments about Straits Times iOS app]]></summary>
    <content type="html" xml:base="http://hboon.com/comments-about-straits-times-ios-app"><![CDATA[<p>I saw a few tweets about the Straits Times app being available for the iPad and thought I check it out. Some initial thoughts and suggestions:</p>
<h2>Straits Times app on the iPad</h2>
<ul>
<li>EULA should go into the EULA accessible in the App store instead. There's a least 1 mistake in the EULA, referring to the "I Do not Accept Button" as the "Cancel" button.</li>
<li>UI is jerky, it doesn't respond immediately to finger dragging the screen.</li>
<li>Sometimes when you swipe to a new page, the images flashes.</li>
<li>Get rid of the animation for unrolling the paper after tapping on the "iPad Edition", "PDF Edition" or "Breakign News" buttons. It's unintuitive, especially as there's a pause before the animation to reveal the article starts.</li>
<li>The "Breaking News" UI seems quite different from the "iPad Edition", e.g. you can scroll articles up and down in "Breaking News" and website-like tabs are used for sections, but you swipe left-right in "iPad Edition" and tab buttons at the bottom are used for sections.</li>
<li>There isn't a clear visual response when you tap on the screen (especially articles) to indicate what you have tapped on. The articles suddenly pop up fullscreen.</li>
<li>Crashes within 1 minute of initial use, crashes again within the next few minutes.</li>
<li>I like that tapping on the photo thumbnails bring up a fullsize image with the caption. I wonder if there is something interesting that can be done along the lines of <a href="http://www.boston.com/bigpicture/">The Big Picture</a>.</li>
</ul>
<h2>Straits Times app on the iPhone</h2>
<ul>
<li>EULA (see comment for EULA for app running on iPad).</li>
<li>Has an irritating ad that animates after each refresh. Perhaps move it to the top or bottom, but either way, just keep it stationary and don't flash it?</li>
<li>App slows down while reloading.</li>
<li>In a few minutes testing, seems more stable than running on the iPad.</li>
</ul>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[Trying out Safari again]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/trying-out-safari-again" />
    <id>http://hboon.com/trying-out-safari-again</id>
    <updated>2011-07-11T17:55:00Z</updated>
    <published>2011-07-11T17:55:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[Trying out Safari again]]></summary>
    <content type="html" xml:base="http://hboon.com/trying-out-safari-again"><![CDATA[<p>Trying out Safari again since I migrated to a new machine. (I actually couldn't download Chrome with Safari on both my old and new machine. Had to use Firefox to download. Very strange!)</p>
<p>What I missed from Chrome</p>
<ul>
<li>Multiple undo of tabs closed and the restored tab(s) preserves history</li>
<li><strike>Opening a link in a new tab goes to the right of the current tab</strike> (Update: Safari 5.1 does this now) </li>
<li>It's still faster</li>
<li>Omnisearch bar</li>
<li>The way tabs are displayed</li>
</ul>
<p><strike>What I hate about Safari</strike></p>
<ul>
<li><strike>Safari has this annoying behavoir where when you open a new window, press Cmd+L quickly to go to location bar, start typing and it suddenly loses focus. Everytime. Annoys me to no end.</strike> (Update: finally gotten down to it. It's the Handoff extension. Removed it and the problem is gone)</li>
</ul>
<p>What's good about Safari</p>
<ul>
<li>It's a much better Mac citizen, e.g. QuickCursor support which I think requires using the accessibility API.</li>
</ul>
<p>Other than that, they aren't that different for day-to-day web browsing.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[Migrated from Posterous to Blogofile]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/migrated-from-posterous-to-blogofile" />
    <id>http://hboon.com/migrated-from-posterous-to-blogofile</id>
    <updated>2011-07-11T10:46:00Z</updated>
    <published>2011-07-11T10:46:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[Migrated from Posterous to Blogofile]]></summary>
    <content type="html" xml:base="http://hboon.com/migrated-from-posterous-to-blogofile"><![CDATA[<p>I have migrated this blog from Posterous to being self-hosted on <a href="http://blogofile.com/">Blogofile</a> over the weekend. It's easy to get started and I like simpler tools whenever reasonable. If you have been subscribing to my RSS feed at http://hboon.posterous.com, now's the time to change it to <a href="http://hboon.com/feed">http://hboon.com/feed</a>.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[In-app Purchase Patent and What iOS developers Should Know About It]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/in-app-purchase-patent-and-what-ios-developers-should-know-about-it" />
    <id>http://hboon.com/in-app-purchase-patent-and-what-ios-developers-should-know-about-it</id>
    <updated>2011-05-17T23:11:00Z</updated>
    <published>2011-05-17T23:11:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[In-app Purchase Patent and What iOS developers Should Know About It]]></summary>
    <content type="html" xml:base="http://hboon.com/in-app-purchase-patent-and-what-ios-developers-should-know-about-it"><![CDATA[<p>There has been a <a href="http://www.lodsys.com/">patent troll</a> going around contacting iOS developers who are offering in-app purchases, informing them of patent infringement. <a href="http://fosspatents.blogspot.com/">FOSSpatents</a> has put up an article detailing <a href="http://fosspatents.blogspot.com/2011/05/what-app-developers-need-to-know-about.html">what iOS developers should know about it</a>. It also mentions (note that this are educated guesses, not facts) about how Apple and other companies including Google who also run similar app store might react. Do yourself a favor and read it even if you are not utilitzing in-app purchase today.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[Using ctags with MacVim for Objective C on OS X]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/using-ctags-with-macvim-for-objective-c-on-os-x" />
    <id>http://hboon.com/using-ctags-with-macvim-for-objective-c-on-os-x</id>
    <updated>2011-01-12T22:24:00Z</updated>
    <published>2011-01-12T22:24:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[Using ctags with MacVim for Objective C on OS X]]></summary>
    <content type="html" xml:base="http://hboon.com/using-ctags-with-macvim-for-objective-c-on-os-x"><![CDATA[<ol>
<li>Install <a href="http://mxcl.github.com/homebrew/">Homebrew</a> if you haven't.</li>
<li>Run <code>brew install ctags</code>. The version of ctags that ship of OS X is an antique.</li>
<li>Run <code>echo "--langdef=objc" &amp;gt;&amp;gt; ~/.ctags &amp;amp;&amp;amp; echo "--langmap=objc:.m" &amp;gt;&amp;gt; ~/.ctags &amp;amp;&amp;amp; echo "--regex-objc=/^[\t ]*(\-|\+)[\t ]*\([_a-zA-Z0-9][_a-zA-Z0-9]*\)([_a-zA-Z0-9][_a-zA-Z0-9]*)/\2/f/" &amp;gt;&amp;gt; ~/.ctags</code></li>
<li>cd to the directory to write the tags file in</li>
<li>Run <code>ctags -R mytargetdirectory</code></li>
<li>Press ^] in MacVim over a function name to go to declaration/definitions</li>
</ol>
<p>PS: Creating the .ctags file is so convoluted because I can't figure out how to put a multiliner without ruining the formatting in the instructions.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[Glass Buttons in iPhone Apps Without Using Image Files]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/glass-buttons-in-iphone-apps-without-using-image-files" />
    <id>http://hboon.com/glass-buttons-in-iphone-apps-without-using-image-files</id>
    <updated>2010-07-06T12:03:00Z</updated>
    <published>2010-07-06T12:03:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[Glass Buttons in iPhone Apps Without Using Image Files]]></summary>
    <content type="html" xml:base="http://hboon.com/glass-buttons-in-iphone-apps-without-using-image-files"><![CDATA[<p>For folks who want to <a href="http://github.com/hboon/GlassButtons">create glass buttons in iPhone apps without using private APIs and image files</a>.</p>
<p>From the README:</p>
<p>Uses public APIs to create native-looking glass buttons. No image files used. Buttons can be created in IB (and configured programmatically) or fully by code.</p>
<ul>
<li>Include Quartz Core framework.</li>
<li>Add Global.h, MOButton.h/.m, MOGlassButton.h/.m</li>
<li>See demo project.</li>
</ul>
<div style="text-align:center">
    <img src="/images/glass-buttons-in-iphone-apps-without-using-image-files.png"/>
</div>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[My SimplyTweet Punch Card]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/my-simplytweet-punch-card" />
    <id>http://hboon.com/my-simplytweet-punch-card</id>
    <updated>2010-06-03T23:11:00Z</updated>
    <published>2010-06-03T23:11:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[My SimplyTweet Punch Card]]></summary>
    <content type="html" xml:base="http://hboon.com/my-simplytweet-punch-card"><![CDATA[<p>I use GitHub to manage my code and I thought it's interesting to look at my commit activity for SimplyTweet. GitHub has an excellent tool for this called Punch Card. This is how it looks like for SimplyTweet:</p>
<div style="text-align:center">
    <img src="/images/my-simplytweet-punch-card.png"/>
</div>

<p>It shows the relative number of commits (rough equivalents of changes if you are consistent) performed across the duration of the project. You can see that</p>
<ol>
<li>I am most productive (again, commit-wise) the few hours around 12am and 12pm.</li>
<li>I am least productive on Fridays.</li>
<li>I seem to be slightly more productive during midnight than noon.</li>
<li>I work on Saturday nights.</li>
<li>I work on Sunday nights</li>
<li>I work everyday.</li>
</ol>
<p>Does anyone else has Punch Card graphs they like to share?</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[How to Report a Bug in a Software to the Developer]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/how-to-report-a-bug-in-a-software-to-the-developer" />
    <id>http://hboon.com/how-to-report-a-bug-in-a-software-to-the-developer</id>
    <updated>2010-06-01T01:11:00Z</updated>
    <published>2010-06-01T01:11:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[How to Report a Bug in a Software to the Developer]]></summary>
    <content type="html" xml:base="http://hboon.com/how-to-report-a-bug-in-a-software-to-the-developer"><![CDATA[<p>As a software developer, I often receive bug reports. As with all software developers, I can't make sure my software doesn't get released without bugs, but we most certainly want to fix bugs which are reported.</p>
<p>Here's what as a user, how you can help us:</p>
<ol>
<li>Let us know what you were doing when you saw the bug. Is there a way to reproduce the bug reliably? It's always easier to fix if you can help the developer see the bug for himself/herself. This is the single most important thing you can do for the developer to help fix a bug.</li>
<li>If it's something that can be seen on the screen, a screenshot helps.</li>
<li>State which version of the software are you running on.</li>
<li>State which version of the operating system are you running on.</li>
</ol>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://hboon.com</uri>
    </author>
    <title type="html"><![CDATA[You can copy and paste from/to the iPhone simulator]]></title>
    <link rel="alternate" type="text/html" href="http://hboon.com/you-can-copy-and-paste-from/to-the-iphone-simulator" />
    <id>http://hboon.com/you-can-copy-and-paste-from/to-the-iphone-simulator</id>
    <updated>2010-05-18T03:53:00Z</updated>
    <published>2010-05-18T03:53:00Z</published>
    <category scheme="http://hboon.com" term="Uncategorized" />
    <summary type="html"><![CDATA[You can copy and paste from/to the iPhone simulator]]></summary>
    <content type="html" xml:base="http://hboon.com/you-can-copy-and-paste-from/to-the-iphone-simulator"><![CDATA[<p>Did you know you can copy and paste from/to the iPhone simulator? Just press Cmd+V to paste and then tap in the simulator to paste as usual. Tap in the simulator to copy and then Cmd+C to copy back into your development machine.</p>]]></content>
  </entry>
</feed>

