ios - 如何从 objective-c 中的 NSMutablearray 中删除空值?

标签 ios objective-c

当我使用 json 网络服务并将值存储在 NSMutablearray 中时,我得到了 Null 响应。现在我想删除该 null 值并将其替换为空值。谁能帮我解决这个错误。

(
        {
        Aadhar =1123323244;
        AddressProofCopy = "<null>";
        Advertisement = "<null>";
        AgreementCopy = "<null>";
        ApCity = ggg;
        ApDistrict = g;
        ApDoorNo = g;
        ApFGFirstName = v;
        ApFGSurName = g;
        ApGender = F;
        ApPIN = 12323;
        ApStreet = h;
        AppStatus = "<null>";
        ApplRefStageStatus = N;
        ApplicantFirstName = g;
        ApplicantPhoto = "<null>";
        ApplicantSurName = g;
        ApplicationDate = "2018-09-06T00:00:00.000Z";
        ApplicationType = New;
        BuldingType = "<null>";
        District = 132424;
        DistrictId = 11;
        DocVerifiedBy = "<null>";
        DocVerifiedDate = "<null>";
        DocVerifiedMessage = "<null>";
        DocVerifiedStatus = "<null>";
    }
)

最佳答案

请验证此链接.. https://github.com/bismasaeed00/NullReplacer它对我来说工作正常。

试试这个..

#import "NSArray+NullReplacement.h"
#import "NSDictionary+NullReplacement.h"

之后,根据使用下面的行传递您的字典/数组 JSON 响应,

NSArray *newvalue = [yourarrayresponse arrayByReplacingNullsWithBlanks];

NSDictionary *newvalue = [yourdictionary dictionaryByReplacingNullsWithBlanks];

如果你得到任何错误,只需添加

#import "NSArray+NullReplacement.h"

在NSDictionary+NullReplacement类中

#import "NSDictionary+NullReplacement.h" 

在 NSDictionary+NullReplacement 类文件中。

关于ios - 如何从 objective-c 中的 NSMutablearray 中删除空值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52200344/

相关文章:

android - 如何为 Android 和 iOS 使用相同的 Cucumber 步骤定义

iphone - 将对象存储到 NSMutableArray

iphone - UIImageView 不显示图像

objective-c - 如果从 subview 拖入,NSView 会丢失 mouseMoved/mouseDragged

ios - UITextView 内的 UITextField 一次性关闭键盘

iphone - iPhone 上的 ASIHTTPRequest 编译错误 - `set`

ios - UIButton 标题和图像的不同对齐方式

iphone - 停止从新线程加载照片

objective-c - 具有可配置 URL 的 webview

iphone - UIView 不尊重 UINavigationController 中 'loadView' 中的框架