在FTP上传多个文件

我是新来的Objective-C和iOS。 我正在使用SimpleFTPSample来制作上传和下载文件到ftp的testing应用程序。 我需要在FTP上传两个文件,但是在SimpleFTPSample中只能上传一个…所以我需要添加到源代码中? 我想必须有一些循环,但我不知道在哪里…

这里是我的代码,我添加(),但我知道这是错的,但我没有任何想法。 谢谢你的帮助。

success = (url != nil); NSMutableArray *listFile = [[NSMutableArray alloc] initWithCapacity:2]; [listFile addObject:[[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"1.txt"]]; [listFile addObject:[[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"2.txt"]]; for (int i= 0; i <= 1; i++ ) { self.filePath = [listFile objectAtIndex:i]; url = [NSURL URLWithString:@"ftp://anonymous@ftp"]; url = CFBridgingRelease( CFURLCreateCopyAppendingPathComponent(NULL, (__bridge CFURLRef) url, (__bridge CFStringRef) [self.filePath lastPathComponent], false)); // ); success = (url != nil); self.ftpFileStream = [NSInputStream inputStreamWithFileAtPath:_filePath]; assert(self.ftpFileStream != nil); [self.ftpFileStream open]; self.ftpNetworkStream = CFBridgingRelease( CFWriteStreamCreateWithFTPURL(NULL, (__bridge CFURLRef) url) ); assert(self.ftpNetworkStream != nil); self.ftpNetworkStream.delegate = self; [self.ftpNetworkStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [self.ftpNetworkStream open]; } } 

我相信你可以用其他有效的方式上传多个文件任务。

1)使用AFNetworking

另一个select是

2) ASIHTTPRequest的 ASINetworkQueue

注:ASIHTTPRequest不再维护…快乐编码:)