Making a log file in Xcode Application

Discussion in 'Mac Programming' started by arjit, Nov 20, 2009.

  1. arjit macrumors newbie

    Feb 20, 2009
    I am trying to make log file in for my application now when the program starts i need the file to deleted if it exits and appened in many times in the program how to solve this i FSCreateFileUnicode this but its not working.

    any help would be appreciated thanks
  2. chown33 macrumors 604

    Aug 9, 2009
    What error does FSCreateFileUnicode return when it doesn't work?
  3. arjit thread starter macrumors newbie

    Feb 20, 2009
    Actually it shows dup error whcih shows the file exits ... so there is function which could create the file when the program starts and keeps on appending it .

    thanks in advnace
  4. chown33 macrumors 604

    Aug 9, 2009
    That doesn't make sense.

    If the file exists, then there's no need to create it. Simply open it for writing and append your data.

    If the file doesn't exist, then create it before opening it.

    There are functions for opening existing files for writing. Read the FileManager docs. Look for FSOpenFork.

    You can also use the C standard I/O function fopen(), and it will handle creation, appending, etc. when given the right parameters.
  5. kainjow Moderator emeritus


    Jun 15, 2000
    Isn't CFLog private though?
  6. Catfish_Man macrumors 68030


    Sep 13, 2001
    Portland, OR

Share This Page