开发中各种错误汇总

来源:互联网 发布:巨人网络征途视频 编辑:程序博客网 时间:2024/06/03 21:14

    • couldnt be opened because you dont have permission to view it
    • 在控制台中报了content-type textplain错误则在自己的manage文件中添加textplain
    • 控制台输出不是中文要转成中文输出
    • 跳转 App Store 没有反应

一.

1. couldn’t be opened because you don’t have permission to view it.

这里写图片描述

一般是由于导入了第三方除了冲突,只要clean 一下工程后再运行即可.


2.在控制台中报了content-type: text/plain错误,则在自己的manage文件中添加text/plain

text/json 或者text/JavaScript 等相似错误也是一样的解决方法
但是系统只默认最后添加的一条配置

这里写图片描述
这里写图片描述


3. 控制台输出不是中文,要转成中文输出

这里写图片描述

直接添加下面代码文件(创建 Objective-C File 的空文件)

////  RYFoundationLog.m////  Created by Liu on 2017/2/28.//  Copyright © 2017年 Liu. All rights reserved.#import <Foundation/Foundation.h>#ifndef Release@implementation NSSet(Log)- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level {    NSMutableString *desc = [NSMutableString string];    NSMutableString *tabString = [[NSMutableString alloc] initWithCapacity:level];    for (NSUInteger i = 0; i < level; ++i) {        [tabString appendString:@"\t"];    }    NSString *tab = @"\t";    if (level > 0) {        tab = tabString;    }    [desc appendString:@"\t{(\n"];    for (id obj in self) {        if ([obj isKindOfClass:[NSDictionary class]]            || [obj isKindOfClass:[NSArray class]]            || [obj isKindOfClass:[NSSet class]]) {            NSString *str = [((NSDictionary *)obj) descriptionWithLocale:locale indent:level + 1];            [desc appendFormat:@"%@\t%@,\n", tab, str];        } else if ([obj isKindOfClass:[NSString class]]) {            [desc appendFormat:@"%@\t\"%@\",\n", tab, obj];        } else if ([obj isKindOfClass:[NSData class]]) {            // if is NSData,try parse            NSError *error = nil;            NSObject *result =  [NSJSONSerialization JSONObjectWithData:obj                                                                options:NSJSONReadingMutableContainers                                                                  error:&error];            if (error == nil && result != nil) {                if ([result isKindOfClass:[NSDictionary class]]                    || [result isKindOfClass:[NSArray class]]                    || [result isKindOfClass:[NSSet class]]) {                    NSString *str = [((NSDictionary *)result) descriptionWithLocale:locale indent:level + 1];                    [desc appendFormat:@"%@\t%@,\n", tab, str];                } else if ([obj isKindOfClass:[NSString class]]) {                    [desc appendFormat:@"%@\t\"%@\",\n", tab, result];                }            } else {                @try {                    NSString *str = [[NSString alloc] initWithData:obj encoding:NSUTF8StringEncoding];                    if (str != nil) {                        [desc appendFormat:@"%@\t\"%@\",\n", tab, str];                    } else {                        [desc appendFormat:@"%@\t%@,\n", tab, obj];                    }                }                @catch (NSException *exception) {                    [desc appendFormat:@"%@\t%@,\n", tab, obj];                }            }        } else {            [desc appendFormat:@"%@\t%@,\n", tab, obj];        }    }    [desc appendFormat:@"%@)}", tab];    return desc;}@end@implementation NSArray (Log)- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level {    NSMutableString *desc = [NSMutableString string];    NSMutableString *tabString = [[NSMutableString alloc] initWithCapacity:level];    for (NSUInteger i = 0; i < level; ++i) {        [tabString appendString:@"\t"];    }    NSString *tab = @"";    if (level > 0) {        tab = tabString;    }    [desc appendString:@"\t(\n"];    for (id obj in self) {        if ([obj isKindOfClass:[NSDictionary class]]            || [obj isKindOfClass:[NSArray class]]            || [obj isKindOfClass:[NSSet class]]) {            NSString *str = [((NSDictionary *)obj) descriptionWithLocale:locale indent:level + 1];            [desc appendFormat:@"%@\t%@,\n", tab, str];        } else if ([obj isKindOfClass:[NSString class]]) {            [desc appendFormat:@"%@\t\"%@\",\n", tab, obj];        } else if ([obj isKindOfClass:[NSData class]]) {            NSError *error = nil;            NSObject *result =  [NSJSONSerialization JSONObjectWithData:obj                                                                options:NSJSONReadingMutableContainers                                                                  error:&error];            if (error == nil && result != nil) {                if ([result isKindOfClass:[NSDictionary class]]                    || [result isKindOfClass:[NSArray class]]                    || [result isKindOfClass:[NSSet class]]) {                    NSString *str = [((NSDictionary *)result) descriptionWithLocale:locale indent:level + 1];                    [desc appendFormat:@"%@\t%@,\n", tab, str];                } else if ([obj isKindOfClass:[NSString class]]) {                    [desc appendFormat:@"%@\t\"%@\",\n", tab, result];                }            } else {                @try {                    NSString *str = [[NSString alloc] initWithData:obj encoding:NSUTF8StringEncoding];                    if (str != nil) {                        [desc appendFormat:@"%@\t\"%@\",\n", tab, str];                    } else {                        [desc appendFormat:@"%@\t%@,\n", tab, obj];                    }                }                @catch (NSException *exception) {                    [desc appendFormat:@"%@\t%@,\n", tab, obj];                }            }        } else {            [desc appendFormat:@"%@\t%@,\n", tab, obj];        }    }    [desc appendFormat:@"%@)", tab];    return desc;}@end@implementation NSDictionary (Log)- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level {    NSMutableString *desc = [NSMutableString string];    NSMutableString *tabString = [[NSMutableString alloc] initWithCapacity:level];    for (NSUInteger i = 0; i < level; ++i) {        [tabString appendString:@"\t"];    }    NSString *tab = @"";    if (level > 0) {        tab = tabString;    }    [desc appendString:@"\t{\n"];    // Through array, self is array    for (id key in self.allKeys) {        id obj = [self objectForKey:key];        if ([obj isKindOfClass:[NSString class]]) {            [desc appendFormat:@"%@\t%@ = \"%@\",\n", tab, key, obj];        } else if ([obj isKindOfClass:[NSArray class]]                   || [obj isKindOfClass:[NSDictionary class]]                   || [obj isKindOfClass:[NSSet class]]) {            [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, [obj descriptionWithLocale:locale indent:level + 1]];        } else if ([obj isKindOfClass:[NSData class]]) {            NSError *error = nil;            NSObject *result =  [NSJSONSerialization JSONObjectWithData:obj                                                                options:NSJSONReadingMutableContainers                                                                  error:&error];            if (error == nil && result != nil) {                if ([result isKindOfClass:[NSDictionary class]]                    || [result isKindOfClass:[NSArray class]]                    || [result isKindOfClass:[NSSet class]]) {                    NSString *str = [((NSDictionary *)result) descriptionWithLocale:locale indent:level + 1];                    [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, str];                } else if ([obj isKindOfClass:[NSString class]]) {                    [desc appendFormat:@"%@\t%@ = \"%@\",\n", tab, key, result];                }            } else {                @try {                    NSString *str = [[NSString alloc] initWithData:obj encoding:NSUTF8StringEncoding];                    if (str != nil) {                        [desc appendFormat:@"%@\t%@ = \"%@\",\n", tab, key, str];                    } else {                        [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, obj];                    }                }                @catch (NSException *exception) {                    [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, obj];                }            }        } else {            [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, obj];        }    }    [desc appendFormat:@"%@}", tab];    return desc;}@end#endif

4. 跳转 App Store 没有反应

这里写图片描述

替换中文:

这里写图片描述

1 0
原创粉丝点击