There is actually a plist dictionary (NSDictionary)

Swa.Plist

it is implemented through an array (fruit) (pictures, text), etc. , everything is shown everything is loaded through collectionView and displayed on the ViewController. After I check through the button and now I need to change the value of Boolean from false to True, well, in a princep, to give it the true value is no problem (fruit.correctText = true), but when you restart this cell, we have all the same values ​​false. The question is how to make it write the new value of Bool?

ps Two boolean parameters are connected and coordinated as optional (bool?) in order to avoid fatal and errors at this stage of the experiments. Thanks for attention.

    1 answer 1

    after the change it is necessary to write it all back to the file, something like this

    let plist = NSMutableDictionary(contentsOfFile: "file.plist") plist?.setObject(NSNumber(bool: true), forKey: "EditThis") plist?.writeToFile("file.plist", atomically: true) 

    objC

     NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile:@"file.plist"]; [plist setObject:[NSNumber numberWithBool:YES] forKey:@"EditThis"]; [plist writeToFile:@"file.plist" atomically:YES]; 
    • It's on Obj C and on Swift? - Alex Gr
    • already both (added in reply) - Max Mikheyenko
    • Yes, thanks, it looks like norms in meaning, but I can't figure out the result. NSMutableDictionary displays nil in the console and thus does not record anything. link and here the dictionary itself is implemented and the link is connected If you can help me figure it out. - Alex Gr
    • It's easier to see and compile all the code, if there is nothing secret there - Max Mikheyenko
    • Well, no matter how secretly)) where to throw better? - Alex Gr