-2

I am quite a beginner in iPhone programming so this might be a noob question but here it is:

I am making an app which draws a couple of paths on a Google map. The paths are quiet long and require a lot of coordinates as they have bends in them. I want to know if there is a way I could store the coordinates in a different file or class so i could call "make path" from the main implementation file and it would make the path from the coordinates that are stored in a coordinates.m file for example, or anything like that. I want to do this just so that the code is easier to read.

Thnaks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Balázs Vincze
  • 357
  • 1
  • 3
  • 14
  • 1
    The simple answer is, "Yes you can...good idea!" :) The more complicated part (if you want to do it well) involves understanding the model-view-controller concept. If you search for some information on MVC (especially the 'M' part), it should give you some good ways to design this. – Phillip Mills Jan 11 '15 at 15:42
  • I will definetly have a look in that, thank you! :) – Balázs Vincze Jan 11 '15 at 15:47
  • possible duplicate of [Passing Data between View Controllers](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – Hot Licks Jan 11 '15 at 19:22

1 Answers1

0

Look at subclassing NSObject to make your own custom class that could 'define' a map path. You could then build in a saveToFile: and loadFromFile: method. Then you can just choose a file format to save you data to. The easiest might be .dat files for which you use NSKeyedArchiver, this is good for small files. Or you could use a differnt format like .plist files.

Like @Phillip Mills said, it is important to understand the MVC design paradigm before designing any apple apps.

Rob Sanders
  • 5,197
  • 3
  • 31
  • 58