Skip to content

Commit

Permalink
Syntactic sugar for dictionaryFromObjectWithKeys
Browse files Browse the repository at this point in the history
This version of the dictionaryFromObjectWithKeys method accepts a varargs of `String` keys and delegates the execution to the original method.
  • Loading branch information
hprange authored and darkv committed Jun 12, 2016
1 parent 12e334a commit 85550ee
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ public static NSDictionary<String, Object> dictionaryFromObjectWithKeys(Object o
return result.immutableClone();
}

/**
* Creates a dictionary from an object and a list of key paths
* @param object object to pull the values from
* @param keys list of keys
* @return Returns a {@code NSDictionary} containing all of the object-key pairs.
*/
public static NSDictionary<String, Object> dictionaryFromObjectWithKeys(Object object, String... keys) {
return ERXDictionaryUtilities.dictionaryFromObjectWithKeys(object, new NSArray<>(keys));
}

// if you're keys are not all strings, this method will throw.
public static NSArray<String> stringKeysSortedAscending(final NSDictionary<String, ?> d) {
NSArray<String> result = null;
Expand Down

0 comments on commit 85550ee

Please sign in to comment.