<div dir="ltr">Hi David,<div><br></div><div>I've taken a look at the code you posted. You're right, it uses a very procedural approach, where the program starts at the top and continues to the bottom, much like a script. However, Cocoa programs seldom have this kind of structure. If you take a look at any of Apple's sample code, you'll see that most Mac programs actually consist of a number of functions, and often multiple classes. You might want to read through this Apple documentation introducing Mac app development, to get a sense for it:</div><div><br></div><div><a href="https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/chapters/01_Introduction.html">https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/chapters/01_Introduction.html</a><br></div><div><br></div><div>What I'd suggest is to create a brand new project (don't throw the current code away, since you can reuse most of it) and just make an app that shows a basic UI with an "open" button. Get it so that clicking the button opens the NSOpenPanel, then add another button for saving the output file and do the same thing with NSSavePanel. Once you have this basic skeleton in place, add the code to create a very basic NSURLSession (perhaps one that just requests the Google home page or something), and try setting a delegate or completion block on the NSURLSession. The delegate or block could just use NSLog to say "success" or something like that.</div><div><br></div><div>Once you have those things working, gradually start migrating the code from your current project into the appropriate functions in the new project, until you have things working the way you want them to.</div><div><br></div><div>I won't be at the meeting on Wednesday, so I apologize that I won't be able to help you in person. Perhaps there will be others who can. You can definitely get help for things like this at the Boston CocoaHeads meetings too (they meet second Thursday of every month). Or feel free to continue posting here if you have questions or run into any problems making progress.</div><div><br></div><div>Good luck</div><div><br></div><div>e</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 1, 2015 at 12:18 PM, David M Rosenberg <span dir="ltr"><<a href="mailto:rosenberg@acm.org" target="_blank">rosenberg@acm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Erik,<br>
<br>
Thank you for contacting me. So far you are the only one who has, so I’m very eager to be in touch with you.<br>
<br>
I’ve taken the current source code and shortened it by replacing a very long string literal with a short (junk) one, deleting most of the entries in a dictionary literal, and replacing the real URL with a fake one. I posted the source code at <a href="http://pastebin.com/HwNLxbi9" target="_blank">http://pastebin.com/HwNLxbi9</a>  The program contains comments about the things that aren’t implemented yet. I haven’t implemented a user interface. (It uses NSOpenPanel and NSSavePanel to allow the user select the input and output files).<br>
<br>
Most immediately, I need help restructuring the use of NSURLSession as described in your message. Other issues will be figuring out why NSFileHandle is returning nil instead of a handle, setting up a window and updating the displayed counts of records processed in the window, and responding to clicks on two buttons (one of which I’d like to have change its name from Start to Pause to Resume, depending on what state the program is in and the other of which I’d like to have change its name from Quit to Finish, depending on what state the program is in).<br>
<br>
Do you expect to be at the MacTech group meeting this Wednesday? If so, could we talk then?<br>
<br>
Thanks very much for your response.<br>
<span class="HOEnZb"><font color="#888888"><br>
/David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On Jun 1, 2015, at 10:50 AM, Erik Price <<a href="mailto:erikprice@gmail.com">erikprice@gmail.com</a>> wrote:<br>
> David, please disregard this if you've already gotten some help or solved your problem.<br>
><br>
> Speaking for myself, and possibly for others, it's easier to evaluate whether I can help you if I can see the code you have so far. Do you (or can you) post that code to a public source code repository somewhere?<br>
><br>
> At a high level, you are correct that NSURLSession is not designed to be used synchronously, and if you've written your code with the assumption that it works that way, you'll want to go back and rework things. Typically, you would either create a completion block or a class that conforms to the NSURLSessionDelegate protocol, and the NSURLSession will call you back with either of these facilities to let you know when data has been received. At that point, you can buffer the data in memory or write it to the output file.<br>
><br>
> Good luck!<br>
</div></div></blockquote></div><br></div>