Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6698323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:33:51+00:00 2026-05-26T06:33:51+00:00

I want to save to disk an array of objects as plist file .

  • 0

I want to save to disk an array of objects as plist file .

First I convert the array of objects into an array of equivalent dictionaries. With some properties there is no problem but some of then give errors. Now I’m trying to get the url property error. (The commented lines are also problematic but I’m not working on then now.

HEre is the interface of YOEvento class.

#import <MapKit/MapKit.h>

@interface YOEvento : NSObject

{
    NSURL *url; // <url>
    NSInteger identificador; // <identificador>
    NSString *nombre; // stores the <name> tag
    NSDate *diaDeInicio; // stores the tag <dia-de-inicio>
    NSDate *diaDeFin; // stores the tag <dia-de-fin>
    NSString *entradilla; // stores the tag <entradilla>
    NSURL *foto; // <foto>
    CLLocationCoordinate2D localizacion; // <localizacion>
    BOOL isFavourite;
}

@property (nonatomic, retain) NSURL *url;
@property NSInteger identificador;
@property (nonatomic, retain) NSString *nombre;
@property (nonatomic, retain) NSDate *diaDeInicio;
@property (nonatomic, retain) NSDate *diaDeFin;
@property (nonatomic, retain) NSString *entradilla;
@property (nonatomic, retain) NSURL *foto;
@property CLLocationCoordinate2D localizacion;
@property BOOL isFavourite;

@end

The code to convert the array

        // 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 instructions I get in errorDesc the error “property list invalid format”.
The contents of the dictionary seem to be valid. Here is a log of the contents in runtime:

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://www.gijon.es/eventos/show/18753-49-ficxixon-festival-internacional-de-cine-de-gijon, encoding = 134217984, base = (null)}
    5 : <CFString 0xfcf0 [0x1298400]>{contents = "dia-de-fin"} = 2011-11-26 22:59:00 +0000
    6 : <CFString 0xfce0 [0x1298400]>{contents = "dia-de-inicio"} = 2011-11-18 22:59:00 +0000
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:33:52+00:00Added an answer on May 26, 2026 at 6:33 am

    Property lists can only contain objects of a small number of classes: namely, NSString, NSDate, NSNumber, NSArray, NSDictionary, NSData. If you want to represent other types (such as NSURL) in a property list, you have to convert it to one of the permitted types first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to save my program's DataModel objects to a file, and be able
I want to save the objects I generated in a program. After restart the
I want to save and store simple mail objects via serializing, but I get
I want to save a matrix to a text file, so I can read
I want to save a remote img-file to my server, but I don't know
I want to save large amounts of text then display them (first in table
I want to save a .txt file in my iPhone app, but I want
I have an image on disk which is a jpg file . I want
I want to save a writableimage in Silverlight to disk. I found this tutorial
I want to save data to a file in my elisp program. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.