Warning: Implicit conversion loses Integer precision in xcode 6

后端 未结 3 613
逝去的感伤
逝去的感伤 2020-12-29 06:36

I know it could be a duplicate, but i got about 30 Implicit conversion loses Integer precision warnings in my ios project after updating xcode to version 6.

3条回答
  •  甜味超标
    2020-12-29 07:35

    I was always annoyed by these warnings, so I came up with simple solution to avoid it:

    @interface NSIndexPath(UnsignedIndex)
    
    @property (nonatomic, readonly) NSUInteger sectionIndex;
    @property (nonatomic, readonly) NSUInteger rowIndex;
    
    @end
    
    @implementation NSIndexPath(UnsignedIndex)
    
    - (NSUInteger)sectionIndex {
    
        return (NSUInteger)self.section;
    }
    
    - (NSUInteger)rowIndex {
    
        return (NSUInteger)self.row;
    }
    
    @end
    

    Simply use rowIndex and sectionIndex properties from this category instead of NSIndexPath's row and section properties.

提交回复
热议问题