Ported category to Swift extension

This ported version is NOT backwards compatible with ObjC, as it uses the RawOptionSetType protocol and optional parameters in method definitions. If you want an ObjC-compatible build, ask and I'll push the version I have at home.