• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using xcode ,how to compile .c file as .m file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using xcode ,how to compile .c file as .m file?


  • Subject: Re: using xcode ,how to compile .c file as .m file?
  • From: Kiel Gillard <email@hidden>
  • Date: Tue, 30 Mar 2010 20:55:15 +1100

On 30/03/2010, at 8:32 PM, simon Scylla wrote:

> i need to port some code to iphone and now i find that i can not call system
> interface of objc. i can rename my files from 888.c  to ***.m and it works.
> but i do not wanna rename my files.
> what should i do?i think there must be some choice in xcode.but i don't
> konw......[?]

Wrap your C functions in Objective-C methods.

For example:

SomeController.m

#import "libwhatever.h"

@implementation SomeController

+ (void)initializeLibrary
{
	InititaliseCLibrary();
}

- (BOOL)writeToURL:(NSURL *)url
{
	char path[255];
	//convert URL to C string using NSURL/CFURL API here

	//call C library
	int result = WriteFileToPath(...);

	//return a value
	return (result == 0 ? YES : NO);
}

....and so on. This is the exact same way parts of Carbon and CoreFoundation is used in an Objective-C based application.

> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >using xcode ,how to compile .c file as .m file? (From: simon Scylla <email@hidden>)

  • Prev by Date: using xcode ,how to compile .c file as .m file?
  • Next by Date: Re: using xcode ,how to compile .c file as .m file?
  • Previous by thread: using xcode ,how to compile .c file as .m file?
  • Next by thread: Re: using xcode ,how to compile .c file as .m file?
  • Index(es):
    • Date
    • Thread