NSURLErrorDomain错误-1021 [英] NSURLErrorDomain error -1021

查看:146
本文介绍了NSURLErrorDomain错误-1021的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我集成了Dropbox。登录正确完成我也可以在dropBox中创建文件夹。但是当我尝试加载文件时我收到错误

I'm developing an app were I integrated dropbox. Login is done properly also I'm able to create folder in dropBox. But when I try to load file I'm getting error

以下错误我得到了

error making request to /1/files_put/dropbox/Info.plist - Error
Domain=NSURLErrorDomain Code=-1021 "The operation couldn’t be
completed. (NSURLErrorDomain error -1021.)" UserInfo=0x6859bc0
{destinationPath=/Info.plist,
sourcePath=/Users/bcod/Library/Application Support/iPhone
Simulator/5.0/Applications/0E1EE43C-8F6B-40FA-8696-D3992DA2DCE5/DBRoulette.app/Info.plist}

我没有得到这个我正在创建文件夹时出错。

I'm not getting this error when I'm creating folder.

推荐答案

我在iPhone上的iOS 5.0遇到了同样的问题,但iPhone 6.1模拟器工作正常没有创建错误消息。

I had the same problem with iOS 5.0 on iPhone, but the iPhone 6.1 simulator worked without creating error messages.

我查看了DropboxSDK / DBRestClient.m,特​​别是uploadFile的最后几行:toPath:fromPath:params并实现了一个类别'ExBody '在DBRequest上添加连接:needNewBodyStr eam方法:

I took a look into the DropboxSDK / DBRestClient.m, especially the last lines of uploadFile:toPath:fromPath:params and implemented a categorie 'ExBody' on DBRequest to add the connection:needNewBodyStream method:

#import "DBRequest+ExBody.h"

@implementation DBRequest (ExBody)

#pragma mark NSURLConnection delegate methods

- (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)req {

    NSString * sourcePath = [userInfo objectForKey:@"sourcePath"];
    NSLog(@"%@ needs newBodyStream!", sourcePath);
    return [NSInputStream inputStreamWithFileAtPath:sourcePath];
}

@end

这对我有用。该方法在iOS5上调用,而不是在iOS6上调用!

This worked for me. The method is called on iOS5, not on iOS6!

这篇关于NSURLErrorDomain错误-1021的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆