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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:38+00:00 2026-05-25T22:20:38+00:00

So basically on my ClassA.h I have created a NSNumber called selected. It is

  • 0

So basically on my ClassA.h I have created a NSNumber called selected. It is also used in @property as well in that .h. Now in ClassA.m I have a table view and when one is selected it goes to another screen. I would like the indexPath.row to save into that NSNumber. (Selected was @synthesized as well in .m)

Where it is being called in ClassA.m is in the didSelectRowAtIndexPath and looks like this.

selected = [NSNumber numberWithInt:indexPath.row];

In the next view is where I would like to recall this code so that it can load a perticular view by code based on the selection. I import ClassA.h and this is the code I put in for ClassB.m

HowTosViewController *h = [[HowTosViewController alloc] init];

if([h.selected intValue] == 0){
    content.text = @"0";
}
else if ([h.selected intValue] == 1){
    content.text = @"1";
}

I’m assuming my issue is I didn’t store it correctly or it isn’t calling it correctly. I would prefer to do this using the global variables so if there is an easier way to do this using them I wouldnt mind. I appreciate any help.

Also as a side note. When I go to release selected would it cause any problems or be correct if I did it in ClassB? After it loads the screen from using that number it is no longer needed and another one should be assigned if the person goes back and selects another option.

Thanks 🙂

EDIT: Forgot to mention what it is doing currently. Currently when clicking on any of the Cells in ClassA it opens the screen and displays 0.

  • 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-25T22:20:39+00:00Added an answer on May 25, 2026 at 10:20 pm

    When you do this in ClassB.m

    HowTosViewController *h = [[HowTosViewController alloc] init];
    

    that is a new instance, not the same instance where you stored your selected value.

    Consider init’ing your ClassB with selected value as well and use that in classB like doing

    - (id) initWithSelectedIndex: (NSNumber *) selectedIndex {
        if(self = [super init]) {
           receivedSelectedIndex = selectedIndex;
        }
        return self;
    }
    

    delcare this receivedSelectedIndex like

    NSNumber *receivedSelectedIndex;
    @implementation classB
    

    and where you create instance of ClassB you should do like

    classB *b = [[classB alloc] initWithSelecedIndex:selected]; //using your selected NSNumber
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a class, MonitoredCollection<T> , that basically encapsulates/mimics List but allows me
I have created an arraylist that is made up of custom objects. Basically the
I have a class that basically stores files in amazon s3. Here is what
I'm testing a C++ class with a number of functions that all have basically
I have created a class that I've been using as the storage for all
I have 2 Lists containing entries of a custom class I have created. Basically,
I have created a function that updates some values from a database that I
I have created a drop-down-menu, the html for the drop-down part basically looks like
I have created an extension that adds a new column to the main message
I am using MVVM Light. I have created a window that looks like this:

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.