views:

228

answers:

3

I am new to iphone development.I want to to access the instance variable declared in uiview from its uiview subview.please help me out .Thanks.

+1  A: 

UIView has a superview property that will point to the view's superview if it has one. You can send messages to the object it points to.

Jasarien
Although, if this superview a subclass of `UIView`, you will have to cast it or thecompiler will throw warning at you. `[(MYViewClass*)[self superview] doStuff]`
Squeegy
+1  A: 
view.superview.iVar
Mr-sk
+1  A: 

Technically, you can just do [[self superview] foo] from within one of the child's instance methods and that will give you access to the foo property on the parent (you may have to cast the superview, though). But something to consider is that in hierarchical data structures (like the UIView hierarchy), it's generally good practice for children to not "know" too many of the details of their parents, where possible.

erikprice