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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:30:49+00:00 2026-05-31T13:30:49+00:00

Even though i know there are at least 2 or 3 topics with this

  • 0

Even though i know there are at least 2 or 3 topics with this name, i didnt find a proper answer so far to my problem :
I want to edit a Plist (which has been created by zwoptex (image/animations program)) in order to divide every number in it by 2.
So in my plist i do have some keys like “spriteOffset” with {{182, 160}, {58,75}} or {192, 165} as value. Those are NSStrings, and i just want to modify the numbers so i need to check if there’s a “{” or a space or such, then casting the number.
The thing is i don’t really know how to do it…..
Also, it seems that i’m missing something with my plist management. I’ve put some NSLogs for displaying every of those strings in my plist, but…. nothing gets displayed…
So here is my code :

-(void)DivideValues
{
   for(NSString * plistName in plistSubpathsByName)
{
    NSMutableDictionary* infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@.plist",plistName]];

    for(NSDictionary * sprite in [infoDict objectForKey:@"frames"])
    {
        for(NSString * string in [infoDict objectForKey:@"spriteColorRect"])
        {
            NSLog(@"%@",string);
        }
        for(NSString * string in [infoDict objectForKey:@"spriteOffset"])
        {
            NSLog(@"%@",string);
        }
        for(NSString * string in [infoDict objectForKey:@"spriteSize"])
        {
            NSLog(@"%@",string);
        }
        for(NSString * string in [infoDict objectForKey:@"spriteSourceSize"])
        {
            NSLog(@"%@",string);
        }
        for(NSString * string in [infoDict objectForKey:@"textureRect"])
        {
            NSLog(@"%@",string);
        }
    }

    }
}

Thanks for any response, and i wish you all good luck for your career/passion

  • 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-31T13:30:50+00:00Added an answer on May 31, 2026 at 1:30 pm

    Ok I did succeed so if anyone is interested here is the code :

    -(void)DivideValues
    {
    for(NSString * xflName in [xflSubpathsByName objectEnumerator]){
    
        NSMutableDictionary* infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:[sourceFolder stringByAppendingPathComponent:xflName]];
    
        NSDictionary * dictionary = [infoDict objectForKey:@"frames"];
        NSMutableDictionary * mutabledictionary = [[dictionary mutableCopy] autorelease];
    
        for(NSString * pngFileName in dictionary) {
    
            NSDictionary * sprite = [dictionary objectForKey:pngFileName];
    
            NSLog(pngFileName);
            NSMutableDictionary * mutablesprite = [[sprite mutableCopy] autorelease];
    
            NSString * newstring = [self castSpriteRect:[sprite objectForKey:@"spriteColorRect"]];
            [mutablesprite setObject:newstring forKey:@"spriteColorRect"];
    
            newstring = [self castSprite:[sprite objectForKey:@"spriteOffset"]];
            [mutablesprite setObject:newstring forKey:@"spriteOffset"];
    
            newstring = [self castSprite:[sprite objectForKey:@"spriteSize"]];
            [mutablesprite setObject:newstring forKey:@"spriteSize"];
    
            newstring = [self castSprite:[sprite objectForKey:@"spriteSourceSize"]];
            [mutablesprite setObject:newstring forKey:@"spriteSourceSize"];
    
            newstring = [self castSpriteRect:[sprite objectForKey:@"textureRect"]];
            [mutablesprite setObject:newstring forKey:@"textureRect"];
    
            [mutabledictionary setObject:mutablesprite forKey:pngFileName];
    
        }
    
        [infoDict setObject:mutabledictionary forKey:@"frames"];
                [infoDict writeToFile:[sourceFolder stringByAppendingPathComponent:xflName] atomically:NO];
        }
    
    if(!cancelling)
        ++digestStage;
    else
        digestStage = End;
    }
    
    -(NSString *)castSprite:(id)obj{
    CGPoint point = NSPointFromString((NSString *)obj);
    int i = (int)point.x%2 == 0 ?(int)point.x/2:1+(int)point.x/2;
    int j = (int)point.y%2 == 0 ?(int)point.y/2:1+(int)point.y/2;
    NSString * res = [NSString stringWithFormat:@"{%d, %d}",i,j];
    return res;
    }
    
    -(NSString *)castSpriteRect:(id)obj{
    CGRect point = NSRectFromString((NSString *)obj);
    int i = (int)point.origin.x%2 == 0 ?(int)point.origin.x/2:1+(int)point.origin.x/2;
    int j = (int)point.origin.y%2 == 0 ?(int)point.origin.y/2:1+(int)point.origin.y/2;
    int y = (int)point.size.width%2 == 0 ?(int)point.size.width/2:1+(int)point.size.width/2;
    int x = (int)point.size.height%2 == 0 ?(int)point.size.height/2:1+(int)point.size.height/2;
    NSString * res = [NSString stringWithFormat:@"{{%d, %d}, {%d, %d}}",i,j,y,x];
    return res;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's a name for this, but I don't know what it is so it's
One of my co-workers claims that even though the execution path is cached, there
I have an array of keywords, and I want to know whether at least
I know there are a lot of thoughts about how to use (or even
I know this question may sound silly, but I am learning (at least trying)
Even though I always strive for complete validation these days, I often wonder if
Even though I have a robust and fast computer (Pentium Dual Core 2.0 with
Even though I've been a developer for awhile I've been lucky enough to have
Even though MDI is considered harmful , several applications (even MS Office, Adobe apps)
Even though it's not part of HTTP 1.1/RFC2616 webapps that wish to force a

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.