Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 917277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:11:11+00:00 2026-05-15T18:11:11+00:00

It is exasperating but I can’t get this code work, first I though it

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:11:11+00:00Added an answer on May 15, 2026 at 6:11 pm

    stringByTrimmingCharactersInSet: removes the occurrences of characters in the set from the receiver. i.e. if the NSCharacterSet contains a and c, and if you do

    [@"abc" stringByTrimmingCharactersInSet:characterSet];
    

    you get @"b" and the range in characterSetWithRange: is the range of the unicode to be put in the set of characters.

    I guess this is not what you want. If you just want to remove substrings from a given string, just use substringFromIndex:, substringToIndex and substringWithRange:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UIImagePickerController is easy to use, but i'm all of a sudden finding it exasperating
I have run into an exasperating problem getting a Java service client to communicate
This is not meant to be inflammatory or anything like that, but I am
I'm learning this wpf stuff and trying to get my head around validation of
I have recently noticed that my test code is too close to the production
I am facing a very exasperating challenge. I have to deploy my ASP.NET MVC
I'm new to ASP.NET MVC so this may be a stupid question. I have
I just want to clarify one thing. This is not a question on which
I recently did some work modifying a Python gui app that was using wxPython
I'm looking to clean everything but the Class name off of a fully qualified

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.