nssavepanel filename deprecated

Discussion in 'Mac Programming' started by john903, Sep 15, 2009.

  1. john903 macrumors member

    Joined:
    Apr 11, 2008
    #1
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Read the page and follow the links.

    Start on the page you posted.

    Read the deprecation warning. Notice the word "URL" in "Use URL instead." after the warning. It is a link. Click it.

    You are now at the URL method. Notice its return type: NSURL *. Notice the word "NSURL" is a link. Click it.

    You are now at the NSURL class reference. You can manually scroll around the page reading descriptions, or you can use Find to find the word "path" (a reasonable guess since the -filename method is described as returning a pathname). Eventually, you should stumble upon the -path method, which returns NSString*. Read its description.

    All the Cocoa documentation works like this. Many keywords, method names, and typenames are links. Clicking it takes you to the reference doc.
     
  3. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #3
    1. Some people don't care about spelling, but if your careless spelling changes the meaning of a sentence to the exact opposite, then you should figure out that you need a bit more careful.

    2. "Deprecated" means you shouldn't use it, not that can't use it. It will work fine in 10.6, and probably in 10.7, and disappear in 10.8. Lots of time.

    3. You are not supposed to obtain the filename, that's why it is deprecated. You are supposed to use URLRef for everything.
     
  4. john903 thread starter macrumors member

    Joined:
    Apr 11, 2008
    #4
    Yes, I know but might as well do it the correct way now! :)

    Yes, I have looked at the docs already and I cannot figure out how to do this. I'm sorry if I'm stupid.
     
  5. foidulus macrumors 6502a

    Joined:
    Jan 15, 2007
    #5
    Sort of off-topic, but I wish they would also provide links to structs and things like NS(U)Integer for us cocoa newbies.
     
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    Code:
    NSSavePanel *savePanel = [NSSavePanel savePanel];
    // setup save panel and run
    NSURL *fileURL = [savePanel URL];
    Now you have an NSURL object representing the file that was chosen in the save panel. If whatever API you are using after this doesn't work with NSURL objects, you can call path to get an NSString and use that instead:
    Code:
    NSString *filePath = [fileURL path];
     

Share This Page