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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:48:19+00:00 2026-05-31T19:48:19+00:00

what I want: Download a webpage from a server > Save content in a

  • 0

what I want:

Download a webpage from a server > Save content in a NSString > Search through the content via IsEqualToString > Set text to a label when a specified keyword was found.

I was able to download the webpage, show content in a UITextView but my if function always executes the else part doesn’t matter what I’m searching for in IsEqualToString. Please help.

Actually I should see in my label: Course is open and NOT Sorry, course is closed. See screenshot.

//
//  ViewController.h
//  TestingHTML2
//
//  Created by Marc Woerner on 20.03.12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    NSMutableData *myData;
    NSURLConnection *myConnection;
}

@property (strong, nonatomic) IBOutlet UITextView *myTextView;
@property (strong, nonatomic) IBOutlet UILabel *myLabel;

@end

ViewController.m

//
//  ViewController.m
//  TestingHTML2
//
//  Created by Marc Woerner on 20.03.12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize myTextView;
@synthesize myLabel;


- (void)viewDidLoad
{
    [super viewDidLoad];
    if (myConnection == nil) {
        myData = [NSMutableData new];
        NSString *urlString = [NSString stringWithFormat:@"http://www.golfplatz-altenstadt.de"];
        myConnection =[NSURLConnection connectionWithRequest:
                      [NSURLRequest requestWithURL:
                      [NSURL URLWithString:urlString]] 
                        delegate:self];
    }
}




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




- (void) initializeVariablesAgain {
    myData = nil;
    myConnection = nil; 
    myTextView = nil;
}




- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

    NSString *stringToLookup = [[NSString alloc]initWithData:myData encoding:NSASCIIStringEncoding];

    if ([stringToLookup isEqualToString:@"platz_bespielbar"]) {
        myLabel.text = @"Course is open";
    } else {
        myLabel.text = @"Sorry, course is closed";
    }

    myTextView.text = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding];

    [self initializeVariablesAgain];
}

When I look through the downloaded web page myself I see an entry:

platz_bespielbar

So why does my function don’t work?

enter image description here

  • 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-31T19:48:20+00:00Added an answer on May 31, 2026 at 7:48 pm

    It’s because you are checking the whole string and not only part of it.

    if ([stringToLookup isEqualToString:@"platz_bespielbar"]) {
    

    should be

    if ([stringToLookup rangeOfString:@"platz_bespielbar"].location != NSNotFound]) {
    

    Hope it helps

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

Sidebar

Related Questions

I want to download a PDF file from a SQL Server database which is
I want to download a document from a server. Creating the document in the
I want to download http://www.wordwebonline.com/search.pl?w=humane this webpage on UNIX. I tried to use wget
I want to download a large amount of Files to my Server. I have
I want to download a wav file from a web service, cache it on
I want to download and parse webpage using python, but to access it I
I have to download a lot of documents from a webpage. They are wmv
From an audio-file I want to be able to expose audio on a webpage,
I'm trying to scrape content from a webpage. Currently I'm stuck at a place
I need to get a large amount of data back from a server via

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.