vendredi 31 octobre 2014

Issues with adding new array in update


Vote count:

0




The update for my app is now ready, however I have noticed that updating directly from the version of my app that is on the app store, to the new version that I am working on in Xcode seems to crash my app.


Basically, I added a new array that stores data for notes which was not present in previous versions and this is stored in NSUserDefaults (Not ideal, I know, but I would rather keep it this way for now)


When I go into the table view tab of my app, it crashes at this line:



cell.notesLabel.text = (notes.objectAtIndex(indexPath.row)) as? String


The error just states - "Thread 1: breakpoint 1.1" as soon as the table view tab is tapped.


I was discussing this with someone else and they suggested that I need to check for the existence of the array in the defaults and create and synchronise it if it is missing.


I'm not entirely sure how I would go about this, but I have tried changing my code from this:



if var tempNotes: NSArray = NSUserDefaults.standardUserDefaults().arrayForKey("notes") {
notes = tempNotes.mutableCopy() as NSMutableArray
}


To this:



if NSUserDefaults.standardUserDefaults().arrayForKey("notes") != nil {
var tempNotes: NSArray = NSUserDefaults.standardUserDefaults().arrayForKey("notes")!
notes = tempNotes.mutableCopy() as NSMutableArray
}


However it doesn't seem to have made a difference. That code is in viewWillAppear() by the way.


Any ideas?



asked 49 secs ago







Issues with adding new array in update

Aucun commentaire:

Enregistrer un commentaire