GVKun编程网logo

Error Domain=NSURLErrorDomain Code=-1002 "unsuppor

8

在本文中,我们将详细介绍ErrorDomain=NSURLErrorDomainCode=-1002"unsuppor的各个方面,同时,我们也将为您带来关于AVFoundationErrorDomai

在本文中,我们将详细介绍Error Domain=NSURLErrorDomain Code=-1002 "unsuppor的各个方面,同时,我们也将为您带来关于AVFoundationErrorDomain Code=-11800, An unknown error occurred (-12780)、Core Data遇到的问题(Unresolved error Error Domain=NSCocoaErrorDomain)、CoreData____.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "T、Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 162." UserInf...的有用知识。

本文目录一览:

Error Domain=NSURLErrorDomain Code=-1002

Error Domain=NSURLErrorDomain Code=-1002 "unsuppor

# 这个地址 浏览器可以打开,但是写在 iOS 应用里请求数据的时候会报网址不受支持的错误。

这个是因为,我们平时用的浏览器 ,自动把中文字符转成了类似 “% E6%83%85% E4% BE% A3% E5% A4% B4% E5%83%8F” 这种编码的东西,而 iOS 程序中,并没有进行类似转换。

解决方法如下:

NSString *urlStr =[NSString stringWithFormat:@"http://so.picasso.adesk.com/v1/search/wallpaper/resource/%@?adult=false&first=1&limit=30&channel=tencent",bt.titleLabel.text];

    // 含有中文字符 导致 unsupport 此方法可以解决

    NSString *encodingUrlStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:encodingUrlStr]];

AVFoundationErrorDomain Code=-11800, An unknown error occurred (-12780)

AVFoundationErrorDomain Code=-11800, An unknown error occurred (-12780)

## 期望:

PHAsset 保存到沙盒指定目录

## 实现方法:

- (PHImageRequestID)requestExportSessionForVideo:(PHAsset *)asset options:(nullable PHVideoRequestOptions *)options exportPreset:(NSString *)exportPreset resultHandler:(void (^)(AVAssetExportSession *__nullable exportSession, NSDictionary *__nullable info))resultHandler;

## 结果:

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12780), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x28208c600 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}}

## 原因:   优先检查路径,AVAssetExportSession 的属性 outputURL 为 [NSURL fileURLWithPath:path], 而不是 [NSURL URLWithString:path].

## 完整代码如下:

//PHAsset 的扩展方法
- (void)saveVideoDataWithFileName:(NSString *)fileName finish:(void(^)(BOOL saveOk))completion {
    //确定保存路径
    NSString *directory = GVUSER.isLockedAlbum? DIRECTORY_VIDEO_LOCK : DIRECTORY_VIDEO;
    NSString *path = [directory stringByAppendingPathComponent:fileName];
    BOOL fileExist = [FILEMANAGER fileExistsAtPath:path];
    if (!fileExist) {
        PHVideoRequestOptions *option = [[PHVideoRequestOptions alloc] init];
        option.version = PHVideoRequestOptionsVersionOriginal;
        option.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat;
        option.networkAccessAllowed = YES;
        [PHImageManager.defaultManager requestExportSessionForVideo:self options:option exportPreset:AVAssetExportPresetHighestQuality resultHandler:^(AVAssetExportSession * _Nullable exportSession, NSDictionary * _Nullable info) {
            exportSession.outputFileType = AVFileTypeMPEG4;
            exportSession.outputURL = [NSURL fileURLWithPath:path];
            [exportSession exportAsynchronouslyWithCompletionHandler:^{
                // 如果导出的状态为完成
                if ([exportSession status] == AVAssetExportSessionStatusCompleted) {
                    //保存完成
                    completion(YES);
                }else if (exportSession.status == AVAssetExportSessionStatusFailed){
                    NSLog(@"错误0----%@",exportSession.error);
                    completion(NO);
                }
            }];
        }];
    }else {
        NSString *newFileName = fileName.fixedFileName;
        [self saveVideoDataWithFileName:newFileName finish:^(BOOL saveOk) {
            completion(saveOk);
        }];
    }
}

//NSString 的扩展方法
- (NSString *)fixedFileName {
    NSString *newFileName;
    NSArray *coms = [self componentsSeparatedByString:@"."];
    //有格式显示
    if (coms.count > 1) {
        NSString *fileFormat = coms.lastObject;
        //        NSString *pureName = coms[coms.count-2];
        NSString *dotFormat = [@"." stringByAppendingString:fileFormat];
        NSString *pureName = [self stringByReplacingOccurrencesOfString:dotFormat withString:@""];
        NSString *newPureName;
        if ([pureName hasSuffix:@")"]) {
            //有(*)
            if (pureName.length > 1) {
                NSString *num = [pureName substringWithRange:NSMakeRange(pureName.length-2, 1)];
                NSString *newNum = [NSString stringWithFormat:@"%ld", (long)(num.integerValue+1)];
                newPureName = [pureName stringByReplacingOccurrencesOfString:num withString:newNum];
            }else {
                newPureName = [pureName stringByAppendingString:@"1"];
            }
            newFileName = [NSString stringWithFormat:@"%@.%@", newPureName, fileFormat];
        }else {
            newFileName = [NSString stringWithFormat:@"%@(1).%@", pureName, fileFormat];
        }
    }

    //没有格式显示
    else {
        newFileName = [self stringByAppendingString:@"(1)"];
    }
    return newFileName;
}

Core Data遇到的问题(Unresolved error Error Domain=NSCocoaErrorDomain)

Core Data遇到的问题(Unresolved error Error Domain=NSCocoaErrorDomain)

Mac Version:10.6.7

XCode Version:4.2

参考书籍:Iphone3开发基础教程中文版第十一章关于数据保存技术------Core Data


在- (void)viewDidLoad  函数中

有如下的代码:

NSManagedobjectContext *context = [appDelegate managedobjectContext];

运行到这里就出错,错误提示信息:


2011-12-23 11:35:25.865 Core Data Persistence[1115:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation Couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x6a3e420 {Metadata=<CFBasicHash 0x6a275b0 [0x171bb38]>{type = immutable dict,count = 7,entries =>
...............

根据以下内容:

http://stackoverflow.com/questions/5517129/core-data-cocoa-error-134100

进行如下的操作就能解决问题:

找到该应用程序沙箱的Documents文件夹,删除CoreData需要的那个文件。


用以下的方法可以找到沙箱的Documents文件夹:

- (Nsstring *) dataFilePath {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);

    Nsstring *documentsDirectory = [paths objectAtIndex:0];

    return [documentsDirectory stringByAppendingPathComponent:@"test.txt"];

}


产生这种错误的步骤:

1.编写xcdatamodeld文件的时候,添加一个ENTITIES(命名为entitie)

2.给entitie添加了2个属性a和b

3.运行程序,不会在NSManagedobjectContext *context = [appDelegate managedobjectContext];这里出现错误,但是有很大的可能在其他地方出错

4.重命名entitie为Line

5.运行程序,这个时候就出现错误


最后总结该错误的原因:

The reason for this is because your new managed object model is trying to use older version of storage (the one first time created when you launched the app).


摘自:http://stackoverflow.com/questions/5517129/core-data-cocoa-error-134100

CoreData____.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100

CoreData____.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "T

使用coreData存储数据的时候,运行app就报错CoreData____.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "The operation Couldn’t be completed. (Cocoa error 134100.)"。

解决办法:把模拟器里面的原来的app删除就可以了。运行OK。

Error Domain=NSCocoaErrorDomain Code=3840

Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 162." UserInf...

 AFN 网络请求报错,Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 162." UserInfo={NSDebugDescription=Invalid value around character 162.}

 我在网上用 在线 HTTP POST/GET ... 接口测试工具 测试的时候,是有数据的,也不报错

 解决办法:

manager.requestSerializer = [AFHTTPRequestSerializer serializer];

manager.responseSerializer = [AFHTTPResponseSerializer serializer];

 

 

报错原因:

前面调的接口传数据格式和后台返回的数据都是 json 格式的,传的参数格式如:{"listId":"1","date":"20190820"} 这样的,所以把 requestSerializer 和 responseSerializer 都设置成了

AFJSON***Serializer

 

// 申明返回的结果是 json 类型

    manager.responseSerializer = [AFJSONResponseSerializer serializer];

//    申明请求的数据是 json 类型

    manager.requestSerializer = [AFJSONRequestSerializer serializer];

 

后面调的接口,传参格式是 listId=1&date=20190820 这样的,而且返回的数据格式也是二进制的数据,所以要改成:

manager.requestSerializer = [AFHTTPRequestSerializer serializer];

manager.responseSerializer = [AFHTTPResponseSerializer serializer];

 

如果返回的是 json 格式的,又要根据实际情况调整。

 

关于Error Domain=NSURLErrorDomain Code=-1002 "unsuppor的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于AVFoundationErrorDomain Code=-11800, An unknown error occurred (-12780)、Core Data遇到的问题(Unresolved error Error Domain=NSCocoaErrorDomain)、CoreData____.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "T、Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 162." UserInf...等相关内容,可以在本站寻找。

本文标签: