WordPress Setup

This is a WIP post

WordPress

  • Permalinks URL structure
    • Custom structure /blog/%postname%/
    • Category base blog/category
    • Tag base blog/tag
  • Run the site through Google page speed analyzer
  • Favicon
  • Logo
  • Update the Shop page title using WordPress SEO by Yoast. SEO -> Titles & Meta -> Post Types -> Custom Post Type Archives

Woocommerce

  • Notification email. Woocommerce -> Products -> Inventory

Analytics

  • Google analytics tracking code. Include demographic tracking snippet
  • Submit site to Google webmaster and Bing webmaster
  • Set up Goal conversion
  • Associate Google Analytics account with Google webmaster site

SEO

  • Install WordPress SEO by Yoast

Cache

  • Install W3TC
  • Install Autoptimize

Social

  • Link site to G+ local business
  • Create Google authorship association
  • Link site to Facebook
  • Post all products to Pinterest
  • Post all blog posts to Google +
  • Post all blog posts to Twitter
  • Post all blog posts to Facebook
  • Create instagram
  • Disqus plugin

Images

  • Install EWWW
  • Check image size is correct.
    • Woocommerce -> Products -> Product Image Sizes
    • You will need to install Regenerate Thumbnails and run it

Cusomer Service

  • Zopim

Email

  • Install Mailchimp plugin
  • Add GA tracking code to Mailchimp

 

What I Learnt Building 6 Real Estate iPhone Apps

I’ve built the following real estate related apps over the last few months. All of them are Singapore centric except for the rental yield calculator and the mortgage calculator.

  1. Progressive Payment Calculator 
  2. SG Stamp Duty Calculator
  3. Loan Affordability Calculator
  4. Property Tax Calculator
  5. Rental Yield Calculator
  6. Mortgage Calculator

Takeaways

  • When dealing with currency operations, just bite the bullet and use NSDecimalNumber. You’ll save yourself a lot of grief further down the road
  • Always try to use NSNumberFormatter for converting from NSNumber to NSString or the other way round. Don’t do things like self.label.text = @”$0.00″. Instead, do self.label.text = [self.formatter stringFromNumber:self.number] where self.formatter is a NSNumberFormatter property. Here’s how I instantiate my property.
    - (NSNumberFormatter *)formatter {
        if (!_formatter) {
            _formatter = [[NSNumberFormatter alloc] init];
            _formatter.numberStyle = NSNumberFormatterCurrencyStyle;
            _formatter.locale = [NSLocale currentLocale];
            _formatter.generatesDecimalNumbers = YES;
            [_formatter setLenient:YES];
        }
        return _formatter;
    }
  • If you’re dealing with percentages and you find yourself having to multiply/divide 100 at certain parts of your code, there’s a good chance you’re doing it wrong. Use NSNumberFormatterPercentStyle for NSNumberFormatter. Always work with the decimal form of your percent before formatting it for display at the final step.
  • Always test your app by changing the default region to another country which doesn’t have $ as it’s currency symbol. You can do so by going to Settings > General > International > Region Format. If you’re using NSNumberFormatter correctly, you should be safe.
  • Currency input sanitization can be annoying. Your sanitizer needs to handle the situations where
    • User input with currency symbol
    • User input without currency symbol

    as it was in my case. The initial input from the user doesn’t contain currency symbols. Once the formatter is applied and displayed, subsequent changes to the textfield will involve a currency symbol. It is probably worth noting that [self.formatter numberFromString:self.label.text] requires self.label.text to be in a format that contains the currency symbol otherwise it will return nil. This makes it annoying for the initial input where there isn’t a currency symbol and subsequent inputs where there is.
    My workaround for that is to enforce the currency symbol all the time. I use this little snippet to do so

Comment Scene Like Instagram

In my short stint with iOS programming thus far, I found that one of the most difficult and crucial part of the process is deciding which controller to use. Conceivably, you could use a plain UIViewController to design everything but that’s a poor man’s way of going about it. Here’s how I did the comment page for Instagram.

There are a few requirements:

  • Comment box should stick to the bottom
  • Autolayout should be used
  • UITableViewCell should resize accordingly to the amount of text required to fit the cell nicely
  • Bonus: works in landscape and portrait modes. Instagram doesn’t support landscape.

2014-04-24 12.26.36

2014-04-24 12.23.33

 

 

 

 

 

 

General process:

  • Insert a TableView into a UIViewController
  • Add a subview programmatically or via storyboard
  • Set the constraints up correctly
  • Animate the bottom constraint from the comment box to it’s superview as and when the keyboard appears

Some gotchas:

  • You can’t do this using a UITableViewController and then laying a subview into it.
    • The view will move along with the tableview as you scroll which is not the behaviour you want
  • You can’t do this using a UITableViewController and then adding the comment box in the footer
    • The footer will always be below the last cell in the tableview which is not what you want

Code: https://github.com/nychng/AutoSizeTableCell

UICollectionView Doesn’t Fill The Screen. Leaves a Top and Bottom Thin Black Margin

If you have a UICollectionView in a UIViewController, you might see something like the image shown here. There are two horizontal black space running across the top and bottom of the Cell. The reason for this is because you might have

- (BOOL)prefersStatusBarHidden {
    return YES;
}

The spacing seems to be space set aside for the status bar.

Screen Shot 2014-03-28 at 11.45.44 am

Next Set of iOS Queries to Answer

  1. In the storyboard, which layout to work in? 3.5 or 4 inch?
  2. Do you drag the size of your view all the way to the edge of the 4 inch? How does this affect the 3.5 inch view?
  3. In a navigation controller, the Top Bar pushes down content when there’s a scroll view. It doesn’t push it down in a normal view. Why?
  4. How to manage autolayout and scroll view?
  5. Should you lazy instantiate all of your properties all the time? Including all the UILabels and UITextFields?
  6. Assuming I want the height of a view to occupy the few screen, what should the height of the UIView be in a navigation controller (with and without the status bar)
  7. In View Controller, what does Extend Edges — Under Top Bars/Under Bottom Bars/Under Opague Bars