How to switch back to a view controller without losing data
I have an iCarousel view, which for those of you who don't know what it
is, works a lot like UITableView or UICollectionView. If you'd like, we
can pretend that I'm using one of those.
Anyways, my iCarousel has a bunch of items in it already. They're defined
in a global NSMutableArray by the name of "items". My problem is when I
switch views for a minute away from the carousel, when i switch back, the
items are gone. I believe this is because when i switch views, the
carousel is deallocated or the reference is lost. When i try to reload it,
i use this code:
self.carousel = [[iCarouselExampleViewController alloc]
initWithNibName:@"iCarouselExampleViewController" bundle:nil];
[self presentViewController:self.carousel animated:YES completion:nil];
[self.carousel.carousel reloadData];
This code brings me to an empty carousel. I assume this is because, as
aforementioned, i lost the reference to the view and i had to reallocate
it with the initWithNibName call. Anyways, how do i get around that? I
dont want to lose the data that was in the class. any suggestions? And how
would i go about switching back to a UITableView from a different view
controller in the first place?
No comments:
Post a Comment