如何保存 NSMutableArray 来解析?

How to save NSMutableArray to parse?

我有一个名为 thePlaylistNSMutableArray,它包含 MPMediaCollection 的列表。我试图将其保存以进行解析,但该列保留 empty(undefined),并且解析时列的类型为数组。我怎样才能正确地做到这一点?

这是我的代码:

let user = PFUser.currentUser()

var thePlaylistData: NSData = NSKeyedArchiver.archivedDataWithRootObject(thePlaylist)

user?.setObject(thePlaylistData, forKey: "userPlaylist")

如有任何意见或建议,我们将不胜感激。

From Parse Documentation:

We do not recommend storing large pieces of binary data like images or documents using NSData fields on PFObject. PFObjects should not exceed 128 kilobytes in size. To store more, we recommend you use PFFile. See the guide section for more details.

您可以使用 PFFile:

 var thePlaylistData: NSData = NSKeyedArchiver.archivedDataWithRootObject(thePlaylist)
 var music= PFObject(className:"Music")
 music["userPlaylist"] = thePlaylistData
 jobApplication.saveInBackground()