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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:21:30+00:00 2026-05-28T04:21:30+00:00

i am having objective c class, which i have a C function in it.

  • 0

i am having objective c class, which i have a C function in it.
in that C function i want to call to ANOTHER c function in another class.

in the first class C function , i do this :

  HelloWorldLayer *ran;
  ran=[[HelloWorldLayer alloc] init];
  [ran showDigital:BinaryWord];

when HelloWorldLayer is the other class, which have the C function :

void showDigital( int word[4])

and it declared also in the HelloWorldLayer.h .

in the first class, when i am trying to call the other function it says that showDigital function is not found.

is it has to do with the fact that its a C function ?

thanks.

  • 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-28T04:21:31+00:00Added an answer on May 28, 2026 at 4:21 am

    First of all, the C function is not in the other class, it is merely in the same file as the other class. Objective-C classes have methods not functions.

    So you can call your C function from anywhere provided you have an extern declaration of it. e.g. in HelloWorldLayer.h

    extern void showDigital(int* word);
    

    If you really want the function to be associated with instances of your class, you need to make it an Objective-C method. You can have that method be a thin wrapper for the original function if you like:

    -(void) showDigital: (int*) word
    {
        showDigital(word);
    }
    

    If you want to pretend that your C function is part of an object, you’ll need to add the receiver object as a parameter. You still won’t be able to access private instance variables directly though.

    void showDigital(id self, int* word)
    {
        [self foobar];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an API class, lets call it MyClass, which I want to be
I'm having a bug in my Objective C program which causes the machine to
Still new to Objective C, and I'm having some trouble that I just can't
I am writing a simple console application in Objective-C but I have heard that
I am trying to use the UINavigationController class in Objective-C, but I am having
I'm kind of a newbie in objective-c and I'm having issues when I call
I have a class that implements IAuthorizationPolicy. I set up a custom Principal object
In some languages like C# and Objective C, you can create class extensions. That
Short version: I have a Qt/C++ to which I am having to add a
I am having some trouble calling an objective-c class method from a C++ file.

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.