Help with a Swift OS X program

David M Rosenberg rosenberg at acm.org
Mon Jun 1 12:18:23 EDT 2015


Hi Erik,

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.

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 http://pastebin.com/HwNLxbi9  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).

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

Do you expect to be at the MacTech group meeting this Wednesday? If so, could we talk then?

Thanks very much for your response.

/David

> On Jun 1, 2015, at 10:50 AM, Erik Price <erikprice at gmail.com> wrote:
> David, please disregard this if you've already gotten some help or solved your problem.
> 
> 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?
> 
> 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.
> 
> Good luck!


More information about the MacTechGroup-discuss mailing list