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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:40:41+00:00 2026-05-31T20:40:41+00:00

I’m using NSURLConnection to pull data from a webpage. I’m looking to find a

  • 0

I’m using NSURLConnection to pull data from a webpage. I’m looking to find a specific line of text to display in a basic app. I’ve converted my NSData to an NSString. The program successfully locates the string I’m looking for:

@"Most recent instantaneous value: 

However, I need to actually pull and store the string that follows “instantaneous value: myString “

I’m noob, so I’m stuck. Here’s my code:

- (void)viewWillAppear:(BOOL)animated
{
[super viewDidAppear:animated];

NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://waterdata.usgs.gov/ga/nwis/uv?cb_72036=on&cb_00062=on&format=gif_default&period=1&site_no=02334400"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if (connection) {
    // Connect
    label.text = @"Connecting...";
    myData = [[NSMutableData alloc] init];
} else {
    // Error
}
}

- (void)connection:(NSURLConnection *) connection didReceiveData:(NSData *)data 
{
[myData appendData:data];
}

-(void)connectionDidFinishLoading: (NSURLConnection *)connection {
response = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];
label.text = response;

NSString *string1 = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];
if ([string1 rangeOfString:@"Most recent instantaneous value: "].location == NSNotFound){
    NSLog(@"Not found");
} else
{
    NSLog(@"Found");
}
connection = nil;
}
  • 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-31T20:40:42+00:00Added an answer on May 31, 2026 at 8:40 pm

    This depends no the format of what follows. You can easily use a regular expression to extract this value if it has a delimiter. For example, let’s say it looks like this:

    …Most recent instantaneous value: 74219MoredataBlahBLahBlah

    This would be extracted using the regular expression “Most recent instantaneous value: ([0-9]+)”

    However, if it is something like this

    …Most recent instantaneous value: MyValueMoredataBlahBLahBlah

    Then you are pretty much out of luck unless it is the same size each time

    If it is like this

    ……Most recent instantaneous value: MyValue MoredataBlahBLahBlah

    Then you can get it like this “…Most recent instantaneous value: ([A-Z,a-z]+ )” (note the space at the end inside the parenthesis).

    Could you perhaps tell a bit more about the format of your value?

    EDIT:

    Since you know the length of your string, just do as shown above and when you get here:

    NSString *restOfString = [string1 substringFromIndex:theRange.location+theRange.length];
    

    Continue with this: NSString *cutString = [restOfString substringToIndex:8];

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

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.