Nitriles hydrolize in basic medium leading to carboxylic acids.
Therefore, the introduction of a nitrile group - by means of a SN reaction with cyanide of a compound with a good leaving group - is an excellent method to obtain a carboxylic acid.
Remember that the nucleophilic substitution reactions cannot be always achieved depending on the structure of the R group.