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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:51:51+00:00 2026-05-15T08:51:51+00:00

Update: It seems to be a problem with the scope of the results. titleForHeaderInSection

  • 0

Update: It seems to be a problem with the scope of the “results.” titleForHeaderInSection seems to be unaware of the “results” arrays content. Will post once I find a solution just in case anyone stumbles across this with the same problem.

How would I set each individual row in cellForRowAtIndexPath to the results of an array populated by a Fetch Request? (Fetch Request made when button is pressed.)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //  ... set up cell code here ...
    cell.textLabel.text = [results objectAtIndex:indexPath valueForKey:@"name"];

}

warning: 'NSArray' may not respond to '-objectAtIndexPath:'

Edit:

- (NSArray *)SearchDatabaseForText:(NSString *)passdTextToSearchFor{
    NSManagedObject *searchObj;
    XYZAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

    NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext;
    NSFetchRequest *request = [[NSFetchRequest alloc] init]; 
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name contains [cd] %@", passdTextToSearchFor]; 
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext]; 
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO]; 
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];   

    [request setSortDescriptors:sortDescriptors];
    [request setEntity: entity]; 
    [request setPredicate: predicate]; 

    NSError *error;

    results = [managedObjectContext executeFetchRequest:request error:&error];
//  NSLog(@"results %@", results);

    if([results count] == 0){
        NSLog(@"No results found");
        searchObj = nil;
        self.tempString = @"No results found.";
    }else{
        if ([[[results objectAtIndex:0] name] caseInsensitiveCompare:passdTextToSearchFor] == 0) {
            NSLog(@"results %@", [[results objectAtIndex:0] name]);
            searchObj = [results objectAtIndex:0];
        }else{
            NSLog(@"No results found");
            self.tempString = @"No results found.";
            searchObj = nil;
        }       
    }

    [tableView reloadData]; 

    [request release];
    [sortDescriptors release];

    return results;
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    textToSearchFor =  mySearchBar.text;
    results = [self SearchDatabaseForText:textToSearchFor];
    self.tempString = [myGlobalSearchObject valueForKey:@"name"];   
    NSLog(@"results count: %d", [results count]);
    NSLog(@"results 0: %@", [[results objectAtIndex:0] name]);
    NSLog(@"results 1: %@", [[results objectAtIndex:1] name]);
}
@end

Console prints:

2010-06-10 16:11:18.581 XYZApp[10140:207] results count: 2
2010-06-10 16:11:18.581 XYZApp[10140:207] results 0: BB Bugs
2010-06-10 16:11:18.582 XYZApp[10140:207] results 1: BB Annie
Program received signal:  “EXC_BAD_ACCESS”.
(gdb) 

Edit 2:

BT:

#0  0x95a91edb in objc_msgSend ()
#1  0x03b1fe20 in ?? ()
#2  0x0043cd2a in -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] ()
#3  0x0043ca9e in -[UITableViewRowData invalidateAllSections] ()
#4  0x002fc82f in -[UITableView(_UITableViewPrivate) _updateRowData] ()
#5  0x002f7313 in -[UITableView noteNumberOfRowsChanged] ()
#6  0x00301500 in -[UITableView reloadData] ()
#7  0x00008623 in -[SearchViewController SearchDatabaseForText:] (self=0x3d16190, _cmd=0xf02b, passdTextToSearchFor=0x3b29630) 
#8  0x000086ad in -[SearchViewController searchBarSearchButtonClicked:] (self=0x3d16190, _cmd=0x16492cc, searchBar=0x3d2dc50)
#9  0x0047ac13 in -[UISearchBar(UISearchBarStatic) _searchFieldReturnPressed] ()
#10 0x0031094e in -[UIControl(Deprecated) sendAction:toTarget:forEvent:] ()
#11 0x00312f76 in -[UIControl(Internal) _sendActionsForEventMask:withEvent:] ()
#12 0x0032613b in -[UIFieldEditor webView:shouldInsertText:replacingDOMRange:givenAction:] ()
#13 0x01d5a72d in __invoking___ ()
#14 0x01d5a618 in -[NSInvocation invoke] ()
#15 0x0273fc0a in SendDelegateMessage ()
#16 0x033168bf in -[_WebSafeForwarder forwardInvocation:] ()
#17 0x01d7e6f4 in ___forwarding___ ()
#18 0x01d5a6c2 in __forwarding_prep_0___ ()
#19 0x03320fd4 in WebEditorClient::shouldInsertText ()
#20 0x0279dfed in WebCore::Editor::shouldInsertText ()
#21 0x027b67a5 in WebCore::Editor::insertParagraphSeparator ()
#22 0x0279d662 in WebCore::EventHandler::defaultTextInputEventHandler ()
#23 0x0276cee6 in WebCore::EventTargetNode::defaultEventHandler ()
#24 0x0276cb70 in WebCore::EventTargetNode::dispatchGenericEvent ()
#25 0x0276c611 in WebCore::EventTargetNode::dispatchEvent ()
#26 0x0279d327 in WebCore::EventHandler::handleTextInputEvent ()
#27 0x0279d229 in WebCore::Editor::insertText ()
#28 0x03320f4d in -[WebHTMLView(WebNSTextInputSupport) insertText:] ()
#29 0x0279d0b4 in -[WAKResponder tryToPerform:with:] ()
#30 0x03320a33 in -[WebView(WebViewEditingActions) _performResponderOperation:with:] ()
#31 0x03320990 in -[WebView(WebViewEditingActions) insertText:] ()
#32 0x00408231 in -[UIWebDocumentView insertText:] ()
#33 0x003ccd31 in -[UIKeyboardImpl acceptWord:firstDelete:addString:] ()
#34 0x003d2c8c in -[UIKeyboardImpl addInputString:fromVariantKey:] ()
#35 0x004d1a00 in -[UIKeyboardLayoutStar sendStringAction:forKey:] ()
#36 0x004d0285 in -[UIKeyboardLayoutStar handleHardwareKeyDownFromSimulator:] ()
#37 0x002b5bcb in -[UIApplication handleEvent:withNewEvent:] ()
#38 0x002b067f in -[UIApplication sendEvent:] ()
#39 0x002b7061 in _UIApplicationHandleEvent ()
#40 0x02542d59 in PurpleEventCallback ()
#41 0x01d55b80 in CFRunLoopRunSpecific ()
#42 0x01d54c48 in CFRunLoopRunInMode ()
#43 0x02541615 in GSEventRunModal ()
#44 0x025416da in GSEventRun ()
#45 0x002b7faf in UIApplicationMain ()
#46 0x00002578 in main (argc=1, argv=0xbfffef5c) at /Users/default/Documents/iPhone Projects/XYZApp/main.m:14

edit:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return[results count];
 }
  • 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-15T08:51:51+00:00Added an answer on May 15, 2026 at 8:51 am

    There’s no method -objectAtIndex:valueForKey:. Do you mean

    cell.textLabel.text = [[myArray objectAtIndex:indexPath.row] valueForKey:@"object"];
    //                     ^                               ****^
    

    ?

    To composite Objective-C method calls you need multiple brackets, as shown by the ^‘s. Also, -objectAtIndex: only accepts an NSInteger, but indexPath is a NSIndexPath. To get the row from the index path, use the .row property, as shown by the *‘s.


    Edit:

    You seems to confuse -numberOfSectionsInTableView: with -tableView:numberOfRowsInSection:. A table contains one or more sections, and each section contains many rows (table view cells).

    Your table have only 1 section, so you should return 1, or just remove this method as 1 is the default. And implement -tableView:numberOfRowsInSection: as

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
       return [results count];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update Solution Found See Bottom of post if interested Seems simple enough and for
-----UPDATE----- Well, seems that the problem was in last.id . When database is created
Update: This is, as I was told, no principle Python related problem, but seems
Since recent update Xcode 4.3 now seems to default to LLDB debugger. I just
I seem to have a tricky problem since the latest ADT update to release
UPDATE: Seems to me like it is pretty much an Apple bug. I tried
A recent Windows Update or software installation seems to have broken my one week
It seems that when I use a tool (such as winmerge) to update my
I want to update fontconfig to a newer version but it seems that the
I am attempting to update an existing record using JPA. The following link seems

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.