• 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
Making an array property without a backing store. How?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making an array property without a backing store. How?


  • Subject: Making an array property without a backing store. How?
  • From: Daryle Walker <email@hidden>
  • Date: Mon, 06 Apr 2015 22:01:22 -0400

I have an object like:

@interface MyClass : NSObject
@property (readonly) NSArray *  myDatumList;
@property NSArray *  myDataList;
@end

The second member is meant to be an actual data member, an array of mutable dictionaries. The first member isn’t supposed to have a backing store; accessing a member of the first array references the corresponding member of the second, then access a dictionary attribute with a custom key.

I have a custom array count and array element read methods for the first member.

The program does nothing now. I checked with my limited debugging skills that the second member has one element, but the first member is looped though as if it has no elements. I see that BOTH “_myDatumList” and “_myDataList” internal members exist, with the former set as NIL. I’ve heard that we used to need to use the “@synthesize” command to create internal members, then a later version of the Objective-C compiler did it automatically. Now I have the reverse problem; the first member gets a backing store automatically, but I do NOT want that; I always want to use the custom array accessor methods to simulate “myDatumList” with pieces of “myDataList.”

So, how can I turn off auto-@synthesize? Using “@dynamic” doesn’t work; it causes a crash due to a missing [MyClass myDatumList] method. I also saw a random page saying that “self.myDatumList” causes this, but “myDatumList” wouldn’t (like the “self.” gives the unwanted backing store have priority over the array accessor methods). Is that accurate?

—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT 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: Making an array property without a backing store. How?
      • From: Greg Parker <email@hidden>
    • Re: Making an array property without a backing store. How?
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Where is my bicycle?
  • Next by Date: Re: Making an array property without a backing store. How?
  • Previous by thread: Getting two copies of my Today Extension
  • Next by thread: Re: Making an array property without a backing store. How?
  • Index(es):
    • Date
    • Thread