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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:31:09+00:00 2026-05-15T00:31:09+00:00

Can anyone please write a simple example on how to pass a number (int

  • 0

Can anyone please write a simple example on how to pass a number (int value) which gets created in 1 .m file to another .m file.

In the apple demo application called QuartzDemo, there is a file called QuartzImages.m

This file has the following line of code:
[CODE]CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);[/CODE]
Notice the (pdf, 1) in that line. This number should be replaced with an integer variable.

Now, there is also a file called MainViewController.m.
In that file, there is a method? called -(void)viewDidLoad

In that method, I want to assign a number to the integer variable which would replace the damn "1" with whatever number I want.

Any help would be greatly appreciated.

  • 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-15T00:31:09+00:00Added an answer on May 15, 2026 at 12:31 am

    Hoping this takes you out of your misery…

    The QuartzPDFView class in QuartzImages.m is not actually instantiated in the viewDidLoad of MainViewController. There, it’s class identity is only stored in a dictionary/array referenced by the table view that provides the menu.

    The actual quartz view objects are kept in QuartzViewController which itself is created in the didSelectRowAtIndexPath method in MainViewController.

    When the QuartzViewController is created and pushed onto the navigation controller, the QuartzViewController’s viewDidLoad fires which adds self.quartzView as a subview. The getter method for quartzView (above the viewDidLoad of QVC) finally creates the quartz view object.

    So to tell the quartz view to load a given page, here’s one way to do it (may not be the most elegant):

    1. Add a pageNumber property to the QuartzPDFView class
    2. Set this property in the didSelectRowAtIndexPath method in MainViewController

    The minor problem is that the quartzView property in QuartzViewController can be different kinds of quartz views (not just QuartzPDFView). So you need to check that it is a QuartzPDFView before trying to set the pageNumber property.

    Step 1: Add pageNumber property to QuartzPDFView class:

    //QuartzImages.h
    @interface QuartzPDFView : QuartzView
    {
        CGPDFDocumentRef pdf;
        int pageNumber;
    }
    @property (nonatomic, assign) int pageNumber;
    -(void)drawInContext:(CGContextRef)context;
    @end
    
    //QuartzImages.m
    @implementation QuartzPDFView
    @synthesize pageNumber;
    ...
    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber);
    ...
    

    Step 2: Set this property in the didSelectRowAtIndexPath method in MainViewController

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        QuartzViewController *targetViewController = [self controllerAtIndexPath:indexPath];
        if ([targetViewController.quartzView isKindOfClass:[QuartzPDFView class]])
        {
            ((QuartzPDFView *)targetViewController.quartzView).pageNumber = 1;
            //replace 1 with whatever number or variable you want
        }
        [[self navigationController] pushViewController:targetViewController animated:YES];
    }
    

    The pdf in the sample app doesn’t seem to have more than one page by the way.

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

Sidebar

Ask A Question

Stats

  • Questions 458k
  • Answers 458k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As gbn said, using one of the existing formats with… May 15, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer It doesn't show up because I suspect that it has… May 15, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer I believe the problem is in the use of the… May 15, 2026 at 10:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.