Answer the question
In order to leave comments, you need to log in
How to fix '__NSArrayI' (0x1084ecdd8) to 'NSMutableArray' (0x1084ecea0) error in swift 3?
Hello!
I download an archive of images from the Internet and archive:
recipe.imageRecipe = NSKeyedArchiver.archivedData(withRootObject: CDataArray) as NSData
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MainTableViewCell
let myRecipe = recipe[indexPath.row]
let img = NSKeyedUnarchiver.unarchiveObject(with: myRecipe.imageRecipe! as Data) as! NSMutableArray
cell.nameRecipe.text = myRecipe.nameRecipe
cell.imageRecipe.image = UIImage(data: img[0] as! Data)
return cell
}
var newImages: [NSData] = []
override func viewDidLoad() {
super.viewDidLoad()
let images = NSKeyedUnarchiver.unarchiveObject(with: self.recipe.imageRecipe! as Data)
newImages = images as! [NSData]
@IBAction func saveEditRecipe() {
let CDataArray = newImages as! NSMutableArray
if let recipe = recipe {
if recipe.value(forKey: "nameRecipe") != nil {
recipe.setValue(textEditName.text, forKey: "nameRecipe")
}
if recipe.value(forKey: "descriptionRecipe") != nil {
recipe.setValue(textEditDescription.text, forKey: "descriptionRecipe")
}
if recipe.value(forKey: "imageRecipe") != nil {
recipe.setValue(NSKeyedArchiver.archivedData(withRootObject: CDataArray), forKey: "imageRecipe")
}
} else {
print("unable to fetch or create recipe")
}
(UIApplication.shared.delegate as! AppDelegate).saveContext()
self.goToListOfRecepies()
}
let img = NSKeyedUnarchiver.unarchiveObject(with: myRecipe.imageRecipe! as Data) as! NSMutableArray
Answer the question
In order to leave comments, you need to log in
let img = NSKeyedUnarchiver.unarchiveObject(with: myRecipe.imageRecipe! as Data) as! NSArray
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question