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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:10:25+00:00 2026-05-22T23:10:25+00:00

Am not sure how to put this, and I couldn’t find the answer because

  • 0

Am not sure how to put this, and I couldn’t find the answer because of my inability to find the words to express what am looking for. (!)

In Java, I used to do something like this (I don’t remember):

JPanel myButton = new JPanel("Press me"){
    public void add(JComponent component){
        //override add method
    }
};

But, i couldn’t find how to do this in Objective-C .. What I found in my search was categories and weird ^{} symbols …

So, how can I override method(s) in a newly created object?

(For example, override -(BOOL)isEqual; in a newly created NSString* ?)

Am sorry if the question is a bit vague..

EDIT:

Obviously, without subclassing 🙂

EDIT:

Might as well post my problem in case someone has a better idea:

I have a few CCTransitions in COCOS2D, and I want to be notified when the transition ends .. The thing is, as soon as the transition ends, the -(void)finish; method is invoked (which is part of the CCTransition class structure)

I would really want to avoid subclassing the CCTransition class, and override the finish method to do my logic when the transition ends 🙂

EDIT:

-(void)onEnterTransitionDidFinish; … I can’t believe something as awesome as that existed and I haven’t came across it while searching……

Which means, instead of subclassing CCTransition, override this method in my CCNode subclass :D!

  • 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-22T23:10:26+00:00Added an answer on May 22, 2026 at 11:10 pm

    What you have there in Java is an anonymous subclass. This is not possible in Objective-C (well, it sort of is but you would have to do some pretty involved contortions with the Obj-C runtime library).

    But Objective-C as of iOS 4 or OS X 10.6 has “blocks”, which is what the ^{} syntax is for. This is Objective-C’s notion of a closure. This isn’t going to help you directly if the APIs that you’re calling don’t support block callbacks, but you may be able to create wrapper classes that use blocks instead of subclassed methods to handle callbacks.

    There are many resources for learning about blocks in Objective-C.

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

Sidebar

Related Questions

Not sure if this is possible or if I'm expressing correctly what I'm looking
I'm not sure how to put this best into a title, but this is
I am not sure where the best place to put validation (using the Enterprise
Not sure how to ask a followup on SO, but this is in reference
Not sure if this is intended behavior or a bug or a wrong function
Not sure exactly how to word this question ... so edits are welcomed! Anyway
Not sure this is a programming question, but we use LaTeX for all our
I am not sure about this, but I think I read it before, and
I'm going to put iAd on UITableView in my app, but I'm not sure
Not sure what exactly is going on here, but seems like in .NET 1.1

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.