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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:52:45+00:00 2026-05-26T12:52:45+00:00

I am still new in objective-c programming, I got this exception, but I don’t

  • 0

I am still new in objective-c programming, I got this exception, but I don’t know what does it mean,
The exception is here, and after it there is the code ..

Running…
2011-11-02 12:10:31.923 app3[1322:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[Person<0x100001098> init]: cannot init a class object.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00007fff8499c7b4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x00007fff84729f03 objc_exception_throw + 45
    2   CoreFoundation                      0x00007fff849f5f29 +[NSObject(NSObject) init] + 137
    3   app3                                0x0000000100000d99 main + 124
    4   app3                                0x0000000100000c60 start + 52
    5   ???                                 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
sharedlibrary apply-load-rules all

and here is the code that causes this exception , this code is only create class(interface) and makes an instance of this class tand set values ..

#import <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
@interface Person:NSObject{

    int age;
    int weight;
}

-(void) print;
-(void) setAge:(int) a;
-(void) setWeight:(int) w;

@end


@implementation Person
-(void) print{
    NSLog(@"I am %i years old and weight %i pound",age,weight);
}
-(void) setAge:(int) a{
    age = a;
}
-(void) setWeight:(int)w{
    weight = w;
}
@end

int main(int argc, char *argv[]){
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
    Person *adham;
    adham = [Person alloc];
    adham = [Person init];
    [adham setAge:24];
    [adham setWeight:68];
    [adham print];
    [pool release];
    [pool retain];
    return 0;

}
  • 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-26T12:52:46+00:00Added an answer on May 26, 2026 at 12:52 pm

    This is wrong:

    adham = [Person alloc];
    adham = [Person init];
    

    alloc is a class method, init is an instance method, you should be doing this

    adham = [[Person alloc] init];
    

    Also, looking at your two lines at the end

    [pool release];
    [pool retain];
    

    why are you retaining the NSAutoreleasePool? you shouldn’t be (you should get a crash in fact). Release the pool and return.

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

Sidebar

Related Questions

I'm still pretty new to Objective-C coding (as evidenced by this question) and I
So I'm still kind of new to Objective-C, and this was my first app
I am an Objective-C newbie, who still does not have a Mac, but still
Still new to Objective C, and I'm having some trouble that I just can't
I am still new to sharepoint and would like to know if it is
I'm still pretty new to Objective -C and iPhone development and am trying to
I'm still kind of new to Objective-C and I'm wondering what is the difference
I am still new to this Memory Management stuff (Garbage Collector took care of
Ok, I'm still new to using C sockets, but I was wondering if there
I'm still new to web app development, so bear with me if this sounds

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.