Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SirFurtWiggle

macrumors newbie
Original poster
Apr 23, 2014
1
0
Hi!
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.
RmhKs.png

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
 
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

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.