NSRange

Structure for representing a range with location and length in mulle-objc.

Structure Definition

typedef struct _NSRange {
   NSUInteger location;  // Starting index
   NSUInteger length;    // Number of items
} NSRange;

Functions

Range Creation

Range Operations

Range Manipulation

Usage Example

// Create range
NSRange range = NSMakeRange(0, 10);

// Check if location is in range
BOOL contains = NSLocationInRange(5, range);  // YES

// Get maximum location
NSUInteger max = NSMaxRange(range);  // 10

// Combine ranges
NSRange range1 = NSMakeRange(0, 5);
NSRange range2 = NSMakeRange(3, 5);
NSRange union = NSUnionRange(range1, range2);  // {0, 8}

// Intersect ranges
NSRange intersection = NSIntersectionRange(range1, range2);  // {3, 2}

Important Notes

  1. Range Validation
  2. Performance
  3. Best Practices