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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:17:41+00:00 2026-06-01T11:17:41+00:00

I’m calling an NSObject from a UIViewController, and I’m setting the view controller as

  • 0

I’m calling an NSObject from a UIViewController, and I’m setting the view controller as the delegate of the NSObject.

When this code is executed, the app completely crashes on the simulator due to EXC_BAD_ACCESS (how does that apply here?). When the app runs on a real device, the app crashes the third time the code is executed. The output of the real device log is below:

(First time)
2012-04-01 13:29:05.154 The Record[19044:707] Done

----
(Second time)
2012-04-01 13:29:06.274 The Record[19044:707] Done

----
(Third time)
2012-04-01 13:29:07.772 The Record[19044:707] -[ViewController setDelegate:]: unrecognized selector sent to instance 0xde2e6e0
2012-04-01 13:29:07.773 The Record[19044:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController setDelegate:]: unrecognized selector sent to instance 0xde2e6e0'
*** First throw call stack:
(0x3211088f 0x37515259 0x32113a9b 0x32112915 0x3206d650 0x537f7 0x4f82b 0x3206a3fd 0x379eafaf 0x37ab076b 0x3206a3fd 0x379eafaf 0x379eaf6b 0x379eaf49 0x379eacb9 0x379eb5f1 0x379e9ad3 0x379e94c1 0x379cf83d 0x379cf0e3 0x3144322b 0x320e4523 0x320e44c5 0x320e3313 0x320664a5 0x3206636d 0x31442439 0x379fde7d 0x4dd8d 0x4dd38)
terminate called throwing an exception(lldb)

I’m just calling the NSObject and setting the view controller as the delegate.

Authorization *authorization = [[Authorization alloc] init];
authorization.delegate = self;

When I take out authorization.delegate = self; the app does not crash, but I obviously need that line.

Edit: Here is the code. I’m using @protocol. Authorization.h:

#import <Foundation/Foundation.h>
#import "KeychainItemWrapper.h>

@protocol AuthorizationDelegate <NSObject>
- (void)done:(BOOL *)done downloadURL:(NSURL *)downloadURL username:(NSString *)username password:(NSString *)password reason:(NSString *)reason;
@end

@interface Authorization : NSObject {

    id<AuthorizationDelegate> delegate;
    KeychainItemWrapper *keychain;

}

-(id)init;

@property (nonatomic, assign) id<AuthorizationDelegate> delegate;

@end

----
//Authorization.m

#import "Authorization.h"
#import "ASIFormDataRequest.h"
#import "JSON.h"

@implementation Authorization

@synthesize delegate;

-(id)init {

    keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"exampleID" accessGroup:nil];
    NSString *passPhrase = [keychain objectForKey:(id)kSecValueData];


    // Start request
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.website.com/authorization.php"]];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request setPostValue:passPhrase forKey:@"passphrase"];
    [request setPostValue:@"YES" forKey:@"receivingAuthorization"];
    [request setDidFinishSelector:@selector(requestFinished:)];
    [request setDidFailSelector:@selector(requestFailed:)];
    [request setDelegate:self];
    [request startAsynchronous];

}

-(void)requestFinished:(ASIHTTPRequest *)request {

    if (request.responseStatusCode == 200) {

        NSString *responseString = [request responseString];
        NSDictionary *responseDict = [responseString JSONValue];
        NSString *downloadString = [responseDict objectForKey:@"downloadURL"];
        NSString *username = [responseDict objectForKey:@"username"];
        NSString *password = [responseDict objectForKey:@"password"];

        if ((downloadString != nil) && (username != nil) && (password != nil)) {

            NSURL *downloadURL = [NSURL URLWithString:downloadString];

            [delegate done:YES downloadURL:downloadURL username:username password:password reason:@"Received Authorization"];

         } else {

            [delegate done:NO downloadURL:nil username:nil password:nil reason:@"Invalid Request"];

        }

    } else if (request.responseStatusCode == 400) {

        if ([[request responseString] compare:@"Invalid passphrase"] == 0) {

            [delegate done:NO downloadURL:nil username:nil password:nil reason:@"Incorrect Credentials"];

        } else if ([[request responseString] compare:@"Invalid request"] == 0) {

            [delegate done:NO downloadURL:nil username:nil password:nil reason:@"Invalid Request"];

        }

    } else {

        [delegate done:NO downloadURL:nil username:nil password:nil reason:@"Invalid Request"];

    }

}

@end


----

//ViewController.h

@interface ViewController : UIViewController <IssuesPickerDelegate, IssueTableDelegate, AuthorizationDelegate> {

    Authorization *authorization;

}

@property (nonatomic, retain) Authorization *authorization;

----

//ViewController.m

@synthesize authorization;

-(void)done:(BOOL *)done downloadURL:(NSURL *)downloadURL username:(NSString *)username password:(NSString *)password reason:(NSString *)reason {

NSLog(@"Done");

if ((done == YES) && ([reason compare:@"Received Authorization"] == 0)) {


} else if ([reason compare:@"Incorrect Credentials"] == 0) {

    Login *login = [[Login alloc] init];

}

}


-(void)getAuthorization {

//this part here causes the crash

authorization = [[Authorization alloc] init];
authorization.delegate = self;

}
  • 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-01T11:17:43+00:00Added an answer on June 1, 2026 at 11:17 am

    I forgot to return a value from -(id)init. I am returning self. My new -(id)init code is below.

    -(id)init {
    
        self = [super init];
    
        keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"exampleID" accessGroup:nil];
        NSString *passPhrase = [keychain objectForKey:(id)kSecValueData];         
    
        // Start request
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.website.com/authorization.php"]];
        ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
        [request setPostValue:passPhrase forKey:@"passphrase"];
        [request setPostValue:@"YES" forKey:@"receivingAuthorization"];
        [request setDidFinishSelector:@selector(requestFinished:)];
        [request setDidFailSelector:@selector(requestFailed:)];
        [request setDelegate:self];
        [request startAsynchronous];
    
        return self;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

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.