Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 20, 2009, 06:15 AM   #1
arjit
macrumors newbie
 
Join Date: Feb 2009
Making a log file in Xcode Application

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
arjit is offline   0 Reply With Quote
Old Nov 20, 2009, 10:55 AM   #2
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
Why not use the system log via CFLog() or Apple System Logger (http://developer.apple.com/mac/libra...3/asl.3.html)?
Catfish_Man is offline   0 Reply With Quote
Old Nov 20, 2009, 01:55 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by arjit View Post
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.
What error does FSCreateFileUnicode return when it doesn't work?
chown33 is offline   0 Reply With Quote
Old Nov 22, 2009, 11:14 PM   #4
arjit
Thread Starter
macrumors newbie
 
Join Date: Feb 2009
Quote:
Originally Posted by chown33 View Post
What error does FSCreateFileUnicode return when it doesn't work?
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
arjit is offline   0 Reply With Quote
Old Nov 22, 2009, 11:52 PM   #5
chown33
macrumors 603
 
Join Date: Aug 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.

http://developer.apple.com/mac/libra...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.

Last edited by chown33; Nov 22, 2009 at 11:59 PM.
chown33 is offline   0 Reply With Quote
Old Nov 23, 2009, 12:56 PM   #6
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by Catfish_Man View Post
Why not use the system log via CFLog()
Isn't CFLog private though?
kainjow is offline   0 Reply With Quote
Old Nov 23, 2009, 06:04 PM   #7
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
err, s/CFLog/NSLog then.
Catfish_Man is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Create finished application? Xcode 5? mark79658 Mac Programming 1 Mar 17, 2014 05:49 AM
making backspace button on Xcode abcdefg12345 Mac Programming 3 Oct 15, 2013 08:31 PM
Console.log file in HD? kmpoboy2 OS X 10.8 Mountain Lion 4 Jan 20, 2013 02:55 PM
Making AI or PDF file from any GIMP file extensions without loss of quality? twiggy0 Design and Graphics 6 Aug 29, 2012 11:25 PM
Making a package of all the application MitsakiM Mac Programming 0 Jul 8, 2012 12:31 PM

Forum Jump

All times are GMT -5. The time now is 08:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC