Application Support You don’t have permission to save the file

Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “data” in the folder “gamedata”." UserInfo={NSFilePath=file:///var/mobile/Containers/Data/Application/651354D9-30FF-4156-9D31-5F90D92D13C7/Library/Application%20Support/gamedata/data, NSUnderlyingError=0x14010cbf0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

do {
            try NSFileManager.defaultManager().createDirectoryAtPath(GameData.filePath, withIntermediateDirectories: true, attributes: nil)
        } catch {
            print(error)
        }

        NSKeyedArchiver.archiveRootObject(GameData.data!, toFile: GameData.filePath)
        print(GameData.filePath)

createDirectoryAtPath will say You don’t have permission

OK, so use URL:

let fileManager = NSFileManager.defaultManager()
        let appSupportPath:[NSURL] = fileManager.URLsForDirectory(.ApplicationSupportDirectory, inDomains: .UserDomainMask)
        let store:NSURL = appSupportPath.first!

        do {
            try NSFileManager.defaultManager().createDirectoryAtURL(store, withIntermediateDirectories: true, attributes: nil)
        } catch {
            print(error)
        }

        NSKeyedArchiver.archiveRootObject(GameData.data!, toFile: GameData.filePath)
        print(GameData.filePath)