Help me pls with this unexpected trouble.
if (view.tag != nil)
All views have a tag. default is Zero 0
It depend on what you have. I believe you should consider a view with tag 0 is a view that is not tagged. and start tagging from 1.
Since the tag property of a view is of type
NSInteger it can not be
NSInteger is a primitive type and therefore can not have a
nil pointer. The default value assigned to the property will be
Also, when you compare nil with 0 it gives a YES in objective-c. Thats what is breaking your logic.
if (view.tag != nil) equivalent to
if (view.tag != 0)