0x0000000000000000 in iOS?

366 Views Asked by At

I have a view, and I want to remove it in a particular situation.

if (self.superview) {

    [self removeFromSuperview]; // breakpoint point here
}

I lldb it :

(lldb) po self.superview
0x0000000000000000

How to judge the superview equals to 0x0000000000000000?

1

There are 1 best solutions below

0
On

It is safe to send removeFromSuperview to a view even if the view isn't in a superview. If the view isn't in a superview, the message will have no effect. So testing self.superview is not necessary.

When self.superview prints as 0x0000000000000000, that means it is nil, which means self is not in a superview.