1

Objective C is meant to support C. I have some code in C language and I want to use it in objective C how is that possible? I know it is possible but I am not sure how.

Edit
I want to use following code in objective C. How can I do it?

string FileMeasure="Hello FILE!"
int TempNumOne=FileMeasure.size();
char Filename[100];
for (int a=0;a<=TempNumOne;a++)
{
    Filename[a]=FileMeasure[a];
}

Thanks
Pankaj

10
  • 2
    C code is Objective-C code. Commented Apr 23, 2011 at 18:36
  • 1
    Note that the code in your question is not valid C. It looks like you’re mixing C with C++. Commented Apr 24, 2011 at 5:38
  • Yes. That’s called Objective-C++; any C++ code is also valid Objective-C++ code. Commented Apr 24, 2011 at 5:41
  • but when I am trying to use it I am getting error Commented Apr 24, 2011 at 5:47
  • See my answer. What error do you get? Commented Apr 24, 2011 at 5:53

3 Answers 3

5

Objective-C is just a kind of layer over C...

If you have C libraries, C code, C functions, or whatever, you'll be able to use them from Objective-C...

Just think about Objective-C as a wrapper for object-oriented C code...

Maybe you'll have to add details, if you want a more specific answer...

Sign up to request clarification or add additional context in comments.

Comments

1

Objective C is meant to support C.

Not sure what this means. Objective-C is a superset of C.

I have some code in C language and I want to use it in objective C

Just use it. Generally there's no magic required.

Comments

0

As language, you can consider Objective-C a "super set" of C, so that pure C code works fine when compiled in a Obj-C project; but this is about the language itself, the standard library (it is available in Obj-C as well), and any library with "C linkage". If it makes sense and if it will work or not depends on what exactly the C code does. E.g. if it uses a system-specific library, there could be a porting issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.