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 6181223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:58:56+00:00 2026-05-24T00:58:56+00:00

I am parsing an rss and I want to appenend a string here is

  • 0

I am parsing an rss and I want to appenend a string here is some code. My application crashes for and this is what is NSLogged.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with appendFormat:'

I am appending an nsmutablestring

  -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

  //     [data appendFormat:(NSMutableString *)string]; this doesn't work either
  [data appendFormat:string]; 
data = (NSMutableString *)[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

 }

why is my app carshing and what can I do to fix it?

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{


 [data appendFormat:string];
 [data autorelease];
 data = [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] mutableCopy];

}

  • 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-24T00:58:56+00:00Added an answer on May 24, 2026 at 12:58 am

    Casting NSString pointers into NSMutableString pointers doesn’t make the underlying objects mutable. You might fool the compiler into thinking it works, but you can’t trick the runtime. NSStrings and NSMutableStrings are different beasts to start with, so you can’t go around, take an immutable string, and pretend it’s mutable. Your app crashes because of this. (The opposite, casting an NSMutableString into a NSString, works because you’re restricting the set of possible operations on the object. You can always cast an object down to a more restrictive form, but you can rarely cast them the other way around.)

    You need to work with actual NSMutableString objects. The easiest way to get a mutable representation of an immutable string is to use the mutableCopy instance method. (Don’t forget to release the objects as you go.)

    [data appendFormat:string]; 
    [data autorelease];
    data = [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] mutableCopy];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to to use this class http://robbyonrails.com/articles/2005/05/11/parsing-a-rss-feed but am not sure where to
I'm parsing data from this RSS feed: http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=SAM|AR|AR005|MONTE%20MAIZ , The data there updates once
Parsing the string message seems bad. Or was this exception not meant to be
I am working on a web application and want to use SimplePie for parsing
I want to decode my string. I have used parsing and get a string
I'm writing an Android app that is parsing RSS feeds from different sources. What
I'm parsing rss feeds however some feeds have what look to be blank images
I am successfully parsing an RSS feed with PHP, but want to return a
I want to parse an rss feed from an android application. Everything related to
I'm parsing some RSS feeds that aggregate what's going on in a given city.

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.