• 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: Accessing Cocoa instance variables from C functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing Cocoa instance variables from C functions


  • Subject: Re: Accessing Cocoa instance variables from C functions
  • From: Tomas Franzén <email@hidden>
  • Date: Fri, 21 Apr 2006 23:03:47 +0200

On 21 apr 2006, at 22.52, Damien Sorresso wrote:
I've got an Objective-C class that makes use of a C library I've written which has several callbacks. I want to implement these callbacks in my class, but I can't seem to access the class variables from these callbacks. The compiler tells me that the instance variables I'm trying to access are undeclared. Here's a snippet of my code.

void ITPhaseChange(char *message)
{
	NSLog(@"PHASE CHANGE: %s\n", message);
	[phaseText setStringValue:[NSString stringWithCString:message]];
}

Now with just the NSLog(...), everything compiles fine. But I want to work with the `phaseText' outlet from within this function. Is this possible?

Hi Damien,

The problem here is that C functions are not methods, which means they don't 'belong' to any object/class. One solution is to call a method from your function, and do your stuff from there.

Tomas Franzén
Lighthead Software
http://www.lightheadsw.com/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Accessing Cocoa instance variables from C functions (From: Damien Sorresso <email@hidden>)

  • Prev by Date: Re: Accessing Cocoa instance variables from C functions
  • Next by Date: Re: Getting exact height of NSAttributedString
  • Previous by thread: Re: Accessing Cocoa instance variables from C functions
  • Next by thread: Re: Accessing Cocoa instance variables from C functions
  • Index(es):
    • Date
    • Thread