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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:04:09+00:00 2026-05-22T19:04:09+00:00

I know, I know. I’ve Google and searched here but can’t figure out what’s

  • 0

I know, I know. I’ve Google and searched here but can’t figure out what’s going on.

Anyway, i’m getting this error when using the following code, i’m sure it’s something small. I know it’s to do with memory management and down to how i’m handling my object in the main method.

Here’s my main code:

Person *p1 = [[Person alloc] init];
[p1 initWithFirstname:@"John" lastname:@"Doe" andAge:23];

outputText.text = [p1 getDetails]; // App crashes inside getDetails

Then in the person class here’s the two relevant methods:

-(Person *)initWithFirstname:(NSString *)_firstname lastname:(NSString *)_lastname andAge:
(int)_age {
self = [super init];

if(self) {
self.firstname = _firstname;
self.lastname = _lastname;
self.age = _age;

}
return self;
}


-(NSString *)getDetails {
 return [NSString stringWithFormat:@"%@ %@, %@", firstname, lastname, age];
}
  • 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-22T19:04:09+00:00Added an answer on May 22, 2026 at 7:04 pm

    Judging by your init method, age is an int which means the format specifier is wrong. Try this:

    -(NSString *)getDetails 
    {
        return [NSString stringWithFormat:@"%@ %@, %d", firstname, lastname, age];
        //                                         ^^ format specifier for an int
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Know this might be rather basic, but I been trying to figure out how
I know that this sort of question has been asked here before, but still
I know the meaning of this error, but I'm really struggling with it, and
I know that this has been discussed thousand times but I still cannot figure
I know I have done this before but I can't seem to remember where
I know you can not set a key value dynamically, but what about the
i know this is a stupid question but i d'ont know how to do
I know theres a lot of posts about redirects but this is a little
I know that this isn't exactly normalised, but bringing all of the localised data
I know you can use a javascript to do this <script type=text/javascript> touchMove =

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.