I am trying to convert an Objective-C app to swift.
I am reaching the part where I need to send a file through FTP to a distant server. I was able to to that in Objective-C but only because I had the SimpleFTPSample project that apple made to help the developers.
Right now I have almost complete the conversion between the two language but I am stuck.

Apparently &self.buffer[self.bufferOffset] is not correct (does not have a member name subscript), as well as self.bufferLimit - self.bufferOffset (could not find an overload ‘-‘ that accepts the supplied arguments)

To be honest I am not even sure to get what &self.buffer[self.bufferOffset] means. (not the variable but the notation.

So if someone has an idea on how to fixe that, he will be very welcomed !

2 Responses to “Implementing SimpleFTPSample in swift”

Here is my plagiarism of apple’s SimpleFTPExample to solve my problem of uploading a csv file from an iOS app to a ftp server.
I took the PutController objective-c file, cut lots and lots (too much?) out of it an included it into my swift application.
I modified the parameters passed to the main PutController function, to pass in the data I wanted to send, the URL it has to go to and the username and password to get onto the server.

Can’t you just compile SimpleFTP into a framework and use its methods directly from swift? No need to rewrite everything, Xcode does that for you. I use that for many custom libraries and it works like a charm. Just add target, and put in the required frameworks, include the framework and you’re all set!