NSCFType keeps occurring, something is not being released?
- by user1493543
I'm attempting to delete files from the documents directory using a tableview/array combination.
For some reason, my NSString pointing to the Documents directory path is being converted to a NSCFType (which after some research, I understand is happening because a variable is not being released). Because of this, the application crashes at the line
NSString *lastPath = [documentsDirectory stringByAppendingPathComponent:temp];
claiming that NSCFType cannot recognize the method stringByAppendingPathComponent.
I would appreciate if someone could help me out (I hope I have explained this clearly enough).
- (void) tableView: (UITableView *) tableView
commitEditingStyle: (UITableViewCellEditingStyle) editingStyle
forRowAtIndexPath: (NSIndexPath *) indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSString *temp = [directoryContent objectAtIndex:indexPath.row];
NSLog(temp);
NSString *lastPath = [documentsDirectory stringByAppendingPathComponent:temp];
[[NSFileManager defaultManager] removeItemAtPath:lastPath error:nil];
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
directoryContent = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil] retain];
//tableview handling below
}