• 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
Re: Accessing members from NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing members from NSDictionary


  • Subject: Re: Accessing members from NSDictionary
  • From: Tom Davie <email@hidden>
  • Date: Fri, 05 Apr 2013 15:00:28 +0100

On 5 Apr 2013, at 14:55, Pax <email@hidden> wrote:

> On 5 Apr 2013, at 14:20, Mike Abdullah <email@hidden> wrote:
>
>>
>> For a start, trying to access instance variables directly is almost always a bad idea. Expose proper accessor methods instead.
>>
> Why is it a bad idea?  I do this quite often, and I find it has the double benefit of improving readability and reducing the number of lines of code.  But if it's bad then I shall look to mend my ways - but I'll need to understand the badness first!

The reason it's a bad idea is because it means that you have two strongly coupled components of code.  You can not change the implementation of the class with the ivar, without also changing the implementation of the other class now.

I don't really understand your argument about lines of code or readability, you would be replacing

someObject->someIvar = 56.9f;

with

someObject.someProperty = 56.9f;

and

{
    float someIvar;
}

with

@property (assign, nonatomic) float someProperty;

So neither is really true.

Thanks

Tom Davie
_______________________________________________

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: Accessing members from NSDictionary
      • From: Pax <email@hidden>
    • Re: Accessing members from NSDictionary
      • From: Pax <email@hidden>
References: 
 >Accessing members from NSDictionary (From: Pax <email@hidden>)
 >Re: Accessing members from NSDictionary (From: Mike Abdullah <email@hidden>)
 >Re: Accessing members from NSDictionary (From: Pax <email@hidden>)

  • Prev by Date: Re: Accessing members from NSDictionary
  • Next by Date: Re: Accessing members from NSDictionary
  • Previous by thread: Re: Accessing members from NSDictionary
  • Next by thread: Re: Accessing members from NSDictionary
  • Index(es):
    • Date
    • Thread