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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:27:07+00:00 2026-05-22T18:27:07+00:00

Given: I created a Navigation-based Application for Obj-C iPhone. In the method of –

  • 0

Given:

I created a Navigation-based Application for Obj-C iPhone. In the method of - (void) viewDidLoad in the file RootViewController.m added button +:

 / * Create the button that appears on the Right Side * /
 UIBarButtonItem * rightButton =
 [[UIBarButtonItem alloc]
  initWithBarButtonSystemItem: UIBarButtonSystemItemAdd
  target: self
  action: @ selector (performRight:)];

 / * Assign the buttons to the Navigation Item's properties * /
 self.navigationItem.rightBarButtonItem = rightButton;

 [rightButton release];

In the method of - (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section changed the return value from 1 to 4:

return 4;

A method of - (void) performRight: (id) paramSender

- (Void) performRight: (id) paramSender
{
     / * Perform another action here * /


     // Add a row (?).

}

Question:

How can I make the row added to the table when I click on the button +?

Explanation:

All I found examples using arrays, which I do not need.

Thank you.


This is a default code. In the message above, I wrote a full process of creating the application.

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell.
    return cell;
}

I added this code

[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:row inSection:section]] withRowAnimation:UITableViewRowAnimationBottom];

But I get an error Thread 1: Program received signal "SIGABRT". I quote below NSLog:

2011-05-21 08:17:24.932 MyTable[2981:207] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:995
2011-05-21 08:17:24.948 MyTable[2981:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc15a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f15313 objc_exception_throw + 44
    2   CoreFoundation                      0x00d79ef8 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x008163bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x00091e8b -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 8420
    5   UIKit                               0x000811e8 -[UITableView endUpdates] + 42
    6   MyTable                             0x00003229 -[RootViewController performRight:] + 313
    7   UIKit                               0x000134fd -[UIApplication sendAction:to:from:forEvent:] + 119
    8   UIKit                               0x00225cc3 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
    9   UIKit                               0x000134fd -[UIApplication sendAction:to:from:forEvent:] + 119
    10  UIKit                               0x000a3799 -[UIControl sendAction:to:forEvent:] + 67
    11  UIKit                               0x000a5c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    12  UIKit                               0x000a47d8 -[UIControl touchesEnded:withEvent:] + 458
    13  UIKit                               0x00037ded -[UIWindow _sendTouchesForEvent:] + 567
    14  UIKit                               0x00018c37 -[UIApplication sendEvent:] + 447
    15  UIKit                               0x0001df2e _UIApplicationHandleEvent + 7576
    16  GraphicsServices                    0x00ffa992 PurpleEventCallback + 1550
    17  CoreFoundation                      0x00da2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    18  CoreFoundation                      0x00d02cf7 __CFRunLoopDoSource1 + 215
    19  CoreFoundation                      0x00cfff83 __CFRunLoopRun + 979
    20  CoreFoundation                      0x00cff840 CFRunLoopRunSpecific + 208
    21  CoreFoundation                      0x00cff761 CFRunLoopRunInMode + 97
    22  GraphicsServices                    0x00ff91c4 GSEventRunModal + 217
    23  GraphicsServices                    0x00ff9289 GSEventRun + 115
    24  UIKit                               0x00021c93 UIApplicationMain + 1160
    25  MyTable                             0x00002979 main + 121
    26  MyTable                             0x000028f5 start + 53
    27  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language:  auto; currently objective-c

What kind of data are you presenting
that doesn’t need an array? – Deepak 7
hours ago

This is a sample application, which posed to perform at Courses iOS Developer.

  • 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-22T18:27:08+00:00Added an answer on May 22, 2026 at 6:27 pm

    Solution!

    In RootViewController.h add

    @ interface RootViewController:
    UITableViewController {
         int rows; }
    

    In RootViewController.m add

     - (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section {
          return rows; }
    

    and

     - (Void) performRight: (id) paramSender
    
     {
          // Insert a row
          ++rows;
          [self.tableView reloadData]; }
    

    In RootViewController.xib add outlets

     tableView - Table View
    

    Thank you all for your support!

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

Sidebar

Related Questions

Given a DataSet, I'm left joining DataTables[1-n] onto DataTable[0]. I have created a method
The code generated by Xcode when creating a navigation based application which uses core
Given an Oracle table created using the following: CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME
when a dll is created out of the source code in a given namespaces
I have an application based on the Core Data Books example, and I'm coming
I am attempting to display a dynamically created SVG inline in a dojo based
A have a view created with Drupal's Views module, and have given it a
I have a strange 'problem' with one of my created queries. Given the next
Given an empty MimeMessage created with e.g. MimeOleCreateMessage function, how can I initialize it
So I created a layout in Expression Blend 4 for my Silverlight application. Now

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.