ObjC: object returned empty description?

My code reads a list of key / value pairs, for example:

A:nodeAbc ... Q:node2 R: T:node3 ... 

Each pair is separated using NSString: componentsSeparatedByString:

 NSArray *kv = [@"R:" componentsSeparatedByString:@":"]; 

In the above list example, R has no corresponding value. When I ask you to print it, here is what I get:

(lldb) po [kv objectAtIndex: 1] (id) $ 33 = 0x00007fff77a888e0

How can I identify this?

 if ([kv objectAtIndex:1]) // returns YES 

I would like it to be perceived as zero, how can this be done? Thanks!

+6
source share
1 answer

This is not zero, this is an empty string (read the documents, it is listed there). Do you want to

 if ([[kv objectAtIndex:1] length] > 0) 
+17
source

Source: https://habr.com/ru/post/923465/


All Articles