How to get substring of NSString?

后端 未结 5 972
孤城傲影
孤城傲影 2020-12-01 02:44

If I want to get a value from the NSString @\"value:hello World:value\", what should I use?

The return value I want is @\"hello World\".

5条回答
  •  不知归路
    2020-12-01 02:55

    Here's a slightly less complicated answer:

    NSString *myString = @"abcdefg";
    NSString *mySmallerString = [myString substringToIndex:4];
    

    See also substringWithRange and substringFromIndex

提交回复
热议问题