hlily hlily - 1 year ago 66
Objective-C Question

Is there a situation that when range.location > targetString.length, range.length !=0

  1. Is there a situation possible that when
    range.location > targetString.length
    range.length !=0

  2. What's the best way to judge whether an range variable exists?

Answer Source

An invalid NSRange has the location member set to NSNotFound (which is NSIntegerMax), so:

  1. Yes, when the range is invalid, however in that case the length member should be ignored anyway.
  2. If by "exists" you mean "valid", it's when location != NSNotFound.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download