I have an issue the dismissing view controller to the tabbed view controller. I will explain my flow.
I have 5 tabs in the tabbed view controller in the 3 tabbed i have an camera view from their i am presenting the view controller and passing some parameters by using this code
UIStoryboard *storybord=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
shareViewController *shareview=[storybord instantiateViewControllerWithIdentifier:@"share"];
[self presentViewController:shareview animated:YES completion:nil];
//shareview.finalvideourl=videoURL;
shareview.videooutputstring=videoPath;
from the share view controller I want send the data back to the 1st tab for this I am using the below code
UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
TabedfirstViewController *Tabedfirst=[story instantiateViewControllerWithIdentifier:@"id"];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:Tabedfirst];
[self presentViewController: nc animated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShareArray" object:_selectedimgarray];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SharetitleArray" object:_newtile];
[[NSNotificationCenter defaultCenter] postNotificationName:@"sharevideooutputstring" object:_videooutputstring];
}];
When I do this very thing working good I am sending the data from share view to the tabbed view and I am printing it.
The problem is when I send the second time data from share viewcontroller to the tabbed view controller first data is deleting and the second passed data is replacing the first i.e. I have the 15 objects in an array, from share view controller I am passing array to the tabbed view controller now the array count is 16 and I am printing it, now again I am passing one more object from the share view to tabbed view the array count must increase to 17 but it 16 only.
In the App delegate add/make properties of your arrays like
@property (nonatomic, retain) NSMutableArray *array1;
In AppDelegate.m initiate all your properties
After that in the controller where you are storing the values add instance of AppDelegate as
In
- (void)viewDidLoad
{
[super viewDidLoad];
objAppDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
objAppDelegate.array1= _imagearray=[@[@"bootimages",@"fall-photography-in-hocking-hills", @"gift",@"hillimages",@"Mercedes-classe-S-W116_large_dettaglio_articolo",@"prinimages",@"resplendent",@"tnb4",@"Tomato-plant",@"Vole",@"waterimages",@"fall-photography-in-hocking-hills", @"gift",@"hillimages",@"Mercedes-classe-S-W116_large_dettaglio_articolo"]mutableCopy];
then
[objAppDelegate.array1 insertObject:[userInfo firstObject] atIndex:0];
The values are maintained and can be used anywhere in the whole project. If your number of objects keeps on increasing then you NSMutableDictionary and add as much key/value pairs as you like.