First of all you should follow object creation and methods declaration in Objective-C
SecondViewController *Obj
it should be as SecondViewController * obj
-(void) MethodCall
it should be as -(void) methodCall
- (IBAction)ButtonClick:(id)sender
is should be - (IBAction)ButtonClick:(id)sender
And, Where did you call your method MethodCall
in FirstViewController
?
Did you try to use Delegate option to send the data to previous view controller?
Example :
In your FirstViewController.h
@protocol FirstControllerDelegate
-(void)dataUpdated:(NSArray *)array;
@end
@interface FirstViewController : UIViewController <FirstControllerDelegate>
@end
In your FirstViewController.m
-(void)dataUpdated:(NSArray *)array
{
NSLog(@" -- MethodCall Success -- :%@", array);
self.title=@"From back";
[tblView reloadData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SecondViewController *Obj= [[SecondViewController alloc] init];
Obj.delegate = self;
[self.navigationController presentViewController:Obj animated:YES completion:nil];
}
In SecondViewController.h
@property (nonatomic, assign) id <FirstControllerDelegate> delegate;
In SecondViewController.m
- (IBAction)ButtonClick:(id)sender
{
FirstViewController *Obj=[[FirstViewController alloc] init];
[_delegate dataUpdated:[NSArray arrayWithObject:@"Object Passed"]];
[self dismissViewControllerAnimated:YES completion:nil];
}