简化字典(xcode 永远保持索引) [英] Simplify dictionary (xcode keeps indexing forever)

查看:28
本文介绍了简化字典(xcode 永远保持索引)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我遇到了一个错误,xcode 开始永远索引我的文件,使用所有处理器时间.我用谷歌搜索了这个问题,并设法理解以下代码导致了这个错误:

So I've encountered a bug, where xcode starts indexing my files forever, using all the processor time. I googled this problem and managed to understand that the following code is causing this bug:

    private struct Database {

    let db = [
        "oasis" : [
            "id" : "oasis",
            "sector_id" : "oasis",
            "name" : "Oasis",
            "type" : "planet",
            "image" : "planet_oasis",
            "xPos" : 170,
            "yPos" : 10,
            "spaceport" : true
        ],
        "oasis_hub" : [
            "id" : "oasis_hub",
            "sector_id" : "oasis",
            "name" : "Oasis Hub",
            "type" : "station",
            "image" : "station_oasis_hub",
            "xPos" : 30,
            "yPos" : 70,
            "spaceport" : true
        ],
        "oasis_exit" : [
            "id" : "oasis_exit",
            "sector_id" : "oasis",
            "name" : "Oasis sector exit",
            "type" : "exit",
            "image" : "planet_oasis",
            "xPos" : -350,
            "yPos" : 0,
            "spaceport" : false
        ]
    ]
}

我试图将此语句分成几行,但到目前为止还没有运气.我每次都收到需要声明"的错误.可能是因为我做错了什么,因为我是个菜鸟.

I am trying to split this statement into several lines, but no luck so far. I keep getting "statement required" errors every time. Probably because I am doing something wrong since I am a total noob.

我尝试过这样的事情:

var db: Array<Dictionary<String, NSObject>> = Array<Dictionary<String, NSObject>>()
db.append(["oasis" : ["name" : "oasis"]])

它在操场上有效,但在我的项目中失败了.因此,任何帮助将不胜感激.

It worked in the playground, but failed to work in my project. So any help will be appreciated.

推荐答案

找到了:

    let db:[String:[String:AnyObject]] = [

将解决问题.

这篇关于简化字典(xcode 永远保持索引)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆