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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:39:47+00:00 2026-06-07T05:39:47+00:00

I have created a custom class called RCTextField , whose purpose is to create

  • 0

I have created a custom class called RCTextField, whose purpose is to create an NSTextField with rounded corners (thus RC...).

This RCTextField inherits from NSTextField and overrides the drawRect: method in order to create its own rectangle with rounded corners.

Now, I want to do the same thing for NSSecureTextField, that is, have a way to make it have rounded corners. I can’t just make it inherit RCTextField, because that one doesn’t have any secure implementation for text that NSSecureTextField has.

And if I inherit from NSSecureTextField, I’d have to rewrite all the drawRect: implementation again.

An option I thought about would be to have an RCBaseTextField class which contains a static method called drawRect:forNSTextField:withParams:, and call that one in the drawRect: of RCTextField and RCSecureTextField. However, that seems a bit hackish, and it feels like there could be a better OOP way to do this in Objective-C.

So, what would be the best/sanest/software-engineering-“esquest” way to share the draw-rounded-corners code from RCTextField between an RCTextField and an RCSecureTextField?

  • 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-07T05:39:48+00:00Added an answer on June 7, 2026 at 5:39 am

    Unfortunately, you cannot make an Objective-C inherit behavior from more that one other class. I think providing a function (using a Object-Oriented language doesn’t prevent from using functions when they are appropriate) that will be invoked by both drawRect: implementation is the simpler way.

    Or you may just ignore NSSecureTextField and make RCSecureTextField inherit from RCTextField. Then implement the class method cellClass to return NSSecureTextFieldCell and you should get the same exact features as NSSecureTextField.

    @interface RCSecureTextField : RCTextField
    @end
    
    @implementation RCSecureTextField
    + (Class)cellClass { return [NSSecureTextFieldCell class]; }
    @end
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have created a List of a Custom Class called FinalPixel , and
I have created a custom class for my Android project called Sounds I want
I have created my own button class called custom_btn. I created it on the
In my app i have created one custom class for Label.Now i want to
I have created a custom collection class that I am trying to bind to
I have created a subclass of UITableViewController that is used as the custom class
I have created my custom MembershipProvider. I have used an instance of the class
I have created custom jQuery UI widget called uiPopover, very similar to UI-dialog (in
I have written a custom SessionStoreProvider class that inherits from the SessionStateStoreProviderBase. I have
I have a custom view called DrawView created in the main activity. I have

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.