In my 'DictionaryTableViewController: UITableViewController' class I define the below variables:
var dataObj : [String: AnyObject]!
var letters : Int!
var currentSection : Int!;
var currentRow : Int!
In 'viewDidLoad' I have:
let jsonUrl = NSBundle.mainBundle().URLForResource("dictionary", withExtension: "json")
var data = NSData(contentsOfURL: jsonUrl!)
func dataReturn(object: [String: AnyObject]) {
dataObj = object
letters = object["collection"]!.count
}
do {
let object = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
if let dictionary = object as? [String: AnyObject] {
dataReturn(dictionary)
}
} catch {
// Handle Error
}
This is the basic structure of the JSON file that I am pulling in from NSBundle
{
"collection": [{
"letter": "A",
"words": [{
"word" : "Apple",
"definition" : "Tasty fruit"
}]
},{
"letter": "B",
"words": [{
"word" : "Banana",
"definition" : "Meh, not bad."
}]
},{
"letter": "C",
"words": [{
"word" : "Carrots",
"definition" : "hooock twooo!"
}]
}]
}
So now when I go style the tableView cell I believe that is what is causing this error:
Command failed due to signal: Segmentation fault: 11
- While emitting SIL for 'tableView' at /Users/me/Desktop/.../DictionaryTableViewController.swift:70:14
As a warning I am just getting this issue after updating to xcode 7.3. This issue was not present in 7.2
Line 70 from the where the error says to becoming from reads:
Line 70: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)
//let currentSelection = dataObj["collection"]![indexPath.section]["words"]!![indexPath.row]!
let currentSelection = dataObj["collection"]![indexPath.section]["words"]!![indexPath.row]!!!
cell.textLabel?.text = currentSelection["word"] as? String
cell.detailTextLabel?.text = currentSelection["definition"] as? String
return cell
}
Note: The commented out line in the above code was working correctly in xcode 7.2. Xcode7.3 gave me a syntax error (Ambiguous use of subscript). The code just below the commented out line are my changes that produce no syntax errors. Is this what is causing my issue? I am really at a loss here and can't seem to find an answer. Any help is appreciated!