objective c - Trouble casting UIView in iOS -


i have class called fooview subclass of uiview , i'm trying cast uiview object fooview.

i follows

fooview *myview = (fooview*) myviewcontroller.view nslog(@"leg class of %@",nsstringfromclass([myview class])); // uiview here. 

the ivar of myviewcontroller uiview type.

i uiview result, idea why happens?

casting compile-time operation. doesn't magically change type of object. it's compile time checking , little runtime magic. myview still uiview, not fooview.

these 2 lines in question should give answer:

the ivar of myviewcontroller uiview type. uiview result

all objective-c objects have pointer called isa points object of type class. casting not change pointer, nor change size of object.

if want use fooview, need change property type in controller , if you're using interface builder, change type of uiview in inspector on right.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -