|
From: | Andreas Heppel |
Subject: | Re: How to initialise an array class inheriting from NSArray? |
Date: | Wed, 04 Jun 2003 10:17:40 +0200 |
I've got a class that inherits from NSArray, but don't know how to initialise it. Here's how it looks:In addition to what Yen-Ju already said it should be mentioned that the code above would eventually fail anyway. +arrayWithObjects returns an autoreleased array, meaning that the resulting array would be gone sooner or later automatically and your app would blast.@implementation NewClass : NSArray. [...] - (id) init { self = [super arrayWithObjects: @"String1", @"String2", nil]; return self; }
Concerning categories, be aware that adding a category to NSArray would affect _all_ NSArray objects in your app, even those you do not want to use as data sources. This does not automatically mean that categories are bad, but simply keep it in mind.
Andreas -- Andreas Heppel Mail: aheppel at web dot de Home: http://www.andreasheppel.de Check out Burn.app - the CD burning frontend for GNUstep http://gsburn.sourceforge.net
[Prev in Thread] | Current Thread | [Next in Thread] |