• 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: posting message to text view from C-function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: posting message to text view from C-function


  • Subject: Re: posting message to text view from C-function
  • From: j o a r <email@hidden>
  • Date: Fri, 6 May 2005 11:13:06 +0200


On 6 maj 2005, at 10.53, Roland Silver wrote:

The question becomes, where does the CALLER get a reference to the text view, so as to provide it as a parameter?
In other words, the caller, itself a C-function (call it cFunction2), will have to invoke plainCFunction this way:
... plainCFunction(textView); ...
so if it can't conjure up the reference to the text view, how does IT get it??

The simplified answer is that if it doesn't get it via a parameter, it must have created it.
This is not a problem that is specific to C-functions. It works in exactly the same way for Objective-C methods.
The only thing that differs is that an ObjC method is passed a "secret" parameter - the reference to "self". Via this parameter you get access to the instance variables of the object in question.


I think that your problem is that you have an existing ObjC object graph, in a Cocoa application, and you have some C-functions that you want to use in that context. Right so far? You need to think about what event that triggers the C-functions to be called in the first place. When the first C-function is called, it needs to have knowledge about some part of the ObjC object graph, to be able to access the data in that graph. If your C-function is called from an ObjC method, just pass along the required parameters as have been discussed previously in this thread. If the C-function is called from some sort of callback, there is often (always?) some sort of context (void *) pointer that can be used for that same purpose.

If you want more help, I think you need to give a concrete example of what you're trying to do.

j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: 
 >posting message to text view from C-function (From: Roland Silver <email@hidden>)
 >Re: posting message to text view from C-function (From: Ondra Cada <email@hidden>)
 >Re: posting message to text view from C-function (From: Roland Silver <email@hidden>)
 >Re: posting message to text view from C-function (From: j o a r <email@hidden>)
 >Re: posting message to text view from C-function (From: Roland Silver <email@hidden>)

  • Prev by Date: Re: Running AppleScript without Window Server context
  • Next by Date: Re: to NSTask or not to NSTask
  • Previous by thread: Re: posting message to text view from C-function
  • Next by thread: Re: posting message to text view from C-function
  • Index(es):
    • Date
    • Thread