NSMutableArray with only a particular type of objects

Posted by Leo on Stack Overflow See other posts from Stack Overflow or by Leo
Published on 2010-04-28T12:01:19Z Indexed on 2010/04/28 12:03 UTC
Read the original article Hit count: 305

Hello, is it possible to specify that a NSMutableArray can only contain a certain type of objects. For example, if I want to store only this kind of objects :

@interface MyObject : NSObject {
    UInt8 value; 
}

In order to be able to use the instance variable like this :

- (void)myMethod:(NSMutableArray *)myArray{
    for (id myObject in myArray){
        [self otherMethod:myObject.value];
    }
}

because I'm getting this error :

request for member 'value' in something not a structure or union

Thank you for your help

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nsmutablearray