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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:52:29+00:00 2026-05-28T05:52:29+00:00

When I click save I am getting an error when it talks back to

  • 0

When I click “save” I am getting an error when it talks back to the AppDelegate.

I’m sure, that I’m missing something small here, but if anyone has a quick answer it would be greatly appreciated.

Here’s the error I’m getting:

-[AppDelegate saveNewUsername:username:]: unrecognized selector sent to instance 0x8e403d0

Here’s my button action:

-(IBAction)saveButtonPressed:(id)sender
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

NSString *userid = [appDelegate retrieveFromUserDefaults:@"userid"];
NSMutableArray *currentUser = [appDelegate getUserInfo:userid];
NSString *currentUsername = [currentUser objectAtIndex:0];

NSLog(@"%@", userid);

if ([currUsername.text isEqualToString:currentUsername]) {
    //here we'll check and make sure the new username is valid and doesn't already exist (for now just update local DB)
    if ([theNewUsername.text isEqualToString:@""]) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You must enter something for your new username." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    } else {
        int returnVal = [appDelegate saveNewUsername:userid username:theNewUsername.text];
        if (returnVal == 1) {
            [self dismissModalViewControllerAnimated:YES];
        } else {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"There was an error saving to the database." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
            [alert show];
        }
    }
} else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"The username you entered is not your current username." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
}
}

And here’s my AppDelegate method:

-(int)saveNewUsername:(NSString *)user_id username:(NSString *)username
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"somedbname.sqlite3"];

FMDatabase *db = [FMDatabase databaseWithPath:writableDBPath];

if (![db open]) {
    NSLog(@"Could not open db.");
    return 0;
} else {
    [db intForQuery:@"UPDATE user SET username=? WHERE user_id=?", username, user_id];

    if ([db hadError]) {
        NSLog(@"Error %d: %@", [db lastErrorCode], [db lastErrorMessage]);
        return 0;
    } else {
        return 1;
    }
}
}
  • 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-28T05:52:30+00:00Added an answer on May 28, 2026 at 5:52 am

    Your code looks OK. So I guess appDelegate is actually not an instance of AppDelegate.

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    

    Set a breakpoint there and have a look in the debugger to check whether it is indeed an instance of AppDelegate.

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

Sidebar

Related Questions

I may be missing something obvious here, but how could I rewrite this code!
I currently have a simple form that when you click the save button will
I'm getting back into .NET development after a couple years and it seems that
I'm getting the same error when I'm trying to delete my save files. The
OK have just started getting this error and I'm not sure why. I have
I am constantly getting the EXC_BAD_ACCESS error in multiple places but always on the
Hi I m getting this error when I save a file in asp.net. I
my ajax is : $('#save').click(function(){ $.post(http://127.0.0.1:8080/sss, function(data){ alert(data); }); }) and the django view
I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:
I am using the TSaveDialog component to save a file from a button click.

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.