Xcode警告错误处理

  • 警告:Applications using Launch Screen Files and targetting iOS 7.1 and earlier need to also include a Launch Image in an Asset Catalog.

解决方案:Launch Images Source 要选择启动图片来源,来适配iOS7.1及更早的版本。 

图示:

Xcode6默认是这样的:


修改后:



  • 报错:This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes.  This will cause an exception in a future release.

解决方案:使用主线程更新UI,

dispatch_async(dispatch_get_main_queue(), ^{
                     // 更UI
                 });


报错:Collection <__NSArrayM: 0x13e172510> was mutated while being enumerated.的崩溃问题。

崩溃原因:

在枚举的时候发生了变化。比如forin 循环中的便利内容不能被改变, 是因为如果改变其便利的内容会少一个, 而系统是不会允许这个发生的所以就会crash...但是当改变最后一个的内容时, 就不会crash, 是因为此时遍历已经结束, 结束之后对内容做修改是允许的

这里有三种解决方案:

 1.利用for loop ()


      for (int i = 0; i < arr.count; i++) {

            if (...) {

                // do sth ;

            }

        }


2.利用临时变量

   NSArray *tmp = [NSArray arrayWithArray:arr];

        for (id obj in tmp) {

            if (...) {

               // do sth ;

            }

        }


3.enumerateObjectsUsingBlock(推荐)

    [arr enumerateObjectsUsingBlock:^(NSMutableDictionary *obj, NSUInteger idx, BOOL *stop) {

            if (...) {

                // do sth

                *stop = YES; // 相当于break ; stop控制跳出枚举器.

            }

        }];



转载于:https://my.oschina.net/tonychb/blog/597881

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值