Questions tagged «nsmutablestring»

5
如何查看NSString是否以某个其他字符串开头?
我正在尝试检查要用作URL的字符串是否以http开头。我现在尝试检查的方式似乎不起作用。这是我的代码: NSMutableString *temp = [[NSMutableString alloc] initWithString:@"http://"]; if ([businessWebsite rangeOfString:@"http"].location == NSNotFound){ NSString *temp2 = [[NSString alloc] init]; temp2 = businessWebsite; [temp appendString:temp2]; businessWebsite = temp2; NSLog(@"Updated BusinessWebsite is: %@", businessWebsite); } [web setBusinessWebsiteUrl:businessWebsite]; 有任何想法吗?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.