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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:57:13+00:00 2026-05-24T08:57:13+00:00

Ok, i was searching but there wasn’t any method that was working for me.

  • 0

Ok, i was searching but there wasn’t any method that was working for me. Following code bases on many tutorials and Apple documentation, but i can’t get it to work. Can anybody help please?

Code is crashing at: obj.delegatee = self; (in class B.h), also methods respondsToSelector and performSelector:withObject aren’t recogized.

I want to set delegate object, on which there will be a method called when we tap on particular picture.

class A.h:

@interface AViewController : UIViewController <UIScrollViewDelegate>{
    id delegatee;
}
@property (nonatomic, assign) id <AViewControllerDelegate> delegatee;
@end

@protocol AViewControllerDelegate
@optional
- (void) tappedImage:(int)tag;
@end

class A.m:

@dynamic delegatee;
- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {
UIImageView *imageView = (UIImageView *)[gestureRecognizer view];
int a = imageView.tag;

if ([self.delegatee respondsToSelector:@selector(tappedImage:)])
    [self.delegatee performSelector:@selector(tappedImage:) withObject: [NSNumber numberWithInt:a]];

}

class B.h:

#import "AViewController.h"
@interface BViewController : UIViewController <AViewControllerDelegate> {...}

class B.m:

- (void)viewDidLoad
{
[super viewDidLoad];
//... some code

AViewController *obj = [[[AViewController alloc] init] autorelease];
obj.delegatee = self;
}

- (void) tappedImage:(int)tag{
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: [NSString stringWithFormat: @"%d.png",tag]]];
CViewController *NView = [[CViewController alloc] initWithPicture: imgView.image];
[self presentModalViewController:NView animated:YES];
[NView release]; NView = nil;
}

Many thanks for any help, i hope it will help me to understand how protocols work.

  • 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-24T08:57:15+00:00Added an answer on May 24, 2026 at 8:57 am

    Two things.

    1. (Your Crash) You declared your delegatee as @dynamic instead of @synthesized which means you are responsible for creating the -(void)setDelegatee:(id<AViewControllerDelegate>) (and the getter) method. Fix: Simply change it from @dynamic to @synthesize delegatee;

    2. (Your warnings) Whenever you want to call methods that you do not explicitly define in your protocol, then your protocol will need to conform to another protocol :). Fix: Add the NSObject protocol to your decleration.

    @protocol AViewControllerDelegate<NSObject>

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

Sidebar

Related Questions

Are there any PHP equivalents for these two functions? I tried searching but couldn't
I've tried searching around but there isn't something that is a fairly concrete example
I have done a load of searching but haven't found anything. There seem to
Inverted index is designed to be fast for searching but not that easy for
I've been searching around but could not find any answers to this. What I'm
I was searching at w3schools about the meta tag , but there's nothing about
I've done some searching, but haven't found any satisfactory answers: what's the best Maven
I thought there had already been a similar question but searching for it yielded
This seemed like a common question but after doing some searching, I wasn't really
After a lot of searching I wasn't able to find anything that clearly describes

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.