NSRange

NSRange is one of the essential types of Foundation. Passed around and returned in methods throughout the framework, being well-versed in this struct has a range of benefits, which this week’s article will help you locate. Ranges are data types used to describe a contiguous interval of integers. They are most commonly used with strings, arrays, and similarly-ordered collections.

nshipster.com/nsrange/

NSRange is a Foundation struct for a contiguous interval of integers, with location (start) and length. It helps avoid off-by-one errors compared to start/end pairs.

Common uses:

Functions:

Wrap in NSValue for collections. NSRangePointer is a typedef for NSRange *. CFRange is Core Foundation's version with CFIndex and CFRangeMake.


Category:

Year: