Comma-separated string to NSArray in Objective-C

前端 未结 2 966
误落风尘
误落风尘 2020-12-08 06:32

So I have no experience with arrays... But I need to use one to populate a UIPickerView. I am obtaining a list of objects via HTTP (NSURLConnection). This works fine. Curren

相关标签:
2条回答
  • 2020-12-08 07:07

    Assuming there's no worry about escaping/unescaping commas contained within the strings, it should be this simple:

    NSArray *items = [theString componentsSeparatedByString:@","];
    
    0 讨论(0)
  • 2020-12-08 07:24

    Objective-C

    NSString *list = @"Karin, Carrie, David";
    NSArray *listItems = [list componentsSeparatedByString:@", "];
    
    0 讨论(0)
提交回复
热议问题