Swift - How implementing different ViewController/Class using swipe gesture? - ios

I wonder how implementing two different ViewControllers and their own classes on the same page. Feed page both of them, and then I wanna pass them using left/right swipe gesture. But I don't know exactly how combining these pages together.
If someone explain as detailed It would be great.
Update
I have added Bridging header and your lines of codes, after editing new ViewControllers and identifier. But When I run and open this view, application stopped with below error.
All my views WishVC, TestVC1, TestVC2 are blank, there are no object.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

Related

Swift 2: App crashes during rotation

i have reloaded the view that contains table view. But when i keep on rotating the table view frequently the app crashes saying:
Terminating app due to uncaught exception 'NSGenericException', reason: '8 Collection <__NSArrayM: 0x7fdd5d460250> was mutated while being enumerated.'
I have implemented a simple table view with its delegates.
Can anyone suggest what actually this means.
looks like on rotate you are reloading the dataSource and while doing so your array is not fully populated and you are trying to change the array while its still have a reference somewhere else.

NSInternalInconsistencyException with UICollectionView

Recently, I have been assigned to deal with crash reports and I found that there are a lot of crash report that come from 'NSInternalInconsistencyException' that are originated from 'UICollectionView'. The 2 reasons that were common are
'Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items in section 0 when there are only 0 sections in the collection view'
I was not able to reproduce the crash. I'm sorry that I am not able to post the code or the full crash report, but I will try my best to briefly explain the situation.
I have a UIViewController that is holding a UICollectionView. The UIViewController acts as the dataSource and delegate for the UICollectionView. And the dataSource and delegate are assigned in the storyboard.
First, I thought that somehow the dataSource disappear somewhere, which would have cause the crash. So I tried to force the crash by setting dataSource = nil, but as expected it did not crash. I also found a solution here which says to check if dataSource in layoutAttributesForElementsInRect is equal to nil or deal with it accordingly. I tried to force dataSource = nil in there, but still can't reproduce the problem (
UICollectionView and Supplementary View crash)
Is it possible that somehow the UIViewController that acts as a dataSource for the UICollectionView died somehow so UICollectionView does not have the dataSource? But wouldn't this be the same as UICollectionView.dataSource = nil, which would not crash the app anyway?
Would it help if I separate UIViewController and UICollectionViewDataSource and then assign the dataSource in the viewDidLoad?
I would greatly appreciate it if someone could point me to the right direction in solving this problem.
Thanks
Edited: found a similar problem here iOS 9: UICollectionView dataSource is not set However, there is no solution yet.

*** Terminating app due to uncaught exception 'NSRangeException' in UITableView

I am using an UITableView for showing some data. Now when an user tap on a cell I appended a new cell just below the taped cell to show some more extra information. Everything is working fine. It's has two sections. Now if I tap on a cell of section 1 it's append a new cell as it should be. Then I do down scroll and the appended cell & it's parent cell is going out of the visible rect. And when I do up scroll it's shows back. No issue. But the problem is if I scroll up very fast it got crashed on the below line.
UITableViewCell *parentCell=[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:[indexPath row]-1 inSection:[indexPath section]]];
In console it shows
***** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
If I scroll slowly it's works fine only got crashed if I do it fast. And very strange is if I do the same for section 0. It's not got crashed. Guys please help me. I already spent lot of time to figure out this but fail. Thanks in advance.
The -1 in [indexPath row]-1 is almost certainly wrong; the row is zero-based and so are your data structures (well they are if you keep your data in an NSMutableArray or somesuch).
However this doesn't tally with the exception "5 is greater than 4", so I'm assuming you are making "+1" and "-1" adjustments here and there which is breaking your app.
I'm pretty sure you don't have to make these adjustments at all, however I cannot tell for certain without seeing more code.

What is the best implementation of an infinitescroll to a collectionview? Like Pinterest which at the end of the scroll fetches the data

I've done it but I'm not quite satisfied with it because I get this error when I try to scroll fast. * Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSSetM: 0x14e85a50> was mutated while being enumerated.'
There's some apple sample code for scroll views, should give you an idea about how to go about this:
https://developer.apple.com/library/ios/samplecode/StreetScroller/Introduction/Intro.html

Empty Array Error

I have a UITableView that I populate with data from an array. It displays available networks, and populates the table view based upon its findings. I try and recall reloadData to the table view in one of my methods, but for some odd reason the app crashed with the error:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
To recreate the issue, I first scan for the networks. There are 2 available and they're just chilling. I connect to one, then I go to disconnect. I click disconnect, fire a reloadData to refresh the table view, then that is when the app crashes with the error. If I delete the reloadData call, it doesn't crash and goes along fine. This ties in with another question that I have about refreshing the table view to not display the network unless it's connected to it, I thought reloadData would work but it hates me. I'm at a loss of what to do to fix this bug and refresh properly.

Resources