我正在使用Parse進行數據存儲。我創建自己的遊戲查詢打開得分這在回調返回數組是這樣的:如何將結果的NSArray迭代到單獨的數組中
(
"<GameTurnScore:ipPd3tKRc1:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 1;\n TurnDifficulty = 0;\n TurnNumber = 1;\n TurnScore = 500;\n UserRef = \"<PFUser:e3Wyo4JaKC>\";\n}",
"<GameTurnScore:AendjA9Yzq:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 6;\n TurnDifficulty = 1;\n TurnNumber = 2;\n TurnScore = 48;\n UserRef = \"<PFUser:UgkZDtDsVC>\";\n}",
"<GameTurnScore:ZTNmSkGae1:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 8;\n TurnDifficulty = 2;\n TurnNumber = 3;\n TurnScore = 60;\n UserRef = \"<PFUser:e3Wyo4JaKC>\";\n}",
"<GameTurnScore:8QbcznSa1u:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 3;\n TurnDifficulty = 1;\n TurnNumber = 4;\n TurnScore = 99;\n UserRef = \"<PFUser:UgkZDtDsVC>\";\n}",
"<GameTurnScore:Mj6LmdE5LY:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 8;\n TurnDifficulty = 0;\n TurnNumber = 5;\n TurnScore = 60;\n UserRef = \"<PFUser:e3Wyo4JaKC>\";\n}",
"<GameTurnScore:qeDWt7KFK2:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 12;\n TurnDifficulty = 1;\n TurnNumber = 6;\n TurnScore = 24;\n UserRef = \"<PFUser:UgkZDtDsVC>\";\n}",
"<GameTurnScore:RMRYi9fkUu:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 1;\n TurnDifficulty = 2;\n TurnNumber = 7;\n TurnScore = 500;\n UserRef = \"<PFUser:e3Wyo4JaKC>\";\n}",
"<GameTurnScore:Fd78iI8NGo:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 6;\n TurnDifficulty = 1;\n TurnNumber = 8;\n TurnScore = 48;\n UserRef = \"<PFUser:UgkZDtDsVC>\";\n}",
"<GameTurnScore:qioVUqmbEB:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 1;\n TurnDifficulty = 2;\n TurnNumber = 9;\n TurnScore = 500;\n UserRef = \"<PFUser:e3Wyo4JaKC>\";\n}",
"<GameTurnScore:iFLS39GqLM:(null)> {\n GameRef = \"<Game:jGBok5ZiXM>\";\n TotalGuesses = 1;\n TurnDifficulty = 1;\n TurnNumber = 10;\n TurnScore = 300;\n UserRef = \"<PFUser:UgkZDtDsVC>\";\n}"
)
然後我需要這些分數分成兩個獨立的數組。目前我基於用戶分開,但我想根據TurnNumber分開它們。
我不確定的具體部分是如果轉彎號不存在,則將一個emtpy索引或[NSNull null]
插入索引。
例如,我有兩個新的NSArrays
調用scoreBlock1
和scoreBlock2
。如果缺少第3輪,我想在scoreBlock1
以下。
turnNumber1
NSNull空
turnNumber5
turnNumber7
turnNumber9
什麼是迭代結果數組實現這一目標的最佳方式是什麼?
空值的存在,爲什麼你要到位失蹤圈空值?似乎只是讓他們失蹤會更容易處理。另外,你如何「知道」缺少一個轉身? – CrimsonChris
謝謝,我想原因是我知道每個索引中有一個對象。如果我只是添加任何轉到新數組我如何檢查索引中是否有對象? – StuartM