• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Local Properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Local Properties
      • From: Graham Cox <email@hidden>
    • Re: Local Properties
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: UIDocument openWithCompletionHandler: called on what thread?
  • Next by Date: Re: Local Properties
  • Previous by thread: Customising cells in IKImageBrowserView
  • Next by thread: Re: Local Properties
  • Index(es):
    • Date
    • Thread