$を区切り文字として使用するNSStringを使用しています。
NSMutableString *str = @"AA$BB$CC";
したがって、私の質問は次のとおりです。Javaの場合と同様に、そのNSMutableStringを区切り文字「$」で分割して配列に格納する方法はありますか。
String[] list = str.split()
advancdeに感謝します。
NSArray* splittedArray= [str componentsSeparatedByString:@"$"];
for (NSString *component in splittedArray) {
NSLog(@"%@", component);
}
はい。componentsSeparatedByString
メソッドと同様に機能するメソッドを使用できますsplit()
。例:NSArray* list= [str componentsSeparatedByString:@"$"];