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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:22:29+00:00 2026-06-10T15:22:29+00:00

the following code attempts to search for a String given by a cell.textlabel.text in

  • 0

the following code attempts to search for a String given by a cell.textlabel.text in a CSV-File

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//create singleton instance
Globals *myGlobals = [Globals sharedGlobals];

//get searchstring form cell
NSString *stringToFind = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;

//get Path of csv and write data in string:allLines
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"ITILcsv" ofType:@"txt"];
if(filePath){

    NSString *wholeCSV = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    NSArray *allLines = [wholeCSV componentsSeparatedByString:@"\n"];
    //declaration
    NSArray *currentArray = nil;
    NSString *currentSearchString = nil;

//look for searchstring in 4th line of csv, if found write whole line to a singleton-variable
    for (int i=0 ; i < [allLines count]; i++){

        currentArray = [[allLines objectAtIndex:i] componentsSeparatedByString:@";"];
        currentSearchString = [currentArray objectAtIndex:3];

        if ([stringToFind isEqualToString:currentSearchString]){

            [myGlobals setCurrentLine:currentArray];
        }

    }


}

Working quite a bit with csv-files in my current project I’m pretty sure this should work, but somehow the app always crashes when the function is called.

Through a whole bunch of testing I’m pretty sure that the problem is in the following lines:

 currentArray = [[allLines objectAtIndex:i] componentsSeparatedByString:@";"];
        currentSearchString = [currentArray objectAtIndex:3];

The program works with these two lines commented out, but doesnt implement the desired function 😉
I have no clue what the problem might be?

The Error is a SIGABRT in “main”.

Thanks in advance everybody.

  • 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-10T15:22:31+00:00Added an answer on June 10, 2026 at 3:22 pm

    Might crash when your currentArray has elements less than 3 and you are referring index 3. So in that case your finding for an index which is out of reach.

    So better approach would be

    for (int i=0 ; i < [allLines count]; i++)
    {
        currentArray = [[allLines objectAtIndex:i] componentsSeparatedByString:@";"];
    
        // check and then pick
        if ([currentArray count] > 3)
        {
            currentSearchString = [currentArray objectAtIndex:3];
    
            if ([stringToFind isEqualToString:currentSearchString])
            {
                [myGlobals setCurrentLine:currentArray];
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code which attempts to determine whether a given
The following code snippet attempts to create a Tib DaemonManager connecting to a particular
I have the following code that attempts to connect to various hosts and move
The following code is an attempt to search google, and return the results as
How can I modify the following code snippet so that the attempts variable is
I've the following code, though I set the profile_directory Firefox webdriver still attempts to
In my the following code, I am traversing a graph through breadth first search
The following code, which attempts to specialize class template 'special', based on the return
The following piece of code attempts to create a map that shows the minimum
Given the following code public static Bitmap PrintWindow(IntPtr hWnd) { int width = GetWindowInfo(hWnd).rcWindow.Width;

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.