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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:47:17+00:00 2026-05-13T12:47:17+00:00

I have a custom subclass of UIView that needs to perform a selector when

  • 0

I have a custom subclass of UIView that needs to perform a selector when a value (NSInteger) falls below a certain value. From what I can tell from the docs, I need to set up an observer object to look for this change.

The NSInteger value exists in the view controller and the UIView subclass is implemented as a subview in the same view controller.

I wondering if something like the following is on the right track:

-(void)createNotification:
[[NSNotificationCenter defaultCenter]
                       addObserver:self //since this is in the viewController, I'm thinking it's "self"
                       selector:@selector(genCountLow:)
                       name:@"ReviewGenCount"
                       object: nil ];      

I’m struggling with where I would add the condition for this observer to perform the action. For instance, if the condition would be:

if(genCount < 3) {
///code statement
}

I want my observer to look for the above change and then perform a subsequent action. Would I add that to my notification object like this?

- (void)genCountLow:(NSNotification *)notification {
    if (genCount < 3) {
[electricalSystemDiagramView depowerShedBuses];
}

}
  • 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-13T12:47:17+00:00Added an answer on May 13, 2026 at 12:47 pm

    Your view should not be making this decision, the view controller should. Generally you should try and avoid the situation where the view needs to have information about the model or controller implementation.

    Your view should instead have a flag, for example a BOOL property named drawLowState. When this value changes, the view should be redrawn with a different appearance by doing something like this:

    In YourView.m:

    - (void)setDrawLowState:(BOOL)isLow
    {
        if(drawLowState != isLow)
        {
            drawLowState = isLow;
            [self setNeedsDisplay];
        }
    }
    

    You’d change the appearance of the view by altering what you draw in the view object’s drawing routine based on the value of the drawLowState property.

    Since your view controller knows when the integer value changes, you can then easily make the decision in the setter for your integer property and tell the view to update its appearance:

    In YourViewController.m:

    - (void)setGenCount:(NSInteger)aCount
    {
        genCount = aCount;
        self.view.drawLowState = (genCount < 3);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a simple iPhone app that loads a custom subclass of UIView.
I have a custom UIView subclass that i'm trying to use as a header
I have created a custom UIView that I would like to use on multiple
I am using navigation with a custom UIView subclass that becomes my titleView. I
I've seen custom subviews implemented as an UIViewController subclass, but that maybe could have
I have a custom CustomMembershipUser that inherits from MembershipUser. public class ConfigMembershipUser : MembershipUser
I have a custom NSTableView subclass which is bound to a data source (an
I have a custom NSActionCell subclass, and I want to use setTarget: message to
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
I have a few models that need to have custom find conditions placed on

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.