NSString* str1 = @"hello";
NSString* str2 = @"hello world";
NSRange matching = [str2 rangeOfString : str1];
// Searching for a string within another string
if(matching.location == NSNotFound){
// str1 not found in str2
} else {
// str1 found in str2
}
// Checking for equality
if([str1 isEqualToString:@"hello"]){
// str1 is equal to "hello"
} else {
// str1 is not equal to "hello"
}
NSString* str2 = @"hello world";
NSRange matching = [str2 rangeOfString : str1];
// Searching for a string within another string
if(matching.location == NSNotFound){
// str1 not found in str2
} else {
// str1 found in str2
}
// Checking for equality
if([str1 isEqualToString:@"hello"]){
// str1 is equal to "hello"
} else {
// str1 is not equal to "hello"
}
No comments:
Post a Comment