I want to save an array of objects to disk as a plist file.
First, I convert an array of objects to an array of equivalent dictionaries. There are no problems with some properties, but some of them give errors. Now I am trying to get a url property error. (Commented lines are also problematic, but now I am not working.
HEre is the interface of the YOEvento class.
Array Conversion Code
// 1. Convert array of YoEvento in array of Dictionary to be able to save as plist NSMutableArray *tempArray = [NSMutableArray array]; for (YOEvento *evento in self.eventosFavouritesAppDel) { NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: evento.url, // evento.identificador, evento.nombre, evento.diaDeInicio, evento.diaDeFin, evento.entradilla, // evento.foto, // evento.localizacion, nil] forKeys:[NSArray arrayWithObjects: kURLElement, // kIdentificadorElement, kNombreElement, kDiaDeInicioElement, kDiaDeFinElement, kEntradillaElement, // kFotoElement, // kLocalizacionElement, nil]]; [tempArray addObject:dict]; } // 2. Convert the array to NSData NSString *errorDesc; NSData *data = [NSPropertyListSerialization dataFromPropertyList:tempArray format:NSPropertyListXMLFormat_v1_0 errorDescription:&errorDesc];
After the last commands, I get an error "invalid property list format" in errorDesc. The contents of the dictionary seem valid. Here is the runtime content log:
Printing description of dict: <CFBasicHash 0x5b99170 [0x1298400]>{type = immutable dict, count = 5, entries => 0 : <CFString 0xfd00 [0x1298400]>{contents = "entradilla"} = <CFString 0x5b99b10 [0x1298400]>{contents = "Festival Internacional de Cine de Gij\u00f3n M\u00e1s informaci\u00f3n en www.gijonfilmfestival.com "} 2 : <CFString 0xfcd0 [0x1298400]>{contents = "nombre"} = <CFString 0x5b99590 [0x1298400]>{contents = "49 FICXix\u00f3n - Festival Internacional de Cine de Gij\u00f3n"} 4 : <CFString 0xfcb0 [0x1298400]>{contents = "url"} = <CFURL 0x5b992f0 [0x1298400]>{type = 15, string = http:
source share