• 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: Encapsulating methods in ObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Encapsulating methods in ObjC
      • From: Marcel Weiher <email@hidden>
  • Prev by Date: Re: Future Objective-C changes
  • Next by Date: Re: Encapsulating methods in ObjC
  • Previous by thread: NSOpenGLView drawing
  • Next by thread: Re: Encapsulating methods in ObjC
  • Index(es):
    • Date
    • Thread