Objects
Functions for working with dictionaries (NSDictionary).
Returns all keys of a dictionary.
A* result = _.keys(OKV({@"one", N.I(1)}, {@"two", N.I(2)}, {@"three", N.I(3)}));// => ["one", "two", "three"]values
Section titled “values”Returns all values of a dictionary.
A* result = _.values(OKV({@"one", N.I(1)}, {@"two", N.I(2)}, {@"three", N.I(3)}));// => [1, 2, 3]functions
Section titled “functions”Returns a sorted list of method names.
A* result = _.functions(_);// => ["all", "any", "bind", ...]Alias: methods
extend
Section titled “extend”Copies all properties from source objects to the destination.
O* result = _.extend(OKV({@"name", @"moe"}), OKV({@"age", N.I(50)}));// => {name: "moe", age: 50}Returns a copy with only the specified keys.
O* result = _.pick(OKV({@"name", @"moe"}, {@"age", N.I(50)}, {@"userid", @"moe1"}), @"name", @"age");// => {name: "moe", age: 50}defaults
Section titled “defaults”Fills in missing properties with default values.
O* iceCream = OKV({@"flavor", @"chocolate"});O* result = _.defaults(iceCream, OKV({@"flavor", @"vanilla"}, {@"sprinkles", @"lots"}));// => {flavor: "chocolate", sprinkles: "lots"}Creates a shallow copy.
O* clone = _.clone(OKV({@"name", @"moe"}));Invokes a block with the object, then returns the object.
O* result = _.chain(OKV({@"a", N.I(1)})) .tap(^(O* obj) { NSLog(@"%@", obj); }) .value();Returns YES if the key is present.
B result = _.has(OKV({@"a", N.I(1)}, {@"b", N.I(2)}), @"b");// => YESisEqual
Section titled “isEqual”Performs deep comparison.
O* stooge = OKV({@"name", @"moe"}, {@"luckyNumbers", AI(13, 27, 34)});O* clone = OKV({@"name", @"moe"}, {@"luckyNumbers", AI(13, 27, 34)});B result = _.isEqual(stooge, clone);// => YESisEmpty
Section titled “isEmpty”Returns YES if the object contains no values.
B result = _.isEmpty(AI());// => YESisArray
Section titled “isArray”Returns YES if the object is an array.
B result = _.isArray(AI(1, 2, 3));// => YESisObject
Section titled “isObject”Returns YES if the object is a dictionary.
B result = _.isObject(OKV({@"a", N.I(1)}));// => YESisString
Section titled “isString”Returns YES if the object is a string.
B result = _.isString(@"moe");// => YESisNumber
Section titled “isNumber”Returns YES if the object is a number.
B result = _.isNumber(N.I(8) * N.I(4) / N.I(2));// => YESisBoolean
Section titled “isBoolean”Returns YES if the object is a boolean.
B result = _.isBoolean(nil);// => NOisDate
Section titled “isDate”Returns YES if the object is a date.
B result = _.isDate([NSDate date]);// => YESReturns YES if the object is NaN.
B result = _.isNaN(NAN);// => YESisNull
Section titled “isNull”Returns YES if the object is nil.
B result = _.isNull(nil);// => YESisFunction
Section titled “isFunction”Returns YES if the object is a block.
B result = _.isFunction(^{ return @"hi"; });// => YESisFinite
Section titled “isFinite”Returns YES if the number is finite.
B result = _.isFinite(N.I(100));// => YESisArguments
Section titled “isArguments”Returns YES if the object is an arguments array.
B result = _.isArguments(args);// => YES_.m Extensions
Section titled “_.m Extensions”These functions are specific to _.m:
isTruthy
Section titled “isTruthy”Returns YES for non-nil, non-empty values.
B result = _.isTruthy(@"hello");// => YESisFalsy
Section titled “isFalsy”Returns YES for nil or empty values.
B result = _.isFalsy(@"");// => YESisDictionary
Section titled “isDictionary”Returns YES if the value is an NSDictionary.
B result = _.isDictionary(OKV({@"a", N.I(1)}));// => YESisBlock
Section titled “isBlock”Returns YES if the value is a block.
B result = _.isBlock(^{ });// => YESvalueTester
Section titled “valueTester”Creates a predicate that tests a property value.
_ItemTestBlock tester = _.valueTester(@"name", @"moe");B result = tester(OKV({@"name", @"moe"}));// => YESvalueStringTester
Section titled “valueStringTester”Creates a predicate that tests a string property.
_ItemTestBlock tester = _.valueStringTester(@"name", @"moe");setProps
Section titled “setProps”Sets a property on all elements in an array.
_.setProps(items, @"selected", @YES);classNames
Section titled “classNames”Returns an array of class names for an object’s class hierarchy.
A* names = _.classNames(myObject);// => ["MyClass", "MySuperClass", "NSObject"]