Using NSTextField to save text into cutom format at a temp location

Discussion in 'Mac Programming' started by SirFurtWiggle, Apr 23, 2014.

  1. SirFurtWiggle macrumors newbie

    Apr 23, 2014
    I tried asking this question at StackOverflow but they were a bit cold. So I am trying my luck here. I am a bit new to coca programming and I Ia m detailing my problem here:

    I want to save a the text entered into the text field of a cocoa app into a custom format(CPELX LP format which ends in .lp) The image attached provides somewhat clearer information. I am trying to create a program similar to the one in the image.
    When the button optimize is pressed, the text entered into the text field should be saved as, say example.lp at a temporary location and then the app reads the example.lp from that temporary location and solves it. Could anyone tell me where how can i write the text entered into the textfield into the example.lp and which is the best location to store example.lp
  2. subsonix macrumors 68040

    Feb 2, 2008
    You mention that CPELX LP is a custom format so I assume you already have written, or have acces to routines to read and write files in that format. After that you can use the tmpfile() C function which takes care of location and cleaning up of your temporary file. For more info check, man tmpfile.

    Perhaps you should also consider if there is another way of solving this that doesn't need a temporary file. The fact that pressing "Optimize" performs a "Save As" that is just read by another function then discarded seems like something that may be avoidable.

Share This Page