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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:57:27+00:00 2026-06-14T07:57:27+00:00

Just learning Objective-C coming from a Java background. I am trying to write a

  • 0

Just learning Objective-C coming from a Java background. I am trying to write a program that has no purpose other then to teach me how to write functions in this language and I am getting errors everywhere. The problem is since I just started with this language yesterday the errors make no sense to me. Here is what I have so far.

Main Method:

int main (int argc, const char * argv[])
{
    @autoreleasepool
    {
        NSString * prompt = @"Hello World";

        prompt = writePromptMessage(prompt);

        NSLog(@"%@", prompt);
    }

    return 0;
}

Special Method:

NSString *writePromptMessage(NSString * prompt)
{
    return prompt;
}

My Errors:

  • Implicit declaration of function writePromptMessage is invalid in C99
  • Implicit conversion of ‘int’ to ‘NSString *’ is disallowed with ARC
  • Incomplete integer to pointer conversion assigning NSString strong from int
  • Conflicting Types for writePromptMessage
  • 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-14T07:57:29+00:00Added an answer on June 14, 2026 at 7:57 am

    Unlike Java, you need to add a function declaration (aka a function prototype) before the point where it’s used. A function declaration is just like the function definition, but without the body (i.e. the code) of the function, and ending with a semicolon:

    // This is a function declaration:
    NSString *writePromptMessage(NSString * prompt);
    
    // This is a function definition:
    NSString *writePromptMessage(NSString * prompt)
    {
        // Function body goes here
    }
    

    In order to be able to call a function, you need to have written a declaration before the usage site:

    NSString *writePromptMessage(NSString * prompt);  // declaration
    
    int main (int argc, const char * argv[])
    {
        ...
        writePromptMessage(...);  // usage
    }
    
    // definition follows
    

    Alternatively, you can place the whole definition before the usage site, but this won’t always be possible (e.g. if you have two functions which can call each other).

    C and Objective-C do actually allow you to call functions that don’t have visible declarations, but this is considered a deprecated feature because it’s easy to misuse and cause subtle errors:

    If a function is called without a visible declaration, the compiler creates an implicit
    declaration
    :

    • The implicit declaration takes an arbitrary number and types of parameters
    • The implicit declaration returns int

    So, what happened is that the compiler is assuming that writePromptMessage returns int when it first sees it, which is wrong, and that causes a cascade of other errors. For functions which don’t return int, you must never use implicit function declarations, and for functions which do return int, you should never use implicit function declarations.

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

Sidebar

Related Questions

Ok so I've just started learning java (I usually program in Objective-C). My first
G'Day Programmers, I am from Java background however I have just started learning C++
I just started learning objective c and iphone development. Coming from an asp.net and
Coming from Java background I am guessing this is expected. I would really love
I'm just learning some basic programming in Objective C and Cocoa. I'm trying to
I just recently started learning Objective C, when i run the next program i
I'm learning Objective-C and just trying out some sample code. I am getting the
I'm just learning Objective-c and I am trying to create a class the generates
I'm just learning to use XCode and program in Objective-C (my plan is to
I have started learning Objective-C, and I just wanted to verify that my understanding

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.