1 Reply
      Latest reply on Dec 3, 2016 6:07 AM by eskimo
      WatchDev2015 Level 1 Level 1 (0 points)

        Hello all:


        I have an app that tracks tennis shot stats on the Watch, writes those stats to an FMDB database, and then the user used to be able to check those stats on the phone. That was in watch OS1, and the watch wrote to a DB and then the phone read from that same DB. With the changes in OS2/3 the code used to determine the paths to the DB, which runs on both the Watch and Phone and used to return the same value, now produces different paths. I changed the code to use a Shared Instance in the phone app for the DB path and file creation, but the Path is still different when the code is called from the watch vs. the phone.


        Can anyone offer any assistance and/or make a suggestion for sharing data? I need the watch app to track the data and then write it out to the DB on the phone, and then at some later point in time when the user runs the app on the phone, the data needs to be accessible.


        Thanks for any and all input.


        the code:




            let identifier = "group.johnstraumann.ScoreItData"

            let sharedContainerURL: URL? = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: identifier)

            if let sharedContainerURL = sharedContainerURL


              let databasePath = sharedContainerURL.appendingPathComponent("scoreit_tennis.db")

              SharedData.gameData.databaseURL = databasePath

              SharedData.gameData.updateDatabasePath(databasePath.path as NSString!)



        When I run the Watch app the path I get is:



        and when I run the phone app the path I get is: