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 single frame of a video file from a server
Possible Duplicate: How to download a text file or some objects from webpage using
I am attempting to just download the html from a webpage, but I want
I want to save zip archive from server to user computer. I have web
I want to download a video from the internet in my application. Hence, I
I want to download image from url and store in sdcard's folder. If folder
I want to download files from internet in my Android Native application. I was
I want to send an email straight from my webpage, but I don't have
I have to download a lot of documents from a webpage. They are wmv
I was using wget with system call (c++) to save a webpage from internet

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.