Latest 1.1.0
Homepage https://github.com/itsthejb/JCKeyPathValidator
License MIT
Platforms ios 4.0, osx 10.6, requires ARC
Frameworks Foundation
Authors

Build Status
Build Status

Stop using constant NSStrings to represent your keypaths: use compiler symbols instead.

Intro

Super simple extension to Justin Spahr-Summers’ object key path validation macro that adds a macro for validating key paths without requiring an instance of the class.

Particularly useful for removing constant NSStrings from your API mappings.

Usage

  • JCValidateKeyPath(anObject, aKeyPath)

    • The original macro. Validates the specified key path as a compiler symbol and returns an equivalent NSString representation.
  • JCValidateKeyPathWithClass(aClass, aKeyPath)
    • As an extension of the above, does not require an object instance, and can use a Class directly.

Examples:

// With a local instance
NSString *stringInstance = nil;
JCValidateKeyPath(stringInstance, length);

// Without a local instance
JCValidateKeyPathWithClass(NSString, length)

Note that as of v1.0.1 you cannot use JCValidateKeyPathWithClass([NSString class], length). Instead you must use the class symbol directly.

Version history

v1.1.0

Cache now removed and functionality entirely implemented with macros. Many thanks to Stepan Hruda for this.

v1.0.2

General spring-clean and Travis configuration.

v1.0.1

Now casting the object returned from the cache. Without this, class validation wasn’t actually correctly working; you could use any valid selector from any class.

v1.0.0

Initial release.

Have fun!

MIT Licensed >> [email protected]

Latest podspec

{
    "name": "JCKeyPathValidator",
    "version": "1.1.0",
    "summary": "Compiler keypath validation.",
    "description": "Stop using constant NSStrings to represent your keypaths: use compiler symbols instead.",
    "homepage": "https://github.com/itsthejb/JCKeyPathValidator",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jonathan Crooke": "[email protected]"
    },
    "source": {
        "git": "https://github.com/itsthejb/JCKeyPathValidator.git",
        "tag": "v1.1.0"
    },
    "platforms": {
        "ios": "4.0",
        "osx": "10.6"
    },
    "source_files": "JCKeyPathValidation/*.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": true
}

Pin It on Pinterest

Share This