• 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: Calling an object from a C function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling an object from a C function


  • Subject: Re: Calling an object from a C function
  • From: "mm w" <email@hidden>
  • Date: Tue, 19 Aug 2008 16:40:17 -0700

did you mean: (im not sure to understand your problem) ???!!!

#import <Foundation/Foundation.h>

int foo(int a, int b) {
	return (a + b);
}

@interface myObject: NSObject

-(SInt32)aIntegertFunction:(SInt32)a plus:(SInt32)b;

@end

@implementation myObject

-(SInt32)aIntegertFunction:(SInt32)a plus:(SInt32)b
{
  return foo(a,b);
}

@end

int main (
  int argc, const char * argv[])
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  myObject *obj = [[myObject alloc] init];

  NSLog(@" %i", [obj aIntegertFunction:10 plus:10]);

  [obj release];

  [pool drain];

  return 0;
}

On Tue, Aug 19, 2008 at 4:38 PM, David Duncan <email@hidden> wrote:
> On Aug 19, 2008, at 4:28 PM, Charlie Dickman wrote:
>
>> from within a C (not Objective C) function and make use of the result?
>>
>> In Objective C I would invoke
>>
>> [myObject myMethod: myInt];
>
>
> You invoke it exactly the same way. There is no difference. But you need to
> compile as Obj-C.
>
> int foo(id bar) { [bar foobaz]; }
> --
> David Duncan
> Apple DTS Animation and Printing
>
> _______________________________________________
>
> 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
>



--
-mmw
_______________________________________________

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: 
 >Calling an object from a C function (From: Gilbert Mackall <email@hidden>)
 >Re: Calling an object from a C function (From: David Duncan <email@hidden>)
 >Re: Calling an object from a C function (From: Charlie Dickman <email@hidden>)
 >Re: Calling an object from a C function (From: David Duncan <email@hidden>)

  • Prev by Date: Re: Calling an object from a C function
  • Next by Date: Re: Calling an object from a C function
  • Previous by thread: Re: Calling an object from a C function
  • Next by thread: Re: Calling an object from a C function
  • Index(es):
    • Date
    • Thread