반응형
[iOS Objective c] NSString contains string
NSString *string = @"hello bla bla";
if ([string rangeOfString:@"bla"].location == NSNotFound) {
NSLog(@"string does not contain bla");
} else {
NSLog(@"string contains bla!");
}
And if you're on iOS 8 or OS X Yosemite, you can now do: (*NOTE: This WILL crash your app if this code is called on an iOS7 device).
NSString *string = @"hello bla blah";
if ([string containsString:@"bla"]) {
NSLog(@"string contains bla!");
} else {
NSLog(@"string does not contain bla");
}
[출처 : stackoverflow]
반응형
'iOS > Swift + Objective-c' 카테고리의 다른 글
[ios xcode] error: linker command failed with exit code 1 (0) | 2017.05.25 |
---|---|
[iOS objective-c] indicator 사용하기 (0) | 2017.04.27 |
[iOS Objective c] 화면 흔들기 (view shake) 구현 (0) | 2017.03.31 |
[iOS Objective c] 진동 구현 (0) | 2017.03.31 |
[iOS] NSMutableArray 배열 순서 섞기 (0) | 2017.03.30 |