Basic setup of FTP iOS; Read and write stream

I am trying to create an iOS 5 application with some basic FTP features and need some recommendations. It will connect to the device on the local network and perform read / write operations with .dat / txt files. I searched several times over the past few days and saw various recommendations, but nothing simple that I can pick up and quickly change for personal use.

My questions are as follows:

  • Are there any tutorials / code examples that you could recommend to me?
  • What frameworks and classes should I work with for basic read / write operations?

Finally, I should mention that I spent a lot of time analyzing Apple’s SimpleFTPSample, but the sample code gives connection disconnection notifications and stream disconnection notifications for each example, so I'm a little afraid of its usefulness.

Forgive me if this was answered elsewhere. All related posts have bits of the answer that I need, but not all. Thank you in advance!

EDIT for clarity: a well-defined example or a step-by-step tutorial is what I really like. My own Google searches did not lead to anything, and I desperately need some recommendations here.

UPDATE: I posted this question a long time ago, but continued to use FTPHelper mentioned in the accepted answer. I recently cleaned the dust of an old project and realized that there was a small memory leak in the FTPHelper fetch function, which could be a killer application if called again. If anybdy stumbles over this issue and prefers to use FTPHelper, be sure to add the CFRelease line shown in the code below.

- (void) fetch: (NSString *) anItem
{
    if (!self.uname || !self.pword) COMPLAIN_AND_BAIL(@"Please set user name and password first");
    if (!self.urlString) COMPLAIN_AND_BAIL(@"Please set URL string first");

    NSString *ftpRequest = [NSString stringWithFormat:@"%@/%@", self.urlString, [anItem stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
/*  CFShow(ftpRequest); */
    NSString *writepath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    self.filePath = [writepath stringByAppendingPathComponent:anItem];
    CFURLRef writeURL = CFURLCreateFromFileSystemRepresentation (NULL, (const UInt8 *) [writepath UTF8String], [writepath length], NO); 
    MySimpleDownload((CFStringRef)ftpRequest, writeURL, (CFStringRef) self.uname, (CFStringRef)self.pword);
    CFRelease(writeURL);//ADD THIS LINE TO FIX MEMORY LEAK 
}
+5
source share
2 answers

SimpleFTPSample , , , . , ( Apple), - , FTP. , , iOS 5 ARC. Apple, , , iOS.

iOS 5 , ARC, -fno-objc-arc [ ] → TARGETS → [ ] → → → [ ] Xcode ARC.

, .

, , , , .

:

, [FTPHelper list:THE_FTP_URL] , ( ) [FTPHelper download: THE_FTP_URL_WITH_THE_FILENAME_FROM_LISTING].

- (void) downloadFinished
{
    //do the reading depending on the file type
    NSData *data = [NSData dataWithContentsOfFile:[FTPHelper sharedInstance].filePath];
}

- [FTPHelper upload:FILE_TO_UPLOAD] .

+7
+4

All Articles