Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7190

SWIFT: Exception when sorting a single value "array"

$
0
0

Update, because the question was closed. I am aware of nil values. So let me phrase my questions a bit more concrete:

(1) Is the line number shown in the crash log the same number as I see in Xcode including comments and blank lines?

(2) Why would Xcode run my script and load a JSON file upon opening a project?

(3) Is there a standard code to cope with sorting a single value array? I guess I could do

guard sortedJsonResult = jsonResult!.highscoreRecord.sorted { $0.Date < $1.Date } else {sortedJsonResult = jsonResult!.highscoreRecord}

right?


When loading my project I get

IB Designables: Failed to render and update auto layout status for HighscoreViewController (6Ed-3Z-stE): The agent crashed

The crash report in the log folder shows

Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/me/Documents/xCode/1x1/ScoreTimeGraphView.swift, line 31

Line 31 (if comments and blank lines are counted) would be

let sortedJsonResult = jsonResult!.highscoreRecord.sorted  { $0.Date < $1.Date }

jsonResult currently has only a single record, so I assume the error is caused by $1.Date. However, I have never seen any exception handling for sorting single value arrays. And this is also strange because I would not assume Xcode to load the JSON file when only opening the project


Viewing all articles
Browse latest Browse all 7190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>