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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:47:57+00:00 2026-06-17T23:47:57+00:00

In my app, I made a BookViewController class that displays and animates the pages

  • 0

In my app, I made a BookViewController class that displays and animates the pages of a book and a MainMenuViewController class that displays a set of books the user can read.

In the latter class, when the user taps on one of the books, a function is called that should create a completely new instance of BookViewController, but for some reason the instance maintains its state (i.e. it resumes from the page the user left off).

How can this be if I set it to nil? What am I missing here? (Note that I’m using ARC).

MainMenuViewController.m

@interface MainMenuViewController ()
@property (strong) BookViewController *bookViewController;
@end

@implementation MainMenuViewController
@synthesize bookViewController;

-(void)bookTapped:(UIButton *)sender{

    NSString *bookTitle;

    if(sender == book1button) bookTitle = @"book1";
    else if(sender == book2button) bookTitle = @"book2";

    bookViewController = nil;

    bookViewController = [[BookViewController alloc] initWithBookTitle:bookTitle];
    [self presentViewController:bookViewController animated:YES completion:nil];

}

BookViewController.h

@interface BookViewController : UIViewController
-(id)initWithBookTitle:(NSString *)bookTitle;
@end

BookViewController.m

@implementation BookViewController
-(id)initWithBookTitle:(NSString *)theBookTitle{
    self = [super init];
    if(self){
        bookTitle = [NSString stringWithFormat:@"%@", theBookTitle];
        [self setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        NSLog(@"init a BookViewController with bookTitle: %@", bookTitle);
    }
    return self;
}

edit 1:
Every time a book is tapped, bookTapped: is called, and thee console always prints:

2012-08-31 16:29:51.750 AppName[25713:c07] init a BookViewController with bookTitle: book1

So if a new instance of BookViewController is being created, how come it seems to be returning the old one?

edit 2:
I inserted NSLog(@"bookViewController %@",bookViewController); just before the line [self presentViewController:bookViewController. The console output is:

2012-08-31 16:37:41.426 Henry[25784:c07] bookViewController <BookViewController: 0x6a21540>
2012-08-31 16:38:23.321 Henry[25784:c07] bookViewController <BookViewController: 0xe425540>
2012-08-31 16:38:53.393 Henry[25784:c07] bookViewController <BookViewController: 0x6839330>
  • 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-17T23:47:59+00:00Added an answer on June 17, 2026 at 11:47 pm

    Your variables are declared outside of the @implementation of the class (you are declaring global variables).

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

Sidebar

Related Questions

I had some problems in my app I made an app that can detect
I have an iPhone app made up of a single UIWebView that displays a
A desktop app (made in Delphi) is started by User A. Let's call it
In the Java Swing app I made it seems to me that all the
On an android App I made, whenever the user turns the app to the
I have a panorama app and made a button on one of the pages.
Does an app that made with ios sdk 4 install on device with os
Can't load the app i made on the Samsung galaxy prevail and I try
I am new to iPhone, I made app in which, when user downloads anything
I have made app which allows me to send message to multiple user from

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.