Sorry I should have been more specific.
I have an object that contains a bool and a ParseFile like this:
struct ProfilePicture: ParseObject, Identifiable, Decodable
{
// Mandatory properties
var ACL: ParseACL?
var createdAt: Date?
var originalData: Data?
var objectId: String?
var updatedAt: Date?
// Custom properties
var userProfilePicture: ParseFile?
var verified: Bool?
}
And I have a pointer in my user object like this:
struct User: ParseUser, ParseObject
{
// Mandatory properties
var ACL: ParseACL?
var authData: [String: [String: String]?]?
var createdAt: Date?
var email: String?
var emailVerified: Bool?
var originalData: Data?
var objectId: String?
var password: String?
var updatedAt: Date?
var username: String?
// Custom properties
var firstName: String?
var lastName: String?
var matchInfo: MatchInfo?
var profilePicture: ProfilePicture?
}
I learned from this post how to set the userProfilePicture field to nil using unset, but how to I go about assigning a new ProfilePicture object to the user field? I tried this code:
let imageData = unwrapImage.pngData()
let parseImageFile = ParseFile(data: imageData!)
var profilePicture = ProfilePicture()
profilePicture.verified = false
profilePicture.userProfilePicture = parseImageFile
profilePicture.save { _ in
var currentUser = User.current
currentUser?.profilePicture = profilePicture
currentUser?.save { _ in
User.current?.fetch(includeKeys: ["*"]) { result in
}
}
}
But it does not save the ProfilePicture object.