Suppress ".. is deprecated" warning in code block
Water
|
01/28/2014
|
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void) methodUsingDeprecatedStuff {
    //use deprecated stuff
}
#pragma clang diagnostic pop
drawInRect:withAttributes: in iOS 7 and iOS 6.1
Water
|
01/20/2014
|

iOS 7 comes with a new method in NSString for drawing text:

drawInRect:withAttributes:

However if you try to test and use the API using:

if ([string respondsToSelector: @selector(drawInRect:withAttributes:)])

You thing it should work, but actually it will crash on iOS 6.1. It is because the method was already existed in iOS 6.1 as hidden API. And it seems the parameters are different and so th

Continue Reading

Nginx setting to force PDF file to be downloaded instead of viewing in the browser
Water
|
01/08/2014
|

In nginx, when user click on a PDF link, if you want the file to be downloaded instead of showing directly on the web browser, we have to default the MIME type of the pdf files from application/pdf to application/octet-stream. So you can add the following lines in your nginx settings:

# force pdf files to be downloaded
location ~* (.*\.pdf) {
    types { application/octet-stream .pdf; }
    defau

Continue Reading

Prevent brackets.io from using discrete graphics card
Water
|
01/06/2014
|

brackets.io is a brilliant open source code editor by Adobe. The editor is completely written using Javascript. Although sometimes I feel it a little bit slow, it is very powerful as a code editor for web development.

The only thing that annoys me is that the editor will trigger the discrete graphics card on my MacBook Pro Retina that will shorten the battery life of the computer. To solve this,

Continue Reading

Useful XCode plugins (for XCode 5)
Water
|
12/30/2013
|

ColorSense

ColorSense shows the color on UIColor/NSColor code visually. Click on it will open color palette that you can change color interactively.

ColorSense

Continue Reading