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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:27:26+00:00 2026-05-28T19:27:26+00:00

I have some NSMutableArray in tableView which contain class Lesson @interface Lesson : NSObject

  • 0

I have some NSMutableArray in tableView which contain class Lesson

@interface Lesson : NSObject <NSCoding>{

    NSString *time1;
    NSString *time2;
    NSString *predmet;
    NSString *namPrepod;
    NSString *zamet;
}

I move row in tableview………………………………………………………………………………………………………………..

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 
{
    if(segmentedControl.selectedSegmentIndex==0)
    {
    if(fromIndexPath.section==0)
    {
       NSMutableArray *r = [[Singleton sharedInstance].chetNedel.monday objectAtIndex:fromIndexPath.row]; 
       [[Singleton sharedInstance].chetNedel.monday  removeObjectAtIndex:fromIndexPath.row];
       [[Singleton sharedInstance].chetNedel.monday  insertObject:r atIndex:toIndexPath.row];
    }
    if(fromIndexPath.section==1)
    {
        NSMutableArray *r = [[Singleton sharedInstance].chetNedel.tuesday objectAtIndex:fromIndexPath.row]; 
        [[Singleton sharedInstance].chetNedel.monday  removeObjectAtIndex:fromIndexPath.row];
        [[Singleton sharedInstance].chetNedel.monday  insertObject:r atIndex:toIndexPath.row];
    }

but when I move row in program I have got error on this lines

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      ..........
if(segmentedControl.selectedSegmentIndex==0)
    {
        time1 = [[[UILabel alloc] init] autorelease];
        time1.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
        time1.tag = tagtime1;
        time1.backgroundColor = [UIColor clearColor];
        if(indexPath.section ==0)
            time1.text =[(Lesson *) [[Singleton sharedInstance].chetNedel.monday objectAtIndex:indexPath.row] time1];
        if(indexPath.section ==1)
            time1.text =[(Lesson *) [[Singleton sharedInstance].chetNedel.tuesday objectAtIndex:indexPath.row] time1];
        if(indexPath.section ==2)
            time1.text =[(Lesson *) [[Singleton sharedInstance].chetNedel.wednesday objectAtIndex:indexPath.row] time1];
        if(indexPath.section ==3)
            time1.text =[(Lesson *) [[Singleton sharedInstance].chetNedel.thirsday objectAtIndex:indexPath.row] time1];
        if(indexPath.section ==4)
            time1.text =[(Lesson *) [[Singleton sharedInstance].chetNedel.friday objectAtIndex:indexPath.row] time1];
        if(indexPath.section ==5)
            time1.text =[(Lesson *) [[Singleton sharedInstance].chetNedel.saturday objectAtIndex:indexPath.row] time1];
        time1.frame = CGRectMake(8, 12, 300-124, 11);
     ...........
 [cell.contentView addSubview:time1];

what i do wrong?

  • 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-28T19:27:27+00:00Added an answer on May 28, 2026 at 7:27 pm

    What error are you getting exactly? Looking at your code however I think the problem happens when you do the removeObjectAtIndex followed by insertObject:atIndex:. After you remove the object, the indexes of the array are recalculated and now you have 1 less object in your array. So if you then do the insertObject:atIndex without decreasing the index where you want to put it, you’re not going to end up with it where you want. I suggest you combine both lines into one and use exchangeObjectAtIndex:withObjectAtIndex: instead. Here’s updated code:

        if(fromIndexPath.section==0)
    {
       [[Singleton sharedInstance].chetNedel.monday exchangeObjectAtIndex:fromIndexPath.row withObjectAtIndex:toIndexPath.row];
    }
    if(fromIndexPath.section==1)
    {
        [[Singleton sharedInstance].chetNedel.tuesday exchangeObjectAtIndex:fromIndexPath.row withObjectAtIndex:toIndexPath.row];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some ASP.NET web services which all share a common helper class they
I have some classes layed out like this class A { public virtual void
I have some C# / asp.net code I inherited which has a textbox which
I have a serious long else if statement which contains some links and some
I have a UITableView which shows some information. The informations are from a XMLFile.
I have some problems during when and which object to be release You can
In my application, I have an NSTableView which should contain a list of files.
I have an NSMutableArray and I load my tableview from it. Now I have
I have a class that mimics the behavior of the UIImagePickerController except with some
I have some UI in VB 2005 that looks great in XP Style, but

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.