NSFileManager may not respond to removeFileAtPath:handler:

Discussion in 'iOS Development' started by jbonedev, Jul 1, 2009.

  1. jbonedev

    jbonedev New Member

    Joined:
    May 24, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    I'm seeing this warning with the version of Xcode included with the 3.0 SDK.

    Using the same code, I don't see this with previous versions of Xcode, nor do I see it building with the toolchain on linux.

    My code makes other NSFileManager calls and those do not generate any warnings about function signatures.

    The removeFileAtPath:handler: call works fine at runtime.

    What is wrong here?
  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    What's the warning?
  3. jbonedev

    jbonedev New Member

    Joined:
    May 24, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    It's in the subject:
    Code:
    warning: 'NSFileManager' may not respond to '-removeFileAtPath:handler:'
    
    The line is:
    Code:
            [fileManager removeFileAtPath: delPath handler: nil];
    
    I've also tried casting nil as id like:
    [fileManager removeFileAtPath: delPath handler: (id)nil];
  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Sorry! I'll take a look at it.
    ------------------double post merged------------------
    Well it seems it's no longer a NSFileManager method from what I can gather.

    I did see
    Code:
     removeItemAtPath: error:
    try that?

    I haven't used NSFileManager before, but I take it this is what is wrong.
  5. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    That is what you use.
    Code:
    NSFileManager * fileManager = [NSFileManager defaultManager];
    if([fileManager fileExistsAtPath:path]) {
    	[fileManager removeItemAtPath:path error:nil];
    }
    
  6. jbonedev

    jbonedev New Member

    Joined:
    May 24, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    That seems to work, thanks chicken.

    Not sure where I found that old API, or why it has been working at runtime for me all this time. (Guess they remove it from the header but it still links.) I would have at least expected some deprecated warning moving up such a minor version of Xcode.
    ------------------double post merged------------------
    EDIT and thanks Stephen 4 too.
  7. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Xcode 3.2 (Snow Leopard) gives you a deprecated warning. It's nice

    Please Register or Log in to view images

    .

Share This Page