Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,706
6,289
Resolved:

I neglected to give a name to the variable "name" in the declaration in my header, thus it wasn't recognized later on in the implementation.

Original Post:

ARC is giving me an error, "No known instance method for selector 'newAttemptViewControllerDidFinish:name:gender:'

I've highlighted the line in red below:

My header:
Code:
@class NewAttemptViewController;

@protocol NewAttemptViewControllerDelegate <NSObject>
- (void)newAttemptViewControllerDidCancel:(NewAttemptViewController *)newAttemptViewController;
- (void)newAttemptViewControllerDidFinish:(NewAttemptViewController *)newAttemptViewController name:(NSString *) gender:(int)gender;
@end

@interface NewAttemptViewController : UIViewController <UITextFieldDelegate>
{
	IBOutlet	UIBarButtonItem		*cancelBarButtonItem;
	IBOutlet	UIBarButtonItem		*doneBarButtonItem;
	IBOutlet	UITextField			*nameTextField;
	IBOutlet	UISegmentedControl	*genderSegmentedControl;
}

@property (nonatomic, weak) id <NewAttemptViewControllerDelegate> delegate;

- (IBAction)cancelBarButtonItemSelected:(UIBarButtonItem *)sender;
- (IBAction)doneBarButtonItemSelected:(UIBarButtonItem *)sender;
- (IBAction)genderSegmentedControlSelected:(UISegmentedControl *)sender;

@end

My Implementation:
Code:
@implementation NewAttemptViewController

@synthesize delegate;

- (IBAction)genderSegmentedControlSelected:(UISegmentedControl *)sender
{
	if (nameTextField.text.length > 0) doneBarButtonItem.enabled = YES;
}

- (IBAction)cancelBarButtonItemSelected:(UIBarButtonItem *)sender
{
	[self.delegate newAttemptViewControllerDidCancel:self];
}

- (IBAction)doneBarButtonItemSelected:(UIBarButtonItem *)sender;
{
	[color=RED][self.delegate newAttemptViewControllerDidFinish:self name:nameTextField.text gender:genderSegmentedControl.selectedSegmentIndex];[/color]
}

Other info... Previously I had just had:
Code:
[self.delegate newAttemptViewControllerDidFinish:self];

and I didn't pass those other arguments and it worked fine, and my cancel method works fine. There's something about passing those two arguments it doesn't seem to like. Or maybe I'm just wrong. Either way, suggestions for how to resolve it? I've copied and pasted the method name to make sure I'm consistently calling it the same thing, but that doesn't seem to be the issue.

Edit: This issue has been resolved; I've edited this post to mention what I had done wrong at the top. It's always so embarrassing to have an issue for several hours, decide you need help and write up a post asking for help, and then moments later find what the issue was. On the other hand, problems that seem like they'll have their root caused found in a few moments too often aren't actually so easily resolved and one does need help with them... c'est la vie, I suppose.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.