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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:26:35+00:00 2026-05-26T06:26:35+00:00

I wonder if it is possible to fill rangeOfString objects of a NSArray. Because

  • 0

I wonder if it is possible to fill rangeOfString objects of a NSArray. Because I have a long list of objects for after rangeOfString:
NSArray biglist´s count is higher than list´s count.

I want to filter away the objects from the small list of the main list.

Please tell me if this is not clear.

My codes below:

NSArray *biglist = [[NSArray alloc] initWithArray:
                        [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"mainlist" ofType:@"txt"]
                                                   encoding:NSUTF8StringEncoding error:NULL] componentsSeparatedByString:@"\n"]];


NSArray *list = [[NSArray alloc] initWithArray:
                        [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"smalllist" ofType:@"txt"]
                                                   encoding:NSUTF8StringEncoding error:NULL] componentsSeparatedByString:@"\n"]];

    for (NSString *listword in list);

    NSMutableArray *wordlist = [[NSMutableArray alloc] init];
    NSMutableArray *worindex = [[NSMutableArray alloc] init];
    NSMutableIndexSet *mindexes = [[NSMutableIndexSet alloc] init];
    NSMutableDictionary *mutdic = [[NSMutableDictionary alloc] init]; 
    NSMutableArray *mutarray = [[NSMutableArray alloc] init];

    for (NSString *s in mainlist)
    {

        NSRange ran = [s rangeOfString:listword];

        if (ran.location !=NSNotFound)
                {
                //my codes here
                }
        }

EDIT:

I think I can solve this by writing

int i;
for (i = 0; i<[list count]; i++)
{
    NSString *same = [list objectAtIndex:i];
    NSLog (@"listword: %@", same);
}

But I am not sure where to place it, inside the for loop s in mainlist or outside.


EDIT: This for loop works inside the main for loop.


EDIT:
Tried these codes, but it doesnt work somehow..

NSArray *list = [[NSArray alloc] initWithArray:
                     [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"small" ofType:@"txt"]
                                                encoding:NSUTF8StringEncoding error:NULL] componentsSeparatedByString:@"\n"]];


    NSArray *mainlist = [[NSArray alloc] initWithArray:
                        [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"mainlist" ofType:@"txt"]
                                                   encoding:NSUTF8StringEncoding error:NULL] componentsSeparatedByString:@"\n"]];

    NSMutableArray *large = [NSMutableArray arrayWithArray:mainlist];


    NSArray *newlarge;

    for (NSString *listword in list)
    {

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF beginswith[c] %@)",listword];
    newlarge = [large filteredArrayUsingPredicate:predicate];
    }

    NSLog (@"large: %@", newlarge);
    NSLog (@"finished!");
  • 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-26T06:26:36+00:00Added an answer on May 26, 2026 at 6:26 am

    I figured it out by myself and solved this 🙂
    It works almost perfectly.

    My codes:

    NSArray *big = [[NSArray alloc] initWithObjects:@"hello ->mache", @"heisann hoppsann ->hiya", @"nei men ->da", @"however ->what", @"may ->april", @"mai ->maj", nil];
    NSArray *small = [[NSArray alloc] initWithObjects: @"heisann ", @"nei men ", @"however ", @"mai", nil];
    NSMutableArray *smallwithh = [[NSMutableArray alloc] init];
    NSMutableIndexSet *mindexes = [[NSMutableIndexSet alloc] init];
    
    for (NSString *same in small)
    {
    
        NSLog (@"listword: %@", same);
    
        for (NSString *s in big)
        {
            NSRange ran = [s rangeOfString:same];
            if (ran.location !=NSNotFound)
    
            {
    
                [smallwithh addObject:s];
                NSUInteger ind = [big indexOfObject:s];
                [mindexes addIndex:ind];
    
            }
    
        }
    
    }
    
    NSLog (@"smallwith: %@", smallwithh);
    
    [smallwithh release];
    
    NSMutableArray *newWords =[NSMutableArray arrayWithArray: big];
    [newWords removeObjectsAtIndexes: mindexes];
    [big release];      
    [small release];
    
    NSLog (@"newWords: %@", newWords);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading this question I started to wonder: is it possible to have a
I wonder if it possible to not have jython automagicaly transform java objects to
I wonder if this is possible with ant and java : I have a
i wonder if this is possible with simple css or if i have to
I wonder is it possible to keep list of files or folders opened before
I wonder if its possible to remove all the objects from the same kind
I wonder if its possible to have a watermark on hotlinked images on an
Wonder if this possible. Saw many posts on adding watermark after the pdf is
I wonder is it possible to have a map that would work like boost
I wonder if is possible to animate the fill color of a path I

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.