Local Properties
Local Properties
- Subject: Local Properties
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Tue, 04 Sep 2012 12:24:59 +0700
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 (email@hidden)
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:
This email sent to email@hidden