Hi,
It is exasperating but I can't get this code work, first I though it was a mutable/inmutable problem but it doesn't, I believe. What am I doing wrong? labeledPemString do has contents and the specified characterSet is printing 'ranges begin {0, 26}' . But unlabeledBeginPemString has the same as the original string.
//Get the .pem file contents
NSString *path = [[NSBundle mainBundle] pathForResource:@"publickey" ofType:@"pem"];
NSMutableString *labeledPemString = [[NSMutableString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog(@"labeled %@", labeledPemString);
//Take off -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- headers
//First get begin range
NSRange beginHeaderRange = [labeledPemString rangeOfString:@"-----BEGIN PUBLIC KEY-----"];
NSLog(@"ranges begin %@ ", NSStringFromRange(beginHeaderRange));
//Create a characterset with begin range
NSCharacterSet *beginHeaderChSet = [NSCharacterSet characterSetWithRange:beginHeaderRange];
//Trim text
NSMutableString *unlabeledBeginPemString = [[labeledPemString stringByTrimmingCharactersInSet:beginHeaderChSet] mutableCopy];
NSLog(@"unlabeled 1 %@", unlabeledBeginPemString);
Thanks for your help.