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

  • Home
  • SEARCH
  • 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 7489413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:14:38+00:00 2026-05-29T15:14:38+00:00

I’m trying to parse some HTML. I use stringWithContentsOfURL to get the HTML. I

  • 0

I’m trying to parse some HTML. I use stringWithContentsOfURL to get the HTML. I attempt to load this into a character array so I can parse it, but I crash with the EXC_BAD_ACCESS error when getCString is called. Here is the relavent code:

- (void)parseStoryWithURL:(NSURL *)storyURL
{
    _paragraphs = [[NSMutableArray alloc] initWithCapacity:10];
    _read = NO;

    NSError* error = nil;
    NSString* originalFeed = [NSString stringWithContentsOfURL:storyURL encoding:NSUTF8StringEncoding error:&error];

    _i = originalFeed.length;
   char* entireFeed = malloc(_i*sizeof(char));
   char* current = entireFeed;
   char* lagger;
   char* recentChars = malloc(7);
   BOOL collectRecent = NO;
   BOOL paragraphStarted = NO;
   BOOL paragraphEnded = NO;
   int recentIndex = 0;
   int paragraphSize = 0;

   NSLog(@"original Feed: %@", originalFeed);


   _read = [originalFeed getCString:*entireFeed maxLength:_i encoding:NSUTF8StringEncoding];

I’ve also tried this passing the ‘current’ pointer to getCString but it behaves the same. From what I’ve read this error is typically thrown when you try to read from deallocated memory. I’m programming for iOS 5 with memory management. The line before that I print the HTML to the log and everything is fine. Help would be appreciated. I need to get past this error so I can test/debug my HTML parsing algorithms.

PS: If someone with enough reputation is allowed to, please add “getCString” as a tag. Apparently no one uses this function 🙁

  • 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-29T15:14:39+00:00Added an answer on May 29, 2026 at 3:14 pm

    There are several issues with your code – you’re passing the wrong pointers and not reserving enough space. Probably the easiest is to use UTF8String instead:

    char *entireFeed = strdup([originalFeed UTF8String]);
    

    At the end you’ll have to free the string with free(entireFeed) though. If you don’t modify it you can use

    const char *entireFeed = [originalFeed UTF8String];
    

    directly.

    If you want to use getCString, you’ll need to determine the length first – which has to include the termination character as well as extra space for encoded characters, so something like:

    NSUInteger len = [originalFeed lengthOfBytesUsingEncoding: NSUTF8StringEncoding] + 1;
    char entireFeed[len];
    [originalFeed getCString:entireFeed maxLength:len encoding:NSUTF8StringEncoding];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string

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.