Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connected to json. #143

Closed
RiverRaid84 opened this issue Mar 21, 2020 · 7 comments
Closed

Connected to json. #143

RiverRaid84 opened this issue Mar 21, 2020 · 7 comments

Comments

@RiverRaid84
Copy link

I have uploaded the json file to a server, and when I update it it show on the web its updated but it doesn't reflect the update on the app. It takes a very long time to reflect the update in simulator but never does when I run the app on a physical device unless I delete the app and re-run agin.

Anyway to fix this and reflect the updates to the json file when they happen?

Thanks

PS: Pull to refresh doesn't do anything for this issue, neither killing the app.

@urayoanm
Copy link

It looks like the cache is returning the same file to you. In my case I did this. At the end of the station JSON url put this:
let stationDataURL = "http://yoururl.com/json/stations.json?\(Int.random(in: 1...9999999))"

This would make your request think the URL is different at the end putting a number from 1 to 9999999.
Do not forget to put the ? at the end of the .json file or at the end of your URL.

To this have affect, you need to fire up the app when you change your json file.

@RiverRaid84
Copy link
Author

It looks like the cache is returning the same file to you. In my case I did this. At the end of the station JSON url put this:
let stationDataURL = "[http://yoururl.com/json/stations.json?(Int.random(in](http://yoururl.com/json/stations.json?%5C(Int.random(in): 1...9999999))"

This would make your request think the URL is different at the end putting a number from 1 to 9999999.
Do not forget to put the ? at the end of the .json file or at the end of your URL.

To this have affect, you need to fire up the app when you change your json file.

Worked like a charm. Thank you very much. Much appreciated.

@RiverRaid84
Copy link
Author

Is there away to get Pull to refresh to to update the stations? Currently after the fix by @urayoanm I have to kill the app to get the updated list of stations.

Thank you.

@urayoanm
Copy link

I think there is a function in the StationsViewController class to do that. Is called setupPullToRefresh()

@RiverRaid84
Copy link
Author

Pull to refresh itself is setup correctly and it finds json. But UI doesn't update unless I re-run from Xcode or kill the app.

@fethica
Copy link
Collaborator

fethica commented Mar 23, 2020

Hey @Egytalian

In DataManager.swift try to set sessionConfig (line 63) requestCachePolicy to:

sessionConfig.requestCachePolicy = .reloadIgnoringCacheData

Or:

sessionConfig.requestCachePolicy = .reloadIgnoringLocalAndRemoteCacheData

@RiverRaid84
Copy link
Author

@fethica Thank you so much. It works great. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants