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

  • Home
  • SEARCH
  • 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 8975811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:58:29+00:00 2026-06-15T18:58:29+00:00

I have an app (Cocoa Touch, Web Browser), however I need to be able

  • 0

I have an app (Cocoa Touch, Web Browser), however I need to be able to compare an NSString with thousands of other strings. Here’s the deal.

When a WebView loads, I get the URL. I need to compare this URL with literally thousands of results (27,847). Each of those numbers represents a line of text in a plain text file.

I would like to know the best way to go about getting the data from the text file, and comparing it with the NSString. I need to know if the URL that the WebView is loading contains any of these strings.

The app needs to be very fast, so I can’t just parse through every line in the text file, turn it into an array, and then compare each and every result.

Please share your ideas. 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-06-15T18:58:30+00:00Added an answer on June 15, 2026 at 6:58 pm

    I think the cleanest solution is to:

    • Create a web service that can offload the work to a server and return a response. Since it sounds like you’re building a web protection service, your database may grow to be quite substantial over time, and you can just scale your server up to increase its speed. Furthermore, you don’t want to have to update your app every time the lookup data changes.

    Other options are:

    • Use a local SQLite database. SQL databases should perform lookups relatively fast.

    • If you don’t want to use any database, have you tried putting all the search strings into an NSDictionary or NSMutableDictionary object? This way, you would just check if the valueForKey: for the string you’re searching for is nil.

    Sample code for this:

    NSDictionary *searchDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                      [NSNumber numberWithBool:YES], @"google.com",
                                      [NSNumber numberWithBool:YES], @"yahoo.com",
                                      [NSNumber numberWithBool:YES], @"bing.com",
                                      nil];
    
    NSString *searchString = @"bing.com";
    
    if ([searchDictionary valueForKey:searchString]) {
        // search string found
    } else {
        // search string not found
    }
    

    Note: if you want the NSDictionary to perform case-insensitive comparisons, pre-load all values lowercase, and make the search string lowercase when using valueForKey:.

    How much memory this could take is a whole other story, but I don’t see how this comparison could be made much faster locally. I strongly recommend the remove web service approach, though.

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

Sidebar

Related Questions

I have a very simple Mac Cocoa app that just has a Web View
I have a MainViewController in my Cocoa Touch app which shows a status view
I'm using Cocoa Touch to build an iPhone app. I have an NSMutableArray called
Have patience with me, I'm still learning Cocoa Touch. Other -viewDidLoad not being called
I have a cocoa-touch app, using the core data framework. I've created a xcdatamodel
1>1st project : I have created a window based cocoa touch app just for
I have a Cocoa app with a table view and a few other controls.
I have a basic Cocoa app with a custom NSCollectionView that overrides drawRect: to
I have a button in my Cocoa app that opens a url in the
I have a graphics editing cocoa app on Mac OSX that produces 32 by

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.