I need to pass back an NSMutableArray of photos between a CameraSessionView; how store the photos taken from camera on an NSMutableArray, and a TableViewController how uploa
If you have to pass data from B View Controller To A view Controller
Create protocol in B View Controller as
@protocol BViewControllerDelegate
-(void)didclickonSubmit:(NSArray*)selected_array;
@end
Create an id, so that you can assign any class as its delegate class.
@property (weak,nonatomic) id delegate;
Call this method in B View Controller on submit button or wherever required.
if (self.delegate && [self.delegate respondsToSelector:@selector(didclickonSubmit:)])
{
[self.delegate didclickonSubmit:myarray];
}
Create an object of B View Controller in View Controller A and assign A as delegate of B
BViewController *b = [[BViewController alloc]init];
b.delegate=self;
Implement required protocol methods of B in A and access the array
-(void)didclickonSubmit:(NSArray*)array
{
NSArray *myarray =[[NSMutableArray alloc]initWithArray:array];
}
now you can use myarray,as u like it..
hit link for sample project https://www.dropbox.com/s/002om8efpy6fout/passDataToPreviousContoller.zip Hope it helps..
****EDITED**** u can for sure assign tableViewController as delegate of UIView class.
@protocol BView
-(void) didclickonSubmit:(NSArray*) selected_array;
@end
@interface BView : UIView
@property (weak,nonatomic) id delegate;
@end
in A i.e. your tableViewController create an object of B and assign your tableview controller as delegate of B .
BView *b=[[BView alloc]init];
b.delegate=self;
Happy Coding..:)