How do I check if a string contains another string in Objective-C?

前端 未结 23 2012

How can I check if a string (NSString) contains another smaller string?

I was hoping for something like:

NSString *string = @\"hello bla         


        
23条回答
  •  渐次进展
    2020-11-22 15:21

    If certain position of the string is needed, this code comes to place in Swift 3.0:

    let string = "This is my string"
    let substring = "my"
    
    let position = string.range(of: substring)?.lowerBound
    

提交回复
热议问题