I have a class with a mutable array. But from outside it should be just a 
read-only non-mutable array.
My current solution:

MyClass.h file contains:

@property (readonly, nonatomic) NSArray *externalArray;

and MyClass.m file has:

@interface MyClass()
@property (strong)      NSMutableArray  *internalArray;
@end

@implementation MyClass
- (NSArray *) externalArray { return self.internalArray; }
@end

Is there a better (more elegant) way?


And another question:
I have a struct property like:
@property (assign)      some_Struct_t           myStruct;

But when I write:
self.myStruct.something = 7;
I get told "Expression is not assignable". (Xcode 4.4.1)

This works:
some_Struct_t temp = self.myStruct;
temp.something = 7;
self.myStruct = temp;

But this is not really nice. There sure must be a better way.

Gerriet.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to