Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将如何取一个逗号分隔值 NSString *location = "15.009483, -87.485195" 并将它们分隔成坐标值来绘制?
我需要将它们放入 CoreData 数据库中,每个坐标都有单独的字段。
您可以使用 NSArraycomponentsSeparatedByString:将字符串分解为数组。从那里您可以将对象作为单独的字符串拉回。
componentsSeparatedByString:
NSString *location = @"15.009483, -87.485195"; NSArray *array = [location componentsSeparatedByString:@","]; NSString *lat = array[0]; NSString *lon = array[1];