Add static safeSetObjectForKey function