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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:20:23+00:00 2026-05-11T17:20:23+00:00

I thought I had a pretty good handle on memory management for objective-c, but

  • 0

I thought I had a pretty good handle on memory management for objective-c, but I can’t figure out the following situation:


@protocol MyProtocol
@end

@interface MyObject : NSObject {
    id<MyProtocol> reference;
}
@property (nonatomic, retain) id<MyProtocol> reference;
@end

@implementation MyObject 
@synthesize reference;
-(void) dealloc {
    [reference release];
    [super dealloc];
}
...
@end

This gives me a “warning: ‘-release’ not found in protocol(s)“.
Can I safely ignore this error? Or am I doing something horribly wrong?

  • 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-11T17:20:24+00:00Added an answer on May 11, 2026 at 5:20 pm

    Yes you can safely ignore this error. An object declared as type id<MyProtocol> may not inherit from NSObject (you do not have to use the Cocoa libraries to program in Objective-C and there are other root classes even in Cocoa such as NSProxy). Since retain (and release, autorelease) are declared in NSObject, the compiler cannot know that the instance declared as type id<MyProtocol> responds to these messages. To get around this, Cocoa also defines the NSObject protocol which mirrors the NSObject API. If you declare your protocol as

    @protocol MyProtocol <NSObject>
    @end
    

    indicating that MyProtocol extends the NSObject protocol, you’ll be set.

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

Sidebar

Related Questions

I had thought I actually had a pretty good handle on the whole view
I thought I had a pretty good grasp of the difference between the is
I thought I had seen a bug report about this on the jQuery site,
This may seem like a programming 101 question and I had thought I knew
I long thought that in C, all variables had to be declared at the
I thought I heard that py2exe was able to do this, but I never
I have looked and thought about good and bad points of my past designs
Unfortunately this is going to be a pretty open-ended question, but I am at
Some student asked this on another site, but got no answers. I had a
I have the following situation: I have site A, which has it's Mercurial repo,

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.