search

Home  >  Q&A  >  body text

ios - 求大神看看这个bug的修复

这个bug有时会出现,有时侯又好用,完全不知道从哪下手,遍历这个model的时候,也是大概遍历到20多个的时候才会崩溃。

大家讲道理大家讲道理2771 days ago467

reply all(8)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 09:46:49

    for in traverse without modifying the traversed array. It is recommended to change it to array enumerateObjectsUsingBlock... method to traverse. This can be modified without crashing. I have encountered the same problem

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:46:49

    It’s not good to modify the array while traversing it...

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:46:49

    Modifying and deleting the array while traversing will definitely cause problems

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:46:49

    The traversed array cannot be changed during traversal

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:46:49

    According to the prompt, your HCFavoriteIconView does not have the nodeIndex attribute or method! If you want to make modifications while traversing the array, it is recommended to use enum to traverse

    reply
    0
  • 黄舟

    黄舟2017-04-18 09:46:49

    When traversing array elements, it is normal logic to add the required elements to a variable array, and then assign the variable array back after traversing it

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:46:49

    HCFavoriteIconView没有nodeIndex, 或者你把nodeIndex发给了不存在这个方法的对象0x7e3930e0, you can use category to debug the reason:

    @interface NSObject(testing)
    
    - (NSString *)nodeIndex;
    
    @end
    
    @implementation NSObject(testing)
    
    - (NSString *)nodeIndex{
        NSAssert(NO, @"class %@ has no method of nodeIndex", [self class]);
        return nil;
    }
    
    @end

    reply
    0
  • 阿神

    阿神2017-04-18 09:46:49

    The console output shows [HCFavoriteIconView nodeIndex], indicating that HCFavoriteIconView cannot access this nodeIndex. First, confirm that the nodeIndex of your object exists.

    reply
    0
  • Cancelreply