NSDictionary from NSData | Cocoanetics

#import "NSDictionary+Helpers.h"
@implementation NSDictionary (Helpers)
+ (NSDictionary *)dictionaryWithContentsOfData:(NSData *)data
	// uses toll-free bridging for data into CFDataRef and CFPropertyList into NSDictionary
	CFPropertyListRef plist =  CFPropertyListCreateFromXMLData(kCFAllocatorDefault, (CFDataRef)data,
	// we check if it is the correct type and only return it if it is
	if ([(id)plist isKindOfClass:[NSDictionary class]])
		return [(NSDictionary *)plist autorelease];
		// clean up ref
		return nil;

Template and Guideline on Git Commit Message

Here is a template originally written by Tim Pope at tpope.net and mentioned in the Pro Git book

Short (50 chars or less) summary of changes

More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together.

Further paragraphs come after blank lines.

- Bullet points are okay, too

- Typically a hyphen or asterisk is used for the bullet, preceded by a single space, with blank lines in between, but conventions vary here

From Documentation/SubmittingPatches in the Git repo:

Describe your changes in imperative mood, e.g. “make xyzzy do frotz” instead of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to do frotz”, as if you are giving orders to the codebase to change its behavior.  Try to make sure your explanation can be understood without external resources. Instead of giving a URL to a mailing list archive, summarize the relevant points of the discussion.

Trouble Shooting Jenkins 1.556 with Java 8


Recently I started learning Jenkins for my new job. The first issue encountered is Jenkins is just now working after the install. Whenever I create a item, the page will show an error trace as below.

Stack trace
javax.servlet.ServletException: java.lang.ArrayIndexOutOfBoundsException: -1

at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:778)

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at com.thoughtworks.xstream.core.util.OrderRetainingMap.entrySet(OrderRetainingMap.java:77)


After searched around, I found the problem is the XStream class simply doesn’t work with the last JDK (8 at the time of this writing) so the solution is switch the java version to JDK 7.

First install JDK 7 from Oracle.

After that, get the the home of JDK 7.

$ /usr/libexec/java_home -v 1.7

Then set the JAVA_HOME to the location got above in our bash profile. Add the following line to ~/.bash_profile

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

Or add the following line to ~/.bash_profile

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)

After this, restart the terminal and restart the tomcat. The Jenkins will work fine this time. Yeah!!


  1. Installing Apache Tomcat 6 on Mac OS X (Snow) Leopard
  2. Jenkins crash on oracle java 8
  3. ArrayIndexOutOfBoundsException during Jenkins.doConfigSubmit; need XStream 1.4.6
  4. [JIRA] [core] (JENKINS-22263) exception in hudson.node_monitors.DiskSpaceMonitor on startup with jdk8
  5. How can I switch between the two Java versions in Mountain Lion now that Java Preferences is gone?


OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code and looking for potential problems.