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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:31:42+00:00 2026-06-14T16:31:42+00:00

So I have had extensive experience reading rendered html source code of a website

  • 0

So I have had extensive experience reading rendered html source code of a website in Java. However I have researched thoroughly regarding how to do the exact same thing in Objective-C and have been able to come up with a solution that should work, but it doesn’t.
The idea is that i want to read each line, for example:”view-source:www.apple.com”, i want the read the result of that page line by line. I don’t want any Html parser etc.
This is what i have:

NSString *s = [NSString stringWithFormat:@"http://www.apple.com"];
NSURL *url = [NSURL URLWithString:s];

NSInputStream *iStream= [[NSInputStream alloc] initWithURL:url];

[iStream setDelegate:self];

[iStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
                   forMode:NSDefaultRunLoopMode];

[iStream open];
NSLog(@"stream successfully opened");



NSInteger result;
uint8_t buffer[1024];
    while((result = [iStream read:buffer maxLength:1024]) != 0) {       
    if(result > 0) {
        NSLog(@"Buffer is %@",buffer);

        // buffer contains result bytes of data to be handled
    } else {
        NSLog(@"ERROR: %@",buffer);
        // The stream had an error. You can get an NSError object using [iStream streamError]
    }
    NSLog(@"end of while loop: %@",buffer);

}
// Either the stream ran out of data or there was an error


NSLog(@"Either the stream ran out of data or there was an error");

This runs and compiles fine, but the result is always 0. Again i have done a a lot of research and i don’t understand why the result is 0. Any help is appreciated.

  • 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-06-14T16:31:44+00:00Added an answer on June 14, 2026 at 4:31 pm

    This other solution worked…

    NSString *s = [NSString stringWithFormat:@"http://www.apple.com"];
    NSURL *url = [NSURL URLWithString:s];
    
    
    NSData *data = [NSData dataWithContentsOfURL:url];
    NSString* newStr = [[NSString alloc] initWithData:data
                                             encoding:NSUTF8StringEncoding];
    NSArray *arr= [newStr componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
    

    although, i would have rather read the page line by line as this seems inefficient-but i’ll settle with this for now until i can find a better answer.

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

Sidebar

Related Questions

I currently have a website source code (no control over the source) which contains
Recently I had to develop several web applications. I did extensive research regarding JavaScript
I have never had an experience with creating simulations or 3D objects, but I
I'm new to Objective C, but have extensive C++ experience. I have a member
I have had the experience a few times now of having GHC tell me
I have had an online archive service for over a year now. Unfortunately, I
I have had to compile my app for the 4.0 sdk to run on
I have had a persistent problem with Visual Studio 2010 and any framework version
I have had this problem crop up a few times and I can't figure
I have had a look all over, but it doesn't seem as though my

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.