Deleting / setting a pointer to nil

Hi, I need help trying to understand if I’m doing something wrong here. Whatever I’ve tried, I can’t seem to remove a pointer from my object and set it to nil.

  func removeProfilePhoto(for userProfile: UserProfile) async throws -> UserProfile? {
    var workingProfile = userProfile
    workingProfile.photo = nil
    let savedProfile = try await workingProfile.save()
    return savedProfile
  }

photo is a pointer to another object

Screen Shot 2021-11-06 at 1.19.33 AM

and every time I run this function, I check the dashboard but alas, the photo pointer is still there.

is there a special way to remove pointers from an object? I’ve tried googling but I nothing.

thanks in advance.

The reason why setting the value to nil doesn’t work is here:

Follow the procedure here to set a property to nil. Basically, you use ParseOperation to unset the property:

func removeProfilePhoto(for userProfile: UserProfile) async throws -> UserProfile? {
    let operations = userProfile.operation
       .unset(("photo", \.photo))
    return try await operations.save()
}
1 Like

ha.

The one place I forgot to check was the repo issues lol.

Thank you.

It is the docs too:

JS Guide

API Documentation:

This question was about the Swift SDK, the JS docs won’t help as they are for a different language.