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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:34:32+00:00 2026-05-27T05:34:32+00:00

I am learning Objective C I have the following trouble. If I use the

  • 0

I am learning Objective C

I have the following trouble.

If I use the libretto NSObject my program work fine,
but if I change to use the library Object.h,
the program doesn’t work.

The code is:

//-------------------------------------------------------------
/* Saludar.h */
//-------------------------------------------------------------
#import <objc/Object.h>

@interface  Saludar : Object
{
    char* strSaludo;
}
- (id)init;
- (void)setSaludo:(char*)sSaludo;
- (void)setSaludo:(char*)sSaludo y:(char*)sMensaje;
- (void)subSaludar;
@end

// ---------------------------------------------------------------
// Saludar.m
// ---------------------------------------------------------------
#import "Saludar.h"
#import <stdio.h>
#import <stdlib.h>
#import <string.h>

@implementation Saludar

- (id)init
{
    if (self = [super init])
    {
        strSaludo = "Programando en Objective-C";
    }
    return self;
}

- (void)setSaludo:(char*)sSaludo
{
    strSaludo = sSaludo;
}

- (void)setSaludo:(char*)sSaludo y:(char*)sMensaje
{
    // Reserva memoria para el Mensaje
    strSaludo = malloc(strlen(sSaludo)+strlen(sMensaje)+1);

    // Copia el Saludo y el Mensaje
    strcpy(strSaludo,sSaludo);
    strcat(strSaludo,sMensaje);

}

- (void)subSaludar
{
    // Desplliega el Saludo
    printf("%s\n",strSaludo);
}
@end


//--------------------------------------------------------
// Clase01.m
//--------------------------------------------------------
#import "Saludar.m"

int main()
{

    //printf("Entra al Programa\n");
    Saludar* s = [[Saludar alloc] init];


    //printf("Va a Saludar\n");
    [s subSaludar];
    [s setSaludo:"Hola Jaor"];
    [s subSaludar];
    [s setSaludo:"Hola Jaor " y:"Long Live to Programming"];
    [s subSaludar];

    [s free];
    return EXIT_SUCCESS;
}

It’s like it doesn’t recognize the super class ‘super’ or doesn’t recognize
the message ‘init’.

The messages ‘alloc’ and ‘free’ aren’t recognized.

This is all message

n Framework GNU\Saludar.m||In function ‘-[Saludar init]’:| n Framework
GNU\Saludar.m|11|warning: ‘Object’ may not respond to ‘-init’ [enabled
by default]| n Framework GNU\Saludar.m|11|warning: (Messages without a
matching method signature [enabled by default]| n Framework
GNU\Saludar.m|11|warning: will be assumed to return ‘id’ and accept
[enabled by default]| n Framework GNU\Saludar.m|11|warning: ‘…’ as
arguments.) [enabled by default]| n Framework GNU\Clase02a.m||In
function ‘main’:| n Framework GNU\Clase02a.m|8|warning: ‘Saludar’ may
not respond to ‘+alloc’ [enabled by default]| n Framework
GNU\Clase02a.m|18|warning: ‘Saludar’ may not respond to ‘-free’
[enabled by default]| ||=== Build finished: 0 errors, 6 warnings ===|

The program runs, but doesn’t display messages, doesn’t work.

  • 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-27T05:34:33+00:00Added an answer on May 27, 2026 at 5:34 am

    You should subclass NSObject, not Object. Object is part of the Apple/GNUStep runtimes as a legacy class, but is not used for new development.

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

Sidebar

Related Questions

I'm learning Objective-C, and have a C/C++ background. In object-oriented C++, you always need
I'm working on learning Objective-C/Coaoa, but I've seem to have gotten a bit stuck
I am learning Objective-C and have completed a simple program and got an unexpected
Hi Just started learning c for uni (usually use objective c) and have run
I'm learning objective-C and Cocoa and have come across this statement: The Cocoa frameworks
I'm learning Objective-C at the moment and have come across optional methods in Protocols.
I'm new to programming and stackoverflow and have decided to start by learning objective
I learning Objective-C in Linux(Ubuntu), but when i tryed to compile my application that
I have just started learning Objective-C, I am reading Programming in Objective-C 3rd Edition
I'm learning Objective-C using GNUstep, because I don't have a Mac and the GNUstep

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.