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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:06:19+00:00 2026-05-14T18:06:19+00:00

I have an array of dictionaries loaded from a plist (below) called arrayHistory. <plist

  • 0

I have an array of dictionaries loaded from a plist (below) called arrayHistory.

<plist version="1.0">
<array>
    <dict>
        <key>item</key>
        <string>1</string>
        <key>result</key>
        <string>8.1</string>
        <key>date</key>
        <date>2009-12-15T19:36:59Z</date>
    </dict>
...

</array>
</plist>

I filter this array based on ‘item’ so that a second array, arrayHistoryDetail has the same structure as arrayHistory but only contains e.g. ‘item’s equal to ‘1’. These detail items are successfully displayed in a tableView.

I then want to select an item from the tableView, and delete it from the tableView data source, arrayHistoryDetail (line 2 in the code below) – works, then I want to delete the item from the tableView itself (line 3 in the code below) – also works.

My problem is that I also need to delete it from the original arrayHistory, so I tried the following: created a temporary dictionary as an ivar:

NSMutableDictionary *tempDict;
@property (nonatomic, retain) NSMutableDictionary *tempDict;

Then my thinking was to make a copy in line 1 and remove it from the original array in line 4.

1   tempDict = [arrayHistoryDetail objectAtIndex: indexPath.row];
2   [arrayHistoryDetail removeObjectAtIndex: indexPath.row]; 
3   [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
4   [arrayHistory removeObject:tempDict];

Didn’t work. Could someone please guide me in the right direction. I’m thinking that tempDict is a pointer and that removeObject needs a copy? I don’t know.

Thanks.

  • 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-14T18:06:19+00:00Added an answer on May 14, 2026 at 6:06 pm

    A couple of things to try:

    First, make sure that the array you load from the plist file is mutable, i.e.:

    NSMutableArray * arrayHistory;
    

    Next, I wouldn’t use an ivar with a property just for a temporary variable. Your code could instead look something like this, and avoid the ivar/property for tempDict:

    NSDictionary * tempDict;
    tempDict = [[arrayHistoryDetail objectAtIndex:indexPath.row] retain];
    [arrayHistoryDetail removeObjectAtIndex:indexPath.row];
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath
                     withRowAnimation:UITableViewRowAnimationFade];    
    [arrayHistory removeObject:tempDict];
    [tempDict release];
    

    Third, be sure that the code you use to generate arrayHistoryDetail is not making a copy of the data in arrayHistory when it performs the filtering. If it does copy of the items, then tempDict will only hold a copy of the dictionary you want to delete, which means it will have a different pointer value than the actual dictionary in arrayHistory. The removeObject method requires an exact pointer to the object you intend to delete.

    If the copying does turn out to be a problem, you may have change your data structure a little. The best option would be to use assign a unique identifier to each dictionary within arrayHistory, and use that information to determine which dictionary to delete.

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

Sidebar

Related Questions

I wrote a serializer (to Byte Array) for dictionaries that have a string key,
I have a plist (array of dictionaries) which populates a table view and works
I have a plist file which is an array of dictionaries. Where each dictionary
I have an Array of NSDictionary objects. These Dictionaries are parsed from a JSON
I'm trying to display data from a plist that is an array of dictionaries:
I have a plist file which contains an array of dictionaries. Here is one
I have an array of dictionaries from a JSON feed. This populates a UITableView
I have 2 arrays. The first is an array of dictionaries from a JSON
I have an array of dictionaries in an iOS .plist structured similar to the
My plist array of dictionaries is copied from the bundle to the documents directory

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.