Re: Defining subclasses at run time

2012-06-11 Thread Greg Parker
On Jun 11, 2012, at 2:35 AM, Oleg Krupnov wrote: > Now the problem is that I need multiple arrays of MyItems have > different contexts. The solution could be to add the context pointer > as an ivar to each MyItem instance, but I would not like to waste > memory on that (the arrays are huge). Firs

Re: Defining subclasses at run time

2012-06-11 Thread Jens Alfke
On Jun 11, 2012, at 9:50 AM, Rainer Brockerhoff wrote: > You could subclass NSArray (tricky because it's a class cluster), adding the > context variable as an ivar to that; or make your own class containing that > context and the actual array, and implementing all the proper methods. I don't t

Re: Defining subclasses at run time

2012-06-11 Thread Rainer Brockerhoff
On Jun 11, 2012, at 13:20 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Mon, 11 Jun 2012 12:35:13 +0300 > From: Oleg Krupnov > Message-ID: > > > I'm solving the following problem. I have a huge array of items of the > same class MyItem. All items need to share a certain global "conte

Defining subclasses at run time

2012-06-11 Thread Oleg Krupnov
Hi, I'm solving the following problem. I have a huge array of items of the same class MyItem. All items need to share a certain global "context" variable. Normally, I would wrap access to this variable in a class-level (+) method of MyItem, like +[MyItem getContext]. Now the problem is that I nee