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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:36:53+00:00 2026-06-03T07:36:53+00:00

The basic idea is to iterate through a directory full of .plists which have

  • 0

The basic idea is to iterate through a directory full of .plists which have NSDictionary objects that contain a monetary value.

Question

How can I iterate through all of the directory contents and extract all the “Current Value” objects and add them together to get a total amount?

Example

NSArray * itemList = [MANAGER contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@",INVENTORY_PATH] error:nil];
for ( NSString * item in itemList )
{
    NSDictionary * currentItem = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",INVENTORY_PATH, item]];

    float monetaries = [[currentItem objectForKey:@"Current Value"] floatValue];

    NSLog(@"Current Value: %.2f",monetaries);       
} 

Current output

2012-05-06 22:11:33.583 WrightsCS[3151:15803] Current Value: 350.99
2012-05-06 22:11:33.584 WrightsCS[3151:15803] Current Value: 321.54

Desired output

2012-05-06 22:11:33.584 WrightsCS[3151:15803] Total Value: 672.53

Solution

float total = 0.0f ;
float monetaries = 0.0f;

NSArray * itemList = [MANAGER contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@",INVENTORY_PATH] error:nil];
for ( NSString * item in itemList )
{
    NSDictionary * currentItem = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",INVENTORY_PATH, item]];

    monetaries = [[currentItem objectForKey:@"Current Value"] floatValue];
    total += monetaries ;     

    NSLog(@"Current Value: %.2f",monetaries);  
}    

NSLog(@"Total Value: %.2f",total);  

Solution Output

2012-05-06 22:26:05.460 WrightsCS[3205:15803] Current Value: 350.99
2012-05-06 22:26:05.462 WrightsCS[3205:15803] Current Value: 321.54
2012-05-06 22:26:05.462 WrightsCS[3205:15803] Total Value: 672.53
  • 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-03T07:36:54+00:00Added an answer on June 3, 2026 at 7:36 am

    Couldn’t you just keep a running total or did I miss it?

    NSArray * itemList = [MANAGER contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@",INVENTORY_PATH] error:nil];
    
    float total = 0.0f ;
    for ( NSString * item in itemList )
    {
        NSDictionary * currentItem = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",INVENTORY_PATH, item]];
    
        float monetaries = [[currentItem objectForKey:@"Current Value"] floatValue];
        total += monetaries ;
    //    NSLog(@"Current Value: %.2f",monetaries);       
    } 
    
    NSLog(@"Total Value: %.2f",monetaries);       
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the basic idea is that you have some class that has a reference type
The basic idea is that I have a family of classes that all do
From a blog: The basic idea with CSS expressions is that you will have
The basic idea is this: I have a form that generates form fields dynamically
The basic idea is that I have a native function I want to call
The basic idea of what we are trying to do is that we have
I have a basic idea about open graph and that it has come up
I have basic idea on Kilo Virtual Machine on Mobiles , I have clear
I have some basic idea on how to do this task, but I'm not
I have a basic implementation of alpha-beta pruning but I have no idea how

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.