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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:45:04+00:00 2026-05-13T17:45:04+00:00

I have created a class, that makes it easy to enter in the amount

  • 0

I have created a class, that makes it easy to enter in the amount for a particular price in the same way an ATM machine allows you to enter in an amount, user does not enter the decimal.

This is a generic class called (AmountPicker), so that it can be used among many other classes. I am using it by invoking the presentModalViewController method, this class uses a nib file. Inside the xib there is a hidden text field and a label along with a done button in the navigation bar. The done button is an IBAction connected to a method named doneButtonPressed.

I am wanting to know if it is possible to delegate this method to another class, so that the logic inside the method can differ from the one already defined inside the amountPicker class.

The reason is, I use the amountPicker Class in two places one for entering a purchase, which takes the label text and assigns the value to a variable inside the appDelegate, this was ok when i just used it in one class, but now there is a detailTableViewController of the purchase and this view will also need to provide a way to change the data in case it was entered wrong.

So in the detail view i am using a custom header, the custom header has a textField for the name of the purchase, a button to activate the AmountPicker, and a label for the amount, when the amount button is pressed then the AmountPicker class pops up and the user enters the amount and presses the done button, NOW, this is where i need to change the logic for the doneButton, instead of using a variable in the appDelegate.

I was thinking that the DetailTableViewController could act as a delegate for the amountPicker Class and override the doneButtonPressed method, so that the amountLabel can be updated with the new amount.

Is this possible, if not what is the right way?

  • 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-13T17:45:05+00:00Added an answer on May 13, 2026 at 5:45 pm

    Your thinking is right along with how delegation is normally used. What I would do is create an Objective-C protocol, maybe AmountPickerDelegate. Then, in your interface for the AmountPicker, you would have this:

    @interface AmountPicker : NSObject {
        NSString *someValue;
        ...
        id <AmountPickerDelegate> delegate;
    }
    
    @property (assign) id <AmountPickerDelegate> delegate;
    
    @end
    

    Then, in your delegate class, you would do this:

    @interface DetailTableViewController : UITableViewController <AmountPickerDelegate>
    

    Finally, in the original AmountPicker class, you could call something like this:

    [delegate amountPickerDidPressDoneButton];
    

    which would execute in the delegate.

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

Sidebar

Related Questions

So I have written a class that makes it extremely easy to interface with
I have created a class that will manage connection and commands, I named it
Currently I have created a ABCFactory class that has a single method creating ABC
I have created a button CSS class that uses background images with different positions
I have created a custom collection class that I am trying to bind to
I have Xcode 4.3 and that class doesn't use ARC. I have created a
I have created a service class for my network connection so that my app
I have a binary tree class that is created with a root node and
I have created a gem that adds a new method to the class ActiveRecord::Base.
I have created a subclass of UITableViewController that is used as the custom class

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.