
Untitled
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 1.73 KB | hits: 15 | expires: Never
Passing Parameter From a View Back To another View's UITableView's Cell
@interface Smoke_ApplicationAppDelegate : NSObject {
UIWindow *window;
UINavigationController *navigationController;
NSString *messageString; //This would be your String Variable
}
@property(nonatomic,retain)NSString *messageString;
@implementation Smoke_ApplicationAppDelegate
@synthesize window;
@synthesize navigationController;
@synthesize messageString; // Synthesize it over here..
import "DelegateFile.h"
@implementation About
DelegateFile *appDel;
-(void)viewDidLoad { [super viewDidLoad];
appDel=[[UIApplication sharedApplication]delegate];
}
appDel.messageString
@protocol SecondViewControllerDelegate
- (void) viewControllerWillDisappearWithLabelText: (NSString*)text;
@end
//in the .h file
@interface SecondViewController : UIViewController {
//declare instance variables
}
@property(nonatomic, assign) id<SecondViewControllerDelegate> delegate;
@end
//in the .m file
@implementation SecondViewController
@synthesize delegate;
//[code...]
@end
//in the .h file
@interface FirstViewController : UIViewController<SecondViewControllerDelegate> {
//[instance variables]
}
//[methods and properties]
@end
//in the .m file
@implementation FirstViewController
//[code...]
- (void) viewControllerWillDisappearWithLabelText: (NSString*)text {
//do whatever you need to do with the text
}
//[code...]
@end
SecondViewController* sv = [[SecondViewController alloc] init];
sv.somestring = someanotherstring;
sv.delegate = self;
- (void) viewWillDisappear: (bool)animated {
[super viewWillDisappear:animated];
if (self.delegate) {
[self.delegate viewControllerWillDisappearWithLabelText: myLabel.text];
}
}