Lacrifilm
Lacrifilm

Reputation: 283

Check type of class an NSData store?

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;
}

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);

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?

Upvotes: 0

Views: 187

Answers (1)

shiju86.v
shiju86.v

Reputation: 667

  • Check the type of NSData
  • if([yourData isKindOfClass: [NSData class]])

Upvotes: 4

Related Questions