Moved to repository: https://github.com/Mailcloud/swift-serializer
| Note that like all analogies, this is not a perfect one. I find it helps me think about it though. Also, don't try to draw conclusions about performance from this analogy :) | |
| -[NSUserDefaults setObject:forKey:] is like... | |
| <edit file to add key and value> | |
| git add file | |
| git commit | |
| dispatch_after(some time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| [[NSUserDefaults standardUserDefaults] synchronize] | |
| }); |
| /* | |
| Purpose: | |
| Convert (or Serialize) an object to a JSON String or Dictionary. | |
| Usage: | |
| Use 'Serialize.toJSON' on instances of classes that: | |
| - Inherit from NSObject | |
| - Implement 'Serializable' protocol | |
| - Implement the property 'jsonProperties' and return an array of strings with names of all the properties to be serialized |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2269385/a714e0e69ba99936f914ade0083709dcca6f8438/hack.sh | sh | |
| # |
| osascript -e 'tell application "iOS Simulator" to quit' | |
| osascript -e 'tell application "Simulator" to quit' | |
| xcrun simctl erase all |
Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.
This document is mainly targeted toward iOS development, but definitely applies to Mac as well.
NSString *foo = @"bar";| extension Array { | |
| func first() -> Element? { | |
| if isEmpty { | |
| return nil | |
| } | |
| return self[0] | |
| } | |
| func last() -> Element? { |
With autofs you can easily mount network volumes upon first access to the folder where you want to mount the volume. Autofs is available for many OS and is preinstalled on Mac OS X so I show you how I mounted my iTunes library folder using this method.
autofs needs to be configured so that it knows where to gets its configuration. Edit the file /etc/auto_master and add the last line:
#
# Automounter master map
#
+auto_master # Use directory service
| #!/bin/sh | |
| ### | |
| # SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
| # For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
| ### | |
| # Alot of these configs have been taken from the various places | |
| # on the web, most from here | |
| # https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
