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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:42:57+00:00 2026-06-02T11:42:57+00:00

So, after I load the animations sprite frames into the cache in the game

  • 0

So, after I load the animations sprite frames into the cache in the game I’m making, I count how many frames each animation has. I do this because in the game config there’s a value for the duration of each animation, and when I create the CCAnimation, the delay attr is AnimationDuration/FramesAmount.

To count the amount of frames per animation, I open the animations.plist and iterate the entries getting every key, removing the file name, and storing every frame (as key) in a NSMutableDictionary with the amount as an NSNumber that I update through the iteration. The thing is that I don’t like how I need to get the NSNumber intValue, do +1, and then alloc another NSNumber and re set the value for the key. Is there any better way of doing this?? Thanks all! (like.. in php OR JS would be dictonary[frame]++)

Here is the code:

NSString *finalPath = [path stringByAppendingPathComponent:@"animations.plist"];
NSDictionary *plistData = [[NSDictionary dictionaryWithContentsOfFile:finalPath] retain];

NSMutableDictionary *conf = [NSMutableDictionary dictionary];
NSDictionary *frames = [plistData valueForKey:@"frames"];

NSNumber *amount;
for( int i=0; i < [frames count]; i++ ) {
    NSString *frame = [[frames allKeys] objectAtIndex:i];

    NSRange range = [frame rangeOfString:@"/" options:NSBackwardsSearch];
    frame = [frame substringToIndex:range.location];

    if( [conf objectForKey:frame] == nil )
        amount = [[NSNumber alloc] initWithInt:1];
    else
        amount = [[NSNumber alloc] initWithInt:[[conf objectForKey:frame] intValue]+1];//amount++...

    [conf setObject:amount forKey:frame];
}
  • 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-02T11:42:59+00:00Added an answer on June 2, 2026 at 11:42 am

    Rather than an NSNumber you can create a MyNumber object with an int/long whatever in it and a property to access the number without having to do the whole alloc thing every time you change it. Could even have an addTo method.

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

Sidebar

Related Questions

I need to perform an action after a jQuery .load call, currently this is
After loading a PHP template (using jQuery's load function), this simple script won't make
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
I load an AJAX request after an animation finishes. However, I'd like to load
I want show annotation view (above one of my pin) after load map. For
Having a little difficulty getting a function to call after a .load: $(function(){ $('a.pageFetcher').click(function(){
js doesn't work if I don't refresh the page after first load,and div's background-img
i'm working on a project with a lot of images but after i load
I need certain scripts to refire after an AJAX load. How could I accomplish
The first page I load from my site after not visiting it for 20+

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.