Splitting an NSString into an array
Just a quick tip:
If you need to split an NSString into an NSArray it can be done:
NSString madeUpText = @"bob, dick, jane, harry, bruce";
NSArray *splitArray = [madeUpText componentsSeparatedByString: @","];
This is especially useful if you have a list of strings from say the NSPasteboard that are separated by newline. In this example you would go:
value = [pasteBoard stringForType:NSStringPboardType];
NSArray *fileList = [value componentsSeparatedByString:@"\n"];
where value is an NSString * and pasteBoard is [NSPasteboard generalPasteboard]
Comments are closed.