• 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: Framework Major versions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Framework Major versions


  • Subject: Re: Framework Major versions
  • From: Uli Kusterer <email@hidden>
  • Date: Tue, 19 Oct 2010 23:34:59 +0200

On 19.10.2010, at 14:26, Bill Cheeseman wrote:
> I'm up to F in one of my frameworks, because I keep playing around with things that require a change in the major version.

 By the way, if you'e changing the instance variable layout, a better approach than changing the framework version each time is probably just to use a struct for your ivars, and only have a pointer to it in your public object's ivars. E.g.:

@interface MyPublicClass : NSObject
{
    struct MyPrivateIVars*    ivars;
}

@end

and then in the implementation file:

struct MyPrivateIVars
{
    NSData* foo;
};


-(id)	init
{
    if(( self = [super init] ))
    {
        ivars = calloc( sizeof(struct MyPrivateIVars), 1 );
    }
    return self;
}


-(void)	dealloc
{
    free( ivars );
    [super dealloc];
}


-(NSData*) foo
{
    return ivars->foo;
}

Advantage is that the size of a pointer doesn't change when you add new ivars to the MYPrivateIVars struct, so anyone using (and subclassing) your framework can just keep using the new class.

 If you have an existing ivar in each of your public classes that is at least the size of a pointer, you can even re-purpose existing classes that need to grow that way, thus saving you the need to do one final framework revision to switch to this "stable" ivar layout.

 Only downside is you won't be able to use @synthesize anymore.

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.com



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Framework Major versions
      • From: Bill Cheeseman <email@hidden>
References: 
 >Framework Major versions (From: Alexander Cohen <email@hidden>)
 >Re: Framework Major versions (From: Nick Zitzmann <email@hidden>)
 >Re: Framework Major versions (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: NSDictionary allValues not mutable
  • Next by Date: Re: NSDictionary allValues not mutable
  • Previous by thread: Re: Framework Major versions
  • Next by thread: Re: Framework Major versions
  • Index(es):
    • Date
    • Thread