removeItem(_:named:fromDirectory:replyHandler:)
Removes an existing item from a given directory.
Declaration
func removeItem(_ item: FSItem, named name: FSFileName, fromDirectory directory: FSItem, replyHandler reply: @escaping @Sendable ((any Error)?) -> Void)func removeItem(_ item: FSItem, named name: FSFileName, fromDirectory directory: FSItem) async throwsParameters
- item:
The item to remove.
- name:
The name of the item to remove.
- directory:
The directory from which to remove the item.
- reply:
A block or closure to indicate success or failure. If removal fails, pass an error as the one parameter to the reply handler. If removal succeeds, pass
nil. For anasyncSwift implementation, there’s no reply handler; simply throw an error or return normally.
Discussion
Don’t actually remove the item object itself in your implementation; instead, only remove the given item name from the given directory. Remove and deallocate the item in reclaimItem(_:replyHandler:).