NSComparisonResult - compare entire string?

Discussion in 'iOS Programming' started by forrestgrant, Aug 13, 2008.

  1. forrestgrant macrumors member

    Jun 24, 2008
    I am using NSComparisonResult like so:
    NSString *haystackText = @"Hello World";
    NSComparisonResult result = [haystackText compare:searchText options:NSCaseInsensitiveSearch range:NSMakeRange(0, [searchText length])];
    So if searchText = @"he" then the result is true.
    But if searchText = @"World", it does not return.

    Is there an option to pass NSComparisonResult to get it to find within the string instead of just an exact match of the beginning?
  2. kainjow Moderator emeritus


    Jun 15, 2000
    Maybe use the rangeOfString:XXX methods instead?

Share This Page