How to separate string by space using Objective-C?

前端 未结 5 2145
清歌不尽
清歌不尽 2021-01-30 16:16

Assume that I have a String like this:

hello world       this may     have lots   of sp:ace or little      space

I would like to seperate this

5条回答
  •  悲&欢浪女
    2021-01-30 16:52

    This has worked for me

    NSString * str = @"Hi Hello How Are You ?";
    NSArray * arr = [str componentsSeparatedByString:@" "];
    NSLog(@"Array values are : %@",arr);
    

提交回复
热议问题