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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:06:35+00:00 2026-05-23T03:06:35+00:00

in my application i’m trying to send an int value from one view to

  • 0

in my application i’m trying to send an int value from one view to another view. To do this i’m setting up a navbar button programmatically and passing it an action from the same class that’s creating the button. In the next view that will load i have a property that i’ll set when the user clicks the navbar button. The problem is that the application crashes when i set this value. I have the int value in a @property in the view’s h class and then i have the @synthesize below the @implementation line.

Here is the code for the navbar button, this is done in the initWithNibName method:

UIBarButtonItem *contentsButton = [[UIBarButtonItem alloc] initWithTitle:@"Contents"                                            style:UIBarButtonItemStyleBordered target:self action:@selector(showBookContents)];


        [[self navigationItem] setRightBarButtonItem:contentsButton];
        [contentsButton release];

Here is the method that i pass to the button when it’s created:

-(IBAction)showBookContents{
    BookContentsViewController *contentsViewController = [[BookContentsViewController alloc] initWithNibName:@"BookContentsViewController" bundle:nil];

    contentsViewController.selectedBookId = self.selectedBook._id;

    [[self navigationController] pushViewController:contentsViewController animated:YES];

    [contentsViewController release];

}

Here is the class that will be loaded when the use clicks the navbar button:

@interface BookContentsViewController : UIViewController {
    int selectedBookId;
}

@property int selectedBookId;

@end

Here is the implementation for the above class:

@implementation BookContentsViewController

@synthesize selectedBookId;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

As you can see the @property and @synthesize looks fine. Here is the error i get:

2011-06-13 11:48:42.321 BookApp[22762:207] -[BookDescriptionViewController setSelectedBookId:]: unrecognized selector sent to instance 0x4d9f070
2011-06-13 11:48:42.323 BookApp[22762:207] ** ** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[BookDescriptionViewController setSelectedBookId:]: unrecognized selector sent to instance 0x4d9f070’

What can the problem be guys?

Thanks in advance for your patience.

  • 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-23T03:06:36+00:00Added an answer on May 23, 2026 at 3:06 am

    try this

    make this selectedBookId NSString and then try.

    NSString *selectedBookId;
    int selectedBookIdIntegerValue;
    
    @property(nonatomic,retain)NSString selectedBookId; 
    

    Change in this method

    -(IBAction)showBookContents{
        BookContentsViewController *contentsViewController = [[BookContentsViewController alloc] initWithNibName:@"BookContentsViewController" bundle:nil];
    
        contentsViewController.selectedBookId = [NSString stringWithFormat:@"%d",self.selectedBook._id];
    
        [[self navigationController] pushViewController:contentsViewController animated:YES];
    
        [contentsViewController release];
    
    }
    

    dont forget to release selectedBookId in dealloc of BookContentsViewController.

    since selectedBookId is now NSString
    You might need integer value so what you do is
    selectedBookIdIntegerValue=[self.selectedBookId intValue];

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

Sidebar

Related Questions

Application requests KML data through AJAX from server. This data is stored in javascript
Application.Run(form); Actually I tried to call this from my project. I got this exception.
Application has an auxiliary thread. This thread is not meant to run all the
My application dynamically loads assemblies at runtime from specific subfolders. These assemblies are compiled
My application has a need to let the user choose a date from a
Application loader is giving me this error when uploading an app to the AppStore:
Application I develop requires several data sources (2 RDBMS and one file storage) to
Application : Nerddinner. This SP is for an inserting password for newly created User.
My application plots a bunch of markers on a map read from a MySQL
My application is able to run from the launcher on the Galaxy Tab, but

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.