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

  • Home
  • SEARCH
  • 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 6749015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:18+00:00 2026-05-26T12:38:18+00:00

I have created a button action method. Initialized an NSDictionary with values from an

  • 0

I have created a button action method. Initialized an NSDictionary with values from an array and assigned values to it. While printing the objects of dictionary in console getting correct value. While assigning to “NSString *value” printing values like Value is: 144964992. But on console getting correct values like 0, 1,2, 3….

-(IBAction)takeDecision:(id)sender
    {
        NSLog(@"FINAL DECISION");
        NSMutableDictionary *dict =  [[NSMutableDictionary alloc]init];
        for(int i = 0; i < [choices count]; i++)
        {
            //[resultChoice indexOfObject:[NSNumber numberWithInt:i]];

            [dict setObject:[NSNumber numberWithInt:i] forKey:[choices objectAtIndex:i]];   
        }

        for (id key in dict) {

            NSLog(@"key: %@, value: %@", key, [dict objectForKey:key]);

        }




        for(int i = 0; i < [preferences count]; i++)
        {
            for(int j = 0; j < [choices count]; j++)
            {
                //NSLog(@"Number of cells: %d", [[myTable] numberOfRowsInSection:0]); // This writes out "Number of cells: 6"


                UITableViewCell *cell = [myTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:j inSection:i]];
                if(cell == nil) {
                    NSLog(@"CELL IS NIL");
                }

                NSArray *array = cell.contentView.subviews;
                NSLog(@"NUMBER OF OBJECTS: %d",[array count]);
                UIButton *test = (UIButton *)[array objectAtIndex:1];
                UIImage *newImage = [test currentBackgroundImage];
                NSLog(@"Image is %@",newImage.CGImage);

                NSLog(@"*************TEST VALUE IS:%@",[dict objectForKey:[choices objectAtIndex:j]]);

                NSString *value = [dict objectForKey:[choices objectAtIndex:j]];
                NSLog(@"--------> Value is: %d", value);
                if(newImage == [UIImage imageNamed:@"thumbsup_selected.png"])
                {
                    [dict setValue:[NSNumber numberWithInt: value+1] forKey:[choices objectAtIndex:j]];
                }
                NSLog(@"CELL IS NOT NIL");
            }
        }
        for (id key in dict) {

            NSLog(@"key: %@, value: %@", key, [dict objectForKey:key]);

        }
    }

If any one can please provide a solution for it it will be helpful… Thanks in advance…

  • 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-26T12:38:18+00:00Added an answer on May 26, 2026 at 12:38 pm

    The reason is when you print in gdb you are actually printing value of NSNumber which seems correct in console. But you can not directly take NSNumber in NSString. So change the line

     NSString *value = [dict objectForKey:[choices objectAtIndex:j]];
    

    to

                NSString *value = [NSString stringWithFormat: @"%d",[[dict objectForKey:[choices objectAtIndex:j]] integerValue]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created Array of Linkbutton and when user click on link button it
I have a submit button created in which I am calling a method call2
I have created a CustomAction feature to add a button to the Actions menu
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
I have created a button CSS class that uses background images with different positions
I am new to iphone development. I have created a button in the view.
I have created a default style for a Button including a custom ControlTemplate like
I created a button and I need it to restart the form I have
i have a table which contains a bunch of dynamically created radio button lists,
I have a button element that I've created like so: $submit = new Zend_Form_Element_Button('submit');

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.