AZTableViewController | easy way to integrate pagination
kandi X-RAY | AZTableViewController Summary
kandi X-RAY | AZTableViewController Summary
Elegant and easy way to integrate pagination with dummy views
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AZTableViewController
AZTableViewController Key Features
AZTableViewController Examples and Code Snippets
Community Discussions
Trending Discussions on AZTableViewController
QUESTION
I'm trying to fetch data from web and trying paging using AZTableView library. I'm facing the above error. Here's my code
My Modal class
...ANSWER
Answered 2018-Feb-05 at 04:21Your completion handler for jobsNearByFetch
returns an array of JobsNearBy
, which you put into jobsArray
Then, you have a force cast of jobsArray
to JobsNearBy
, but it is an array, not a single instance of the object so the downcast fails and because it is a forced downcast your app crashes.
You could fix it by using as! [JobsNearBy]
, but it is better to change the signature of the completion closure to indicate that it returns [JobsNearBy]
instead of Any
; then you don't need to downcast anything:
You shouldn't use Any
when you can determine what the actual type is. Also, you shouldn't use NSDictionary
when working in Swift if you can avoid it. Also, avoid force downcasting and unwrapping whenever possible.
Stylistically the boolean success
parameter and a separate failure closure is a bit odd too; you would typically have a single closure that returns an optional Error
- If error is nil
then the operation was successful.
I would have:
func jobsNearByFetch(pageNumber: Int, completion:@escaping ( _ jobsNearByArray:[JobsNearBy]?, error:Error?) -> ()) {
This way you can use a single trailing closure.
You also need to look at your jobsNearByFetch
as there are some return paths that don't call a closure.
Finally, you should look at the Codeble
protocol as it can eliminate the JSON parsing code altogether.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install AZTableViewController
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page