Reputation: 16793
I have the following code, which is pre-defined NSArray
but I assign it to an id
variable.
I display the output and want to display class name even though it shows <__NSArrayI ..... >
on the output window, but I am getting an empty description as follows. How could I get class of dic1
?
id dic1 =@[@{@"id":@"1",@"name":@"Test 1 "},@{@"id":@"2",@"name":@"Test 2"}];
(lldb) po dic1
<__NSArrayI 0x100300090>(
{
id = 1;
name = "Test 1 ";
},
{
id = 2;
name = "Test 2";
}
)
(lldb) po [dic1 isKindOfClass:[NSArray class]]
<object returned empty description>
UPDATE
(lldb) p [dic1 isKindOfClass:[NSArray class]]
error: no known method '-isKindOfClass:'; cast the message send to the method's return type
Upvotes: 2
Views: 1141
Reputation: 318794
Here's an answer that summarizes all of the comments.
po
to print the result of an object type. Use p
to print the result of a primitive type.isKindOfClass:
returns a BOOL
so you need to use p
, not po
.Since dic1
is an id
, the debugger isn't sure what the isKindOfClass:
method is so it doesn't know its return type. Add a cast to make it clear:
p (BOOL)[dic1 isKindOfClass:[NSArray class]]
or you can also do:
p [(NSObject *)dic1 isKindOfClass:[NSArray class]]
id
for dic1
but since this is a learning exercise, do what you want. :)Upvotes: 4