たまに忘れるのでメモ、どんどん増やすかも
区切り文字で配列に変換する &その逆
・配列から文字列へセパレータで区切りつつ連結させる
NSArray *arr = @[@"Hello", @"World", @"!"];
NSString *str = [arr componentsJoinedByString:@","];
// Hello,World,!
・配列から文字列へセパレータで区切りつつ連結させる
NSString *str = @"Hello,World,!";
NSArray *arr = [str componentsSeparatedByString:@","];
// @{@"Hello", @"World", @"!"}
文字列検索
・文字列の中に、対象の文字列が存在するか確認
NSString *str = @"Hello World!";
NSRange searchResult = [str rangeOfString:@"World"];
// location=6, length=5
if(searchResult.location == NSNotFound) {
// みつからない場合の処理
}else{
// みつかった場合の処理
}