[Biococoa-dev] Caching the NSArray of BCSymbol
Koen van der Drift
kvddrift at earthlink.net
Wed Jul 6 17:56:09 EDT 2005
On Jul 6, 2005, at 1:44 PM, Charles Parnot wrote:
> Then, we should only cache it in one place: the accessor. Though for
> mutable sequences, we also need to remember to set the cached array to
> nil after modifications. Something like this:
>
> - (NSArray *)symbolArray
> {
> if ( cachedArray == nil ) {
> cachedArray = ... //generate the array (and retain it)
> }
> return cachedArray;
> }
>
> - (void)emptyCache
> {
> [cachedArray release];
> cachedArray = nil;
> }
>
> - (void)appendSequence:(BCSequence *)otherSequence
> {
> //code to append the sequence
> ...
> //empty the cache: the array is not valid anymore!!
> [self emptyCache];
> }
>
>
> what do you think?
>
Looks like a good start to me :) Maybe we can write the code in such a
way that the BCSequence can be a delegate of another object (eg a
view).
- Koen.
More information about the Biococoa-dev
mailing list