Making a log file in Xcode Application

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

  1. macrumors newbie

    Joined:
    Feb 20, 2009
    #1
    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. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
  3. macrumors 603

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

    Joined:
    Feb 20, 2009
    #4
    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
     
  5. macrumors 603

    Joined:
    Aug 9, 2009
    #5
    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.

    http://developer.apple.com/mac/libr...ference/File_Manager/Reference/reference.html

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

    kainjow

    Joined:
    Jun 15, 2000
    #6
    Isn't CFLog private though?
     
  7. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR

Share This Page