检查NSData商店的类类型? [英] Check type of class an NSData store?

查看:124
本文介绍了检查NSData商店的类类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处理字符串并将其转换为未知格式并将其插入NSData的库。在库中检查NSData是否为空的代码的一部分,如果不是,它发送到服务器:

I have a library that process a string and converts it to an unknown format and insert it into a NSData. In a part of the code that library check if the NSData is empty, if not it sends to the server:

if (!dataToSend) {
return;
}

我认为存储的值是字符串或base64,因为测试了以下代码:

I thought the stored value would be a string or base64, for that tested the following codes:

NSLog(@"To string -> %@",[NSString stringWithUTF8String:[dataToSend bytes]]);

NSString *decodedString = [[NSString alloc] initWithData:dataToSend encoding:NSUTF8StringEncoding];
    NSLog(@"Decode String Value: %@", decodedString);

在控制台中我继续收到(null) ,但是当我从 return; 中插入下面的代码后,数据不为空。我如何检查NSData存储的类型?

In console I continue receiving (null), but the data is not null once I insert that code below from return;. How I can check the type of that NSData stores?

推荐答案


  • 检查NSData的类型

  • if([yourData isKindOfClass:[NSData class]])

    • Check the type of NSData
    • if([yourData isKindOfClass: [NSData class]])
    • 这篇关于检查NSData商店的类类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆