• 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: Future Objective-C changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Future Objective-C changes


  • Subject: Re: Future Objective-C changes
  • From: Marcel Weiher <email@hidden>
  • Date: Wed, 21 May 2003 22:21:49 +0200

On Wednesday, May 21, 2003, at 09:00 Uhr, Quentin Mathi wrote:

Le mercredi, 21 mai 2003, ` 10:02 Europe/Paris, Marcel Weiher a icrit :

Hmm...I don't find it error prone. If you use convenience factor methods for temporary objects, then the only place you need to deal with reference counting is the accessor. If you use accessor-macros, the accessors, and especially the refcounting that goes on inside them essentially disappears, and the whole thing is automatic (apart from dealloc, but that is so straightforward/boiler-plate that it just disappears in the other syntactic noise of creating a class).

You are talking about accessors-macros I'm curious to see an example.

This sounds like it might be a cocoa-dev FAQ...

idAccessor( var, setVar )

generates both the get and the set accessor for (object) instance variable 'var'. The get-accessor has the same name as the instance variable, the set accessor is called -setVar:, and does all the retain/release correctly and efficiently. So you never have to deal with it again. Corresponding accessors also exist for scalar variables, these don't do any retain/release, but just assign.

So a header(-extract) looks like this:

@interface MPWTextFragment : MPWGraphicContainer {
id string;
NSPoint position;
float _width;
}

scalarAccessor_h( NSPoint, position, setPosition )
floatAccessor_h( width, setWidth )
idAccessor_h( string, setString )

with the .m file starting like this:

#import "MPWTextFragment.h"
#import <MPWScript/MPWPSFontDict.h>
#import <MPWGraphRep/MPWPSGstate.h>
#import <MPWGraphRep/MPWPSMatrix.h>
#import "MPWTextLine.h"

@implementation MPWTextFragment

scalarAccessor( NSPoint, position, setPosition )
floatAccessor( _width, setWidth )
idAccessor( string, _setString )

...


Notice that some of the declarations don't match the implementations. In these cases, there are specialized routines that refer back to the accessors.

Marcel



--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.

References: 
 >Re: Future Objective-C changes (From: Quentin Mathé <email@hidden>)

  • Prev by Date: Quicktime and NSThread
  • Next by Date: Sound & Cocoa
  • Previous by thread: Re: Future Objective-C changes
  • Next by thread: Re: Future Objective-C changes
  • Index(es):
    • Date
    • Thread