gpt4 book ai didi

objective-c - 在名字和姓氏中拆分全名

转载 作者:行者123 更新时间:2023-12-04 14:36:26 26 4
gpt4 key购买 nike

如何在 First Name 中拆分全名和 Last Name .

NSString *fullName = @"John Luke Morite";
NSString *firstName = [[fullName componentsSeparatedByString:@" "] objectAtIndex:0]; //John
NSString *lastName = ?? // Luke Morite

最佳答案

更好的方法:

NSString *fullName = @"John Luke Morite";
NSRange range = [fullName rangeOfString:@" "];
NSString *fname = [fullName substringToIndex:range.location];
NSString *lname = [fullName substringFromIndex:range.location+1];

关于objective-c - 在名字和姓氏中拆分全名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21997062/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com