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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:09:38+00:00 2026-06-16T09:09:38+00:00

So, I have an UITableView which holds entries for an app I am making.

  • 0

So, I have an UITableView which holds entries for an app I am making. The entriesViewController is its own class, with a .xib file. I have a button that adds a new item.

It does this with the following code:

-(IBAction)newItem:(id)sender {
    LEItem *newItem = [[LEItemStore sharedStore] createItem];
    NSLog(@"New Item = %@", newItem);
    [TableView reloadData];
}

Now this works, and adds the item, however it puts it at the bottom of the list. Since this app logs things for days, I do not want the items in this order. The newest items should be placed at the top of the list. How do I do this? I didn’t see any easy way to add items to the table view at the top, but I might be missing something pretty basic.

This doesn’t seem like it should be hard, I am probably just overlooking something.

Ideas are welcome.

Edit:

Here is LEItem Store:

//
//  LEItemStore.m
//
//  Created by Josiah Bruner on 10/16/12.
//  Copyright (c) 2012 Infinite Software Technologies. All rights reserved.
//

#import "LEItemStore.h"
#import "LEItem.h"

@implementation LEItemStore
+ (LEItemStore *)sharedStore
{
    static LEItemStore *sharedStore = nil;
    if (!sharedStore)
        sharedStore = [[super allocWithZone:nil] init];

    return sharedStore;
}

+ (id)allocWithZone:(NSZone *)zone
{
    return [self sharedStore];
}

-(id)init
{
    self = [super init];
    if (self) {
        NSString *path = [self itemArchivePath];
        allItems = [NSKeyedUnarchiver  unarchiveObjectWithFile:path];

        if (!allItems)
        {
            allItems = [[NSMutableArray alloc] init];
        }
    }

    return self;
}

- (NSArray * )allItems
{
    return allItems;
}
-(LEItem *)createItem
{
    LEItem *p = [LEItem addNewItem];

    [allItems addObject:p];

    return p;
}

- (void)removeItem:(LEItem *)p
{
    [allItems removeObjectIdenticalTo:p];
}

-(void)moveItemAtIndex:(int)from toIndex:(int)to
{
    if (from == to) {
        return;
    }
    LEItem *p = [allItems objectAtIndex:from];

    [allItems removeObjectAtIndex:from];

    [allItems insertObject:p atIndex:to];
}

- (NSString *)itemArchivePath {
    NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [documentDirectories objectAtIndex:0];

    return [documentDirectory stringByAppendingPathComponent:@"item.archive"];
}

-(BOOL)saveChanges {
    NSString *path = [self itemArchivePath];

    return [NSKeyedArchiver archiveRootObject:allItems toFile:path];
}
@end
  • 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-16T09:09:39+00:00Added an answer on June 16, 2026 at 9:09 am

    It looks like the simplest solution would be to modify -[LEItemStore createItem] to this:

    -(LEItem *)createItem {
        LEItem *p = [LEItem addNewItem];
        [allItems insertObject:p atIndex:0];    
        return p;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a selectedArray defined as a property in my file that holds which
I am making an iPhone app. In this app I have a UITableView which
In my app, I have a UITableView which has some custom cells and in
I have a UITableView which loads its data from the web. It takes a
In my iOS app have a UITableView which contains a custom subview in one
I have a UITableView which generates its data from a pList. I have a
I have a UITableView which is made up of my own custom UITableViewCell s,
I have a UITableView which downloads its tableviewcells images from a server. I observed
I have a UITableView which uses a UIView subclass for its backgroundView and selectedBackgroundView
I have a grouped UITableView in my UIViewController class and I'm finding that at

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.