# Saving a mapview in iOS

**URL:** <https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741>\
**Category:** iOS\
**Created:** [March 23, 2016, 2:37am UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741 "2016-03-23T02:37:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alakh](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alakh/32/10920_2.png) [@alakh](https://forums.kodeco.com/u/alakh)\
**Post date:** [March 23, 2016, 2:37am UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741/1 "2016-03-23T02:37:35Z")

</div>

Hi, I am currently trying to build a running application where I want user to have a look at their running journey on a map for which I would to save it. I have come across an option of MKMapSnapShot but failing to find any example of how to implement it. If someone has an idea and they are willing to share, it will be great! Thanks.

---

<div class="post-metadata">

**Author:** ![micazeve](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/micazeve/32/103912_2.png) [@micazeve](https://forums.kodeco.com/u/micazeve)\
**Post date:** [March 24, 2016, 12:42pm UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741/2 "2016-03-24T12:42:06Z")

</div>

Hi ! Did you look at these tutorial in Ray Wenderlich :  
[https://www.raywenderlich.com/73984/make-app-like-runkeeper-part-1](https://www.raywenderlich.com/73984/make-app-like-runkeeper-part-1)  
[raywenderlich.com/97945/make-app-like-runkeeper-swift-part-2](http://raywenderlich.com/97945/make-app-like-runkeeper-swift-part-2)

I followed the original tutorial by Matt Luedke in Objective-C and it was great, this update in Swift by Zouhair Mahieddine looks the same according to the screenshot.  
Once the running record is made, you can compute the region of the map needed to display it entirely using the mapRegion() function from part1 of this tutorial.  
Then, you can save a screenshot of your map using MKMapSnapShot in order to be able to load it without internet connection.  
This tutorial from NSHipster show how to use it : [MKTileOverlay,MKMapSnapshotter &MKDirections - NSHipster](http://nshipster.com/mktileoverlay-mkmapsnapshotter-mkdirections/)

---

<div class="post-metadata">

**Author:** ![narrativium](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/narrativium/32/110937_2.png) [@narrativium](https://forums.kodeco.com/u/narrativium)\
**Post date:** [March 25, 2016, 11:52pm UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741/4 "2016-03-25T23:52:42Z")

</div>

If you don’t ask, you won’t find out if anyone can help. What’s making you stuck?

---

<div class="post-metadata">

**Author:** ![micazeve](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/micazeve/32/103912_2.png) [@micazeve](https://forums.kodeco.com/u/micazeve)\
**Post date:** [March 29, 2016, 6:16am UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741/5 "2016-03-29T06:16:20Z")

</div>

Sorry for the delay, Easter Weekend in family ^^  
Where are you actually stuck ? I followed the Objective-C version of this tutorial and it went fine, maybe I’ll remember it 😉

---

<div class="post-metadata">

**Author:** ![alakh](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alakh/32/10920_2.png) [@alakh](https://forums.kodeco.com/u/alakh)\
**Post date:** [March 30, 2016, 5:39am UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741/6 "2016-03-30T05:39:09Z")

</div>

Hi, Thank you for coming back and I hope you had a good Easter weekend! Earlier question was regarding core data but after reading and trying bit of realm I am finding it comparatively a lot easier than Core data.  
I am currently trying to figure out this:  
a) I have a table view with dynamic cells where a new cell is created at midnight which is working fine. 🙂  
b) Tapping on cell leads to a new screen with static cells storing fitness data which is recorded till midnight as well and then gets refreshed to 0.

But currently, when a new cell is created earlier data is washed out ☹ . I understand that I have to save them, but do I have store them against date and fetch them back when user taps on cell or is there any better way?

---

<div class="post-metadata">

**Author:** ![micazeve](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/micazeve/32/103912_2.png) [@micazeve](https://forums.kodeco.com/u/micazeve)\
**Post date:** [March 30, 2016, 11:49am UTC](https://forums.kodeco.com/t/saving-a-mapview-in-ios/10741/7 "2016-03-30T11:49:28Z")

</div>

Ok so if I understand correctly, you have `UITableViewController` objects (or `UIViewController` with tableview in it), and the issue appears when a new cell is created for the first one ?

> Tapping on cell leads to a new screen with static cells storing fitness data which is recorded till midnight as well **and then gets refreshed to 0**.

I didn’t understand the part highlighted, what to you mean by refreshed to 0 ? For the tableview or for the cell ?

* * *

You should add the code you use when you create a cell if you want further help, because we can’t help you otherwise.
