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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:56:31+00:00 2026-06-18T09:56:31+00:00

#import <UIKit/UIKit.h> @protocol myProtocol <NSObject> -(void)aMethod; @end @interface ViewController : UIViewController @property (weak) id<myProtocol>

  • 0
#import <UIKit/UIKit.h>

@protocol myProtocol <NSObject>

-(void)aMethod;

@end

@interface ViewController : UIViewController

@property (weak) id<myProtocol> dSource;

@end

I am trying to get a firm grip on Obj-c protocols, I am reading apple doc to study, few things are not clear to me. Below are the points from doc:

  1. The pie chart view class interface would need a property to keep track of the data source object. (The code above, we mostly declare protocol this way, when I have protocol declared in my class why need a tracking object, Or protocol can be defined in independent class? and for that we need tracking object?)

  2. By specifying the required protocol conformance on the property, you’ll get a compiler warning if you attempt to set the property to an object that doesn’t conform to the protocol.

  3. If you attempt to call the respondsToSelector: method on an id conforming to the protocol as it’s defined above, you’ll get a compiler error that there’s no known instance method for it. Once you qualify an id with a protocol, all static type-checking comes back; you’ll get an error if you try to call any method that isn’t defined in the specified protocol. One way to avoid the compiler error is to set the custom protocol to adopt the NSObject protocol.

  • 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-18T09:56:32+00:00Added an answer on June 18, 2026 at 9:56 am
    1. I dont understand this question
    2. Correct, the property requires that the property is an id which
      conforms to your property, if you try to set it to something else
      the compiler rightly complains
    3. This is because respondsToSelector: is a method on the NSObject
      protocol, so you can either have your protocol extend NSObject
      (standard), or you could declare the property as
      NSObject
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

//viewController.h file //--------------------- #import <UIKit/UIKit.h> @interface ItemClass : NSObject { NSString* name; } @property
I have this simple class TestViewController.h #import <UIKit/UIKit.h> #import ClassB.h @protocol TestViewControllerDelegate <NSObject> -(void)hello;
OrderDetailsView.h #import <UIKit/UIKit.h> @protocol OrderDetailsViewDelegate; @interface OrderDetailsView : UIViewController { IBOutlet UITextView *OrderDetails; NSString
MPPopoverControllerDelegate.h file #import <Foundation/Foundation.h> @class MPPopoverController; @protocol MPPopoverControllerDelegate <NSObject> @optional - (void)popoverControllerDidDismissPopover:(MPPopoverController *)popoverController; @end
I have this appdelegate.h #import <UIKit/UIKit.h> @interface appDelegate : NSObject <UIApplicationDelegate> { UIWindow *window;
Say I have this code: #import <UIKit/UIKit.h> @interface MyView : UIView @end @implementation MyView
I have some codes as below #import <UIKit/UIKit.h> @interface ViewMoreSettingController : UIViewController < UITableViewDelegate,
I just create a simple UITableView in the UIViewController . .h #import <UIKit/UIKit.h> @interface
FirstViewController.h: #import <UIKit/UIKit.h> @interface FirstViewController : UIViewController { NSArray *listData; } -(IBAction) GoToInsert: (id)
In my .h file I have this: @protocol ScanBookDelegate - (void)MethodNameToCallBack:(NSArray *)s; @end @property

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.