Re: Encapsulating methods in ObjC
Re: Encapsulating methods in ObjC
- Subject: Re: Encapsulating methods in ObjC
- From: Lindsey Spratt <email@hidden>
- Date: Wed, 21 May 2003 09:07:20 -0500
On Wednesday, May 21, 2003, at 08:25 AM,
email@hidden wrote:
Furthermore, if this sort of thing were to be needed with any
frequency, I might very well wrap it up in a higher order message, so
it looks like this:
[[self inProtectedGstate] drawMyObject];
This is something I've wondered about the best way to do in ObjC. In
Lisp or Prolog, I'd just use a metacall:
My Lisp is very rusty , but I think it would be something like:
(defun with-protected-gstate (Expr)
(save-gstate)
(eval Expr)
(restore-gstate))
Then one can use this by:
(with-protected-gstate (draw-object obj))
In Prolog:
with_protected_gstate(Goal) :-
save_gstate,
call(Goal),
restore_gstate.
Used by:
with_protected_gstate(draw_object(Obj)).
But it seemed to me that I'd need to use selectors and/or NSInvocation
to get a similar facility in ObjC. What kind of object does '[self
inProtectedGstate] ' return? Could you give more code for your example?
Fascinated,
Lindsey Spratt
http://homepage.mac.com/lspratt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.