Methods in UITableViewDataSource return NSIntegers, where NSUInteger would be more appropriate
Originator: | guillaume.algis | ||
Number: | rdar://34460576 | Date Originated: | 15-sept.-2017 05:18 PM |
Status: | Open | Resolved: | |
Product: | iOS + SDK | Product Version: | 11.0 (15A372) |
Classification: | Enhancement | Reproducible: | Always |
Summary: Most of the methods defined in UITableViewDataSource returning an NSInteger (such as - numberOfSectionsInTableView: and - tableView:numberOfRowsInSection:) would made more sense returning an NSUInteger. These even behave the same way whether you return zero or a negative value. Using `NSUInteger` would made the expected range of returned value clearer, and would play nicer with e.g.. the type of NSArray's `count`, which is NSUInteger. Steps to Reproduce: 1. Implement tableView:numberOfRowsInSection: 2. Return a negative value Expected Results: If the return type was defined as NSUInteger, we'd get a compiler warning us that the returned value made no sense Actual Results: The value is accepted without any warning, masking a potential programming error Version: 11.0 (15A372) Notes:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!