Q:

Split NSString in exactly two pieces

Which is the optimum way to split an NSString in two pieces? My idea was to split a filename in two parts the filename itself and the extension. I would like to know which could be the most simple one.

A:

NSStringoffers some of its own implementations that will do exactly what you want for filenames and paths.
See https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/doc/uid/20000154-SW38 and there for example lastPathComponentor pathExtension.
[yourFilePath lastPathComponent] gives you the filename of a given path. [yourFilePath pathExtension] gives you the extension. Note this works for NSURL as well, but expects a valid path or URL respectively.

