Question: I have an array of my own class:

```
var listofmyclasses = [MyClass]()

```

in MyClass I have implemented:

```
 - func encodeWithCoder(aCoder: NSCoder!)
 - init (coder aDecoder: NSCoder!)

```

I am writing an XML File with the content of my array and this works fine:

```
         let plistpath = directories[0].stringByAppendingPathComponent("BookmarkArray.plist")
         let archivedData = NSMutableData()
         let archiver = NSKeyedArchiver(forWritingWithMutableData: archivedData)
         archiver.outputFormat = NSPropertyListFormat.XMLFormat_v1_0
         archiver.encodeObject(listofbookmarks)
         archiver.finishEncoding()
         archivedData.writeToFile(plistpath, atomically: true)

```

The File is saved in XML format. Great !

Now the question:

How to read the content of the XML back to a new array of MyClass ?:

```
var newArray:[MyClass]=getContent(plistpath);

```

What I tried so far:

```
var archivedData2:NSMutableData = NSMutableData(contentsOfFile: plistpath)!;
let listofmyclasses2 = NSKeyedUnarchiver.unarchiveObjectWithData(archivedData2);

```

but listofmyclasses2 is nil.

Answer: 
Try this to read back the file:

```
    let dat : NSData = NSData.dataWithContentsOfMappedFile(plistpath) as NSData
    let unarchiver = NSKeyedUnarchiver(forReadingWithData: dat)
    let read_bookmarks = unarchiver.decodeObject() as [MyClass]
    unarchiver.finishDecoding()

```

(Of course you certainly want to use better error checking :-) )
The class `NSPropertyListSerialization` can decode all sorts of plist encodings like `NSPropertyListXMLFormat_v1_0`

```
NSError* error;
NSData* data = [NSData dataWithContentsOfURL:yourURL options:NSDataReadingMappedIfSafe error:&error];
NSDictionary* dict = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable error:&error];

```