NSFileManager: removing item

前端 未结 3 1976
没有蜡笔的小新
没有蜡笔的小新 2021-01-28 23:36

The problem is removing an item that´s been written using writeToFile: method, I cannot seem to remove it. I tried NSFileManager but I guess these are two different

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-29 00:21

    In this place

    result = [fileManager removeItemAtURL:destinationURL error:&removeError];
    NSLog(@"ERROR REMOVING OBJECT: %@",removeError);
    

    you log and do not check the result value. Is it really NO? You should check return value first, and then if it is NO, check the removeError.

    And also I prefer to write

    NSError * removeError = nil;
    

    when declarate it. May be removeError object contains some old information.

提交回复
热议问题