我一直在尝试将多个文件上传到服务器,但我一直无法达到我的目标。目前的情况是,我可以发送一些csv文件,但不能发送我存档中的所有csv文件(我的存档保存了会话和了解哪些文件属于哪个会话所需的所有值)。文件正在发送到服务器,但我必须再次按下按钮才能将剩余的csv文件上传到服务器。
NSMutableArray *rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSLog(@"total objects counted: %d", [rootObject count]);
for ( int i = 0; i < [rootObject count]; i++ ) {
NSLog(@"current object: %d", i);
[self sendCSVtoServer: rootObject[0]];
[rootObject removeObjectAtIndex: 0];
}
[NSKeyedArchiver archiveRootObject:rootObject toFile:path];下面是我的sendCSVtoServer函数
- (void) sendCSVtoServer: ( Session * ) archive_session {
NSLog(@"file name: %@", [archive_session getFile]);
NSURL *url = [NSURL URLWithString:@"http://xx.x.xxx.xxx:3000/xxx/xxxxxxxx"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue: [archive_session getEmail] forKey:@"email"];
[request addFile: [archive_session getFile] forKey:@"csv"];
[request setDelegate:self];
[request startSynchronous];
}任何想法都将非常感谢,谢谢:)
发布于 2013-03-05 07:50:22
这就是答案...:/愚蠢的我
NSMutableArray *rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSLog(@"total objects counted: %d", [rootObject count]);
for ( int i = 0; i < [rootObject count]; i++ ) {
NSLog(@"current object: %d", i);
[self sendCSVtoServer: rootObject[i]];
}
[rootObject removeAllObjects];
[NSKeyedArchiver archiveRootObject:rootObject toFile:path];https://stackoverflow.com/questions/15208656
复制相似问题