Howto create a UITableview and load more?









up vote
-2
down vote

favorite












How do I create a table view and load more using a Swift UITableview?



// my class list

var news = [NewsElement]()





// for end bottom list

override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)

if scrollView == tableView

if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)



if !listNews.isLoadingFooterShowing()

self.loadMore()













// load more

func loadMore()



self.offset = String(Int(offset)! + 10)

self.getJsonNews(type:"newest", offset: offset)

self.listNews.showLoadingFooter()

// my problem i caont get news list and append last list

but for me reload data no append

self.news.insert(contentsOf: news + news, at: news.count)



DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.listNews.hideLoadingFooter()













// my method for load api

func getJsonNews(type:String , offset:String)

let parameters = [

"limit":"10",

"offset":offset,

"type":type

]

let parametersH:HTTPHeaders = [

"Authorization":"Basic ==",

"x-api-key":"mykeyg154658746546546544s8ck8" ,

]

Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in



print(response.result)

switch response.result

case .success:

guard let data = response.data else return

do



let json = JSONDecoder()

let decode = try json.decode(News.self, from: data)

self.news = decode

DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.viewIndicator.alpha = 0

self.loadIndicator.alpha = 0

self.listNews.hideLoader()





catch let err

print(err)





case .failure(let error):

print(error)















share|improve this question









New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • post your cellRowForAt
    – Augusto
    Nov 10 at 14:54














up vote
-2
down vote

favorite












How do I create a table view and load more using a Swift UITableview?



// my class list

var news = [NewsElement]()





// for end bottom list

override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)

if scrollView == tableView

if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)



if !listNews.isLoadingFooterShowing()

self.loadMore()













// load more

func loadMore()



self.offset = String(Int(offset)! + 10)

self.getJsonNews(type:"newest", offset: offset)

self.listNews.showLoadingFooter()

// my problem i caont get news list and append last list

but for me reload data no append

self.news.insert(contentsOf: news + news, at: news.count)



DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.listNews.hideLoadingFooter()













// my method for load api

func getJsonNews(type:String , offset:String)

let parameters = [

"limit":"10",

"offset":offset,

"type":type

]

let parametersH:HTTPHeaders = [

"Authorization":"Basic ==",

"x-api-key":"mykeyg154658746546546544s8ck8" ,

]

Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in



print(response.result)

switch response.result

case .success:

guard let data = response.data else return

do



let json = JSONDecoder()

let decode = try json.decode(News.self, from: data)

self.news = decode

DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.viewIndicator.alpha = 0

self.loadIndicator.alpha = 0

self.listNews.hideLoader()





catch let err

print(err)





case .failure(let error):

print(error)















share|improve this question









New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • post your cellRowForAt
    – Augusto
    Nov 10 at 14:54












up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











How do I create a table view and load more using a Swift UITableview?



// my class list

var news = [NewsElement]()





// for end bottom list

override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)

if scrollView == tableView

if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)



if !listNews.isLoadingFooterShowing()

self.loadMore()













// load more

func loadMore()



self.offset = String(Int(offset)! + 10)

self.getJsonNews(type:"newest", offset: offset)

self.listNews.showLoadingFooter()

// my problem i caont get news list and append last list

but for me reload data no append

self.news.insert(contentsOf: news + news, at: news.count)



DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.listNews.hideLoadingFooter()













// my method for load api

func getJsonNews(type:String , offset:String)

let parameters = [

"limit":"10",

"offset":offset,

"type":type

]

let parametersH:HTTPHeaders = [

"Authorization":"Basic ==",

"x-api-key":"mykeyg154658746546546544s8ck8" ,

]

Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in



print(response.result)

switch response.result

case .success:

guard let data = response.data else return

do



let json = JSONDecoder()

let decode = try json.decode(News.self, from: data)

self.news = decode

DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.viewIndicator.alpha = 0

self.loadIndicator.alpha = 0

self.listNews.hideLoader()





catch let err

print(err)





case .failure(let error):

print(error)















share|improve this question









New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











How do I create a table view and load more using a Swift UITableview?



// my class list

var news = [NewsElement]()





// for end bottom list

override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)

if scrollView == tableView

if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)



if !listNews.isLoadingFooterShowing()

self.loadMore()













// load more

func loadMore()



self.offset = String(Int(offset)! + 10)

self.getJsonNews(type:"newest", offset: offset)

self.listNews.showLoadingFooter()

// my problem i caont get news list and append last list

but for me reload data no append

self.news.insert(contentsOf: news + news, at: news.count)



DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.listNews.hideLoadingFooter()













// my method for load api

func getJsonNews(type:String , offset:String)

let parameters = [

"limit":"10",

"offset":offset,

"type":type

]

let parametersH:HTTPHeaders = [

"Authorization":"Basic ==",

"x-api-key":"mykeyg154658746546546544s8ck8" ,

]

Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in



print(response.result)

switch response.result

case .success:

guard let data = response.data else return

do



let json = JSONDecoder()

let decode = try json.decode(News.self, from: data)

self.news = decode

DispatchQueue.global().async

DispatchQueue.main.sync

self.listNews.reloadData()

self.viewIndicator.alpha = 0

self.loadIndicator.alpha = 0

self.listNews.hideLoader()





catch let err

print(err)





case .failure(let error):

print(error)












ios arrays swift pagination tableview






share|improve this question









New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 10 at 14:49









Graham

3,296113558




3,296113558






New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 12:04









Mohammad Akbari

1




1




New contributor




Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • post your cellRowForAt
    – Augusto
    Nov 10 at 14:54
















  • post your cellRowForAt
    – Augusto
    Nov 10 at 14:54















post your cellRowForAt
– Augusto
Nov 10 at 14:54




post your cellRowForAt
– Augusto
Nov 10 at 14:54

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238757%2fhowto-create-a-uitableview-and-load-more%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.












Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.











Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238757%2fhowto-create-a-uitableview-and-load-more%23new-answer', 'question_page');

);

Post as a guest














































































Popular posts from this blog

27

Top Tejano songwriter Luis Silva dead of heart attack at 64

Category:Rhetoric