NSString indexOf in Objective-C

前端 未结 4 792
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-28 11:31

Is there anything similar to an indexOf function in the NSString objects?

4条回答
  •  难免孤独
    2020-12-28 12:09

    Use -[NSString rangeOfString:]:

    - (NSRange)rangeOfString:(NSString *)aString;
    

    Finds and returns the range of the first occurrence of a given string within the receiver.

提交回复
热议问题