My common way of handling this would be NSNotificationCenter. It is a singleton
so I am always sure that it is there, and I can wrap all parameters into the
userInfo dictionary.
Sent from my iPhone
On 2013年7月30日, at 21:19, KappA rejek...@gmail.com wrote:
I sometimes just access my
On 30 Jul 2013, at 15:44, Maxthon Chan xcvi...@me.com wrote:
My common way of handling this would be NSNotificationCenter. It is a
singleton so I am always sure that it is there, and I can wrap all parameters
into the userInfo dictionary.
NSNotificationCenter is not a singleton:
$ cat
While all theses methods may look valid, what not simply use a static variable
declared in your file ?
Instead of trying to use complex approach to hide the fact you need a global,
just use one, and don't try to reuse the existing one for things there are not
designed to do.
static id
Sorry, clicked a wrong button.
On Aug 7, 2013, at 16:00, Maxthon Chan xcvi...@me.com wrote:
Well here is a reason I think that is valid enough to implement a callback
using notifications: that is what Objective-C use for what callbacks used to
do, besides target-actions and delegations. In
On Aug 7, 2013, at 1:47 AM, Jean-Daniel Dupas devli...@shadowlab.org wrote:
While all theses methods may look valid, what not simply use a static
variable declared in your file ?
DING DING DING DING! WE HAVE A WINNER!
Actually, much of the history behind other methods for singletons revolves
On Aug 7, 2013, at 3:47 AM, Jean-Daniel Dupas devli...@shadowlab.org wrote:
Instead of trying to use complex approach to hide the fact you need a global,
just use one, and don't try to reuse the existing one for things there are
not designed to do.
static id myCallbackHandler;
void
Le 7 août 2013 à 17:32, Andy Lee ag...@mac.com a écrit :
On Aug 7, 2013, at 3:47 AM, Jean-Daniel Dupas devli...@shadowlab.org wrote:
Instead of trying to use complex approach to hide the fact you need a
global, just use one, and don't try to reuse the existing one for things
there are not
On Aug 7, 2013, at 12:04 PM, Jean-Daniel Dupas devli...@shadowlab.org wrote:
If you intend to use it from multiple threads, so use a tls.
__thread id myCallbackHandler;
I did not know about __thread, thanks for this. By using tls you're
effectively having each thread store the info that
Le 7 août 2013 à 18:34, Andy Lee ag...@mac.com a écrit :
On Aug 7, 2013, at 12:04 PM, Jean-Daniel Dupas devli...@shadowlab.org wrote:
If you intend to use it from multiple threads, so use a tls.
__thread id myCallbackHandler;
I did not know about __thread, thanks for this. By using tls
On Jul 30, 2013, at 5:29 PM, Michael Crawford li...@warplife.com wrote:
That class object occupies a
non-zero quantity of memory, at its lowest level being somewhat like
the combination of a single copy of a C struct, as well as some C
functions, that from the Objective-C point of view, appear
Hi everybody,
I have a very simple question: if I embed a C-function (more precisely, a
callback from an external C-library) in an Obj-C object, can I expect this
function to behave like a regular method? I.e. can it freely access ‘self’ and
other attributes?
Thanks a lot!
Vincent
On Jul 30, 2013, at 00:59 , Vincent Habchi vi...@macports.org wrote:
I have a very simple question: if I embed a C-function (more precisely, a
callback from an external C-library) in an Obj-C object, can I expect this
function to behave like a regular method? I.e. can it freely access
I don't think so, not it if has a C-language prototype rather than an
Objective-C method prototype.
However, I expect there is a way you could call an Objective-C method
from vanilla C. Possibly you will need some assembly-language glue.
Ultimately, Objective-C method calls are implemented, I
Rick,
thanks for answering, because what I found on the Internet seems contradictory.
Some say that if the C function is placed inside the implementation block, then
it can access attributes as if it were a true Obj-C method; some say otherwise.
So it’s a bit difficult to find a definitive
On Jul 30, 2013, at 01:27 , Vincent Habchi vi...@macports.org wrote:
Rick,
thanks for answering, because what I found on the Internet seems
contradictory. Some say that if the C function is placed inside the
implementation block, then it can access attributes as if it were a true
Obj-C
Le 30 juil. 2013 à 10:27, Vincent Habchi vi...@macports.org a écrit :
Rick,
thanks for answering, because what I found on the Internet seems
contradictory. Some say that if the C function is placed inside the
implementation block, then it can access attributes as if it were a true
The first two parameters to the function have to be an id and a SEL ...
typedef id (*IMP)(id, SEL, ...);
... (this is where we get self and _cmd, by the way) followed by the rest of
the method params, if any.
lowell
On Jul 30, 2013, at 12:59 AM, Vincent Habchi vi...@macports.org wrote:
I sometimes just access my objc-objects from a C thread-proc via the
AppDelegate (providing there's a trail to the object I need, which there
usually is)... If the callback void pointer parameter isn't being used for
something else, you can simply cast the object in there... or if you need
On Jul 30, 2013, at 4:19 AM, Rick Mann rm...@latencyzero.com wrote:
On Jul 30, 2013, at 00:59 , Vincent Habchi vi...@macports.org wrote:
I have a very simple question: if I embed a C-function (more precisely, a
callback from an external C-library) in an Obj-C object, can I expect this
On Jul 30, 2013, at 8:35 AM, Andy Lee ag...@mac.com wrote:
The only effect, as others have explained, is on scope; if you put the
function inside the @implementation and the function has a reference to an
instance of MyClass, then it can use myObj-myIvar for direct access to
instance
On Jul 30, 2013, at 4:27 AM, Vincent Habchi vi...@macports.org wrote:
Yes, right; it’s a SQLite callback, the first parameter is a void *. I wanted
to pass a pointer to a structure containing both a unique query id (out of
uuid) and a pointer to self, but got told off by ARC because it
On Jul 30, 2013, at 10:42 AM, Scott Ribe scott_r...@elevated-dev.com wrote:
On Jul 30, 2013, at 8:35 AM, Andy Lee ag...@mac.com wrote:
The only effect, as others have explained, is on scope; if you put the
function inside the @implementation and the function has a reference to an
instance
On Jul 30, 2013, at 9:08 AM, Andy Lee ag...@mac.com wrote:
I think it's subject to the same criticisms as *any* direct access to ivars,
although I agree it feels sketchier when done in plain C for some reason.
Yes. Because what is the point of plain C functions in Objective-C files? Local
On Jul 30, 2013, at 4:26 AM, Michael Crawford li...@warplife.com wrote:
However, I expect there is a way you could call an Objective-C method
from vanilla C. Possibly you will need some assembly-language glue.
The nice thing is, you don't need glue. You can send Objective-C messages from
On Jul 30, 2013, at 11:25 AM, Scott Ribe scott_r...@elevated-dev.com wrote:
On Jul 30, 2013, at 9:08 AM, Andy Lee ag...@mac.com wrote:
I think it's subject to the same criticisms as *any* direct access to ivars,
although I agree it feels sketchier when done in plain C for some reason.
Le 30 juil. 2013 à 17:25, Scott Ribe scott_r...@elevated-dev.com a écrit :
On Jul 30, 2013, at 9:08 AM, Andy Lee ag...@mac.com wrote:
I think it's subject to the same criticisms as *any* direct access to ivars,
although I agree it feels sketchier when done in plain C for some reason.
Hi and thanks a lot to anybody!
I posted some answer before, but since it included a screenshot I’m afraid it
didn’t make it through. I was just trying to show that when I access an iVar of
‘self’ in the C-function (e.g. self - _egg), Xcode autocompletion pop-up shows
the iVars list, but each
On Jul 30, 2013, at 8:54 AM, Vincent Habchi vi...@macports.org wrote:
Apple's recommended alternative to having a struct contain an object is to
use a class instead of a struct. You could create a MyCallbackInfo class
with two properties: the query id and the pointer to self. You'd still
On Jul 30, 2013, at 08:54 , Vincent Habchi vi...@macports.org wrote:
The way SQLite works, after a query is submitted, the thread is suspended and
a callback is repeatedly executed
There's one other consideration, in the case when the callback is called a
thread other than the main thread,
On Jul 30, 2013, at 8:48 AM, Andy Lee wrote:
On Jul 30, 2013, at 11:25 AM, Scott Ribe scott_r...@elevated-dev.com wrote:
On Jul 30, 2013, at 9:08 AM, Andy Lee ag...@mac.com wrote:
I think it's subject to the same criticisms as *any* direct access to
ivars, although I agree it feels
On Tue, Jul 30, 2013, at 11:49 AM, Lee Ann Rucker wrote:
On Jul 30, 2013, at 8:48 AM, Andy Lee wrote:
On Jul 30, 2013, at 11:25 AM, Scott Ribe scott_r...@elevated-dev.com
wrote:
On Jul 30, 2013, at 9:08 AM, Andy Lee ag...@mac.com wrote:
I think it's subject to the same criticisms
The same is true for class methods, by the way. If a class method has a
reference to
an instance of the class, it can directly access the instance's ivars the
same way.
Objective-C shares a property with some languages, but not with
others, that classes are actual objects.
That is, if my
32 matches
Mail list logo