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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:49:16+00:00 2026-05-27T20:49:16+00:00

I’m now using a function which returns NSString after searching html, The code is

  • 0

I’m now using a function which returns NSString after searching html,
The code is

    - (IBAction) analysys:(id)sender {

    comparisonOptions = NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch;

    NSString *coupangURL = @"http://www.coupang.com/alldeal.pang";       

    NSMutableArray * title = [[NSMutableArray alloc] init];
    [title addObject:(NSString*)@"box"];

    for (NSString * e in title) {

        NSString * addr = [self searchCoupang:coupangURL targetString:e];
        self.myTextView.text = addr;
    }
}

- (NSString*) searchCoupang:(NSString *) url targetString:(NSString*) tString{

    NSString *testString = [NSString stringWithContentsOfURL:[NSURL URLWithString:url] 
                                                    encoding:NSUTF8StringEncoding 
                                                       error:nil];

    NSString * targetURL;

    if (testString != NULL){
        // Find the string

        NSRange rangeOfTargetString = [testString rangeOfString:tString options:comparisonOptions];

        t = [NSDate timeIntervalSinceReferenceDate];

        if( rangeOfTargetString.location != NSNotFound) {

            // Adjust range to take the line takes URL
            NSRange cutRange = {rangeOfTargetString.location - cutStringValueToGetTheAddress, cutStringValueToGetTheAddress};

            // Line which takes URL
            NSString * lineContainsURL = [testString substringWithRange:cutRange];

            NSRange rangeStartOfURL = [lineContainsURL rangeOfString:@"href"];
            NSRange rangeEndOfURL = [lineContainsURL rangeOfString:@"onclick"];

            NSRange targetRangeOfURL = {rangeStartOfURL.location + 6 ,((rangeEndOfURL.location - 2) - (rangeStartOfURL.location + 6)) };

            targetURL = [lineContainsURL substringWithRange:targetRangeOfURL];

        }

        return targetURL;
    }
    else 
        return @"Reading url error";
}

which works fine but when I check the running time each of the function in ‘searchCoupang’ such like

NSString *testString = [NSString stringWithContentsOfURL:[NSURL URLWithString:url] 
                                                    encoding:NSUTF8StringEncoding 
                                                       error:nil];

and

if (testString != NULL){
    // Find the string

    NSRange rangeOfTargetString = [testString rangeOfString:tString options:comparisonOptions];

    t = [NSDate timeIntervalSinceReferenceDate];

    if( rangeOfTargetString.location != NSNotFound) {

        // Adjust range to take the line takes URL
        NSRange cutRange = {rangeOfTargetString.location - cutStringValueToGetTheAddress, cutStringValueToGetTheAddress};

        // Line which takes URL
        NSString * lineContainsURL = [testString substringWithRange:cutRange];

        NSRange rangeStartOfURL = [lineContainsURL rangeOfString:@"href"];
        NSRange rangeEndOfURL = [lineContainsURL rangeOfString:@"onclick"];

        NSRange targetRangeOfURL = {rangeStartOfURL.location + 6 ,((rangeEndOfURL.location - 2) - (rangeStartOfURL.location + 6)) };

        targetURL = [lineContainsURL substringWithRange:targetRangeOfURL];

    }

works few millisecond but when I check the time right after the function which call ‘searchCoupang’ time delayed few seconds

for (NSString * e in title) {
    // start to check the time
    NSString * addr = [self searchCoupang:coupangURL targetString:e];
   //  End checking time (takes few seconds)
    self.myTextView.text = addr;
}

Where does this delay come from?

Thanks,

  • 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-27T20:49:17+00:00Added an answer on May 27, 2026 at 8:49 pm

    are you sure it’s not - stringWithContentsOfURL that’s causing the delay? it’s a synchronous function so the application has to wait while it connects to the URL, downloads the data etc. for a production environment, you’d really want to move to an async process. you can do this via threads or grand central dispatch. personally i’ve found GCD to be an easy way to do this kind of thing.

    if it’s not the downloading that’s causing it, i can’t see what would be.. unless you’re talking about massively long strings.. but then that would imply a long download time.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.