views:

66

answers:

1

The options:NSCaseInsensitiveSearch is crashing my app when I have it in the following. Does anyone know why this might be?

NSString* string3 = [[[[tvQ.text stringByReplacingOccurrencesOfString:@"\n"
    withString:@" " options:NSCaseInsensitiveSearch range:wholeString]
        stringByReplacingOccurrencesOfString:@"&" withString:@"and"]     
            stringByReplacingOccurrencesOfString:@"ç" withString:@"c"] 
                stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

Error from X-Code: error: 'wholeString' not defined

A: 

shouldn't your 'wholeString' be a string which you have to declare before the call of this function? or, if you want to search the whole string, then shouldn't it be your tvQ.text ?

Micko
ahm, no. it's a range. so you have to declare and make the NSRange before the call...
Micko
Micko - how do you declare NSRange or "WholeString"?
BigMike
Do I even need to define a range with the NSCaseInsensitiveSearch option?
BigMike
I never did this before, but I think it should work with define the NSRange. Look in the documentation for "NSMakeRange". you have just to give this method two integers --> the starting point (should be 0) and the ending point (should be the string length)...
Micko
You only need to include the range argument if you wish to only search a certain part (ie. range) of the string; By default the method searches the whole string. – Felixs 2 days ago
Felixs
ah ok, sounds good...
Micko