VTNilReplace 0.1.0

VTNilReplace 0.1.0

VTNullSetup维护。



  • 作者:
  • vipul8989

WTNilReplace

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install

需求

安装

WTNilReplace可以通过CocoaPods获取。要安装它,请在您的Podfile中添加以下行

pod 'VTNilReplace'

作者

vipul8989, [email protected]

入门指南

    Just call by VTNullReplacer()

#### 从字典中移除 NSNull 值。

    NullReplace().dictionaryOfFilteredBy(dict: yourDictionary)

#### 从数组中移除 NSNull 值。

    NullReplace().arrayOfFilteredBy(arr: yourArray)

#### 字典示例

    let myDictionary : NSMutableDictionary = NSMutableDictionary()      // let a dictionary
    myDictionary.setValue(123, forKey: "firstKey")                      // add integer value
    myDictionary.setValue(NSNull(), forKey: "secondKey")                // add null value
    myDictionary.setValue([String](), forKey: "thirdKey")               // add array of string
    myDictionary.setValue("one", forKey: "fourthKey")                   // add string value
    myDictionary.setValue([String : AnyObject](), forKey: "fifthKey")   // add a dictionary

    let filteredDict : NSDictionary = NullReplace().dictionaryOfFilteredBy(dict: myDictionary) // call replacer
    print(filteredDict)
    
    input :
    {
        firstKey = 123;
        secondKey = "<null>";
        thirdKey = (
        );
        fourthKey = "one";
        fifthKey = {
        };
    }

    output :
    {
        firstKey = "123";
        secondKey = "";
        thirdKey = (
        );
        fourthKey = "one";
        fifthKey = {
        };
    }

许可证

VTNilReplace遵循MIT许可证。有关更多信息,请参阅LICENSE文件。