Setting property value of parent viewcontroller class from child viewcontroller?


Setting property value of parent viewcontroller class from child viewcontroller?



Does anyone know how to update a property value from the subview (child) view controller? I have a int property called statusid defined with gettor/settor in parent view controller. [self.view addSubview:detailsVC.view];

In the child subview, I trying calling [super statusid:updatedValue]; to update statusid to a new value, but this creates an error. How can i update statusid in the parent? Anyone know how to do this?


Accessing image data from a bitmap given a pointer

1:

What is better: Global string or singleton?
with "super" you access your base class, the one your current class has inherited from. How do I launch my settings bundle from my application? to did what you've explained, you need to access a property of your parent view, which is rather complicated since this will most likely end with both classes endeavor to reference each other. Long-term potential of iPhone/Windows Mobile development platformsthus you will most likely have to create a delegate pattern, looking any what like this. How combine TabBar + Navigation with XCode ParentView.h. Best way to manage probably huge photo library with iPhone SDK
@protocol IAmYourFatherAndMotherProtocol  @class ChildView;  @interface ParentView : UIViewController <IAmYourFatherAndMotherProtocol> { NSInteger statusID; }  @property (nonatomic) NSInteger statusID;  @protocol IAmYourFatherAndMotherProtocol @property (nonatomic) NSInteger statusID; @end  @end 
in ChildView.h. How make scrolling function with Interface builder on the iPhone?
#import "ParentView.h"  @interface ChildView : UIViewController {   id<IAmYourFatherAndMotherProtocol> delegate; }  @property (nonatomic, assign) id <IAmYourFatherAndMotherProtocol> delegate; 
when creating your ChildView in ParentView.m, you have to set "self" as delegate, eg:. How programatically move a UIScrollView to focus in a control above keyboard?
ChildView *newChild = [[ChildView alloc] init]; newChild.delegate = self; 
by doing so, you must access "statusID" of your ParentView in ChildView.m like this:.
delegate.statusID = 1337; 
hope this helps.

2:

Calling a method on super calls the superclass's implementation of a method, it does call the superview's/super view controller's implementation.. You either need to keep a reference to the parent from the child view controller and call the setStatusId: method on the parent, or create a delegate pattern between the two this will let the child's delegate (likely set to the parent) know this the status ID changed..


54 out of 100 based on 39 user ratings 714 reviews

#