• 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: SmartList
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SmartList


  • Subject: Re: SmartList
  • From: Alex Zavatone <email@hidden>
  • Date: Thu, 19 Dec 2013 17:53:20 -0500


On Dec 19, 2013, at 8:03 AM, Chris Page wrote:

On Dec 18, 2013, at 8:35 PM, Shane Stanley <email@hidden> wrote:

on containsObject:anObject -- whether array contains an object
return ((setStore's containsObject:anObject) as integer = 1)
end containsObject:

Looks like you missed renaming one “setStore” to “arrayStore" when adapting the code to lists.

By the way, I don’t recommend naming “setStore” with “set” as a prefix, because that’s the Cocoa naming convention for setter methods/handlers.

A little more on this that might clarify it a bit for ya.

In Objective-C, with you have a declared property in an NSObject, it gets accessor methods when it's "synthesized", or when it's made real so that code can access it.

These accessors are the ones to set and get the values of the property object.

Now, you'd assume that the methods just append the words "set" and "get" on to the variable and then capitalize the next letter of the method, like so:

Property: bunnies
Expected accessors:
setBunnies
getBunnies


What really happens is very close to this.

The set accessor is indeed setBunnies, but the get accessor method is the exact name of the variable, bunnies.  This can be confusing to the uninitiated, because at first glance, you're not sure if you're directly accessing a property's value, or if you're calling an accessor method on the object that holds the property and it returns the value.

Property: bunnies
Real accessors:
setBunnies
bunnies

So, here's what both look like:

Accessing the property directly:

Getting
NSBunnies *myBunnies = myAwesomeObject.bunnies; // syntax is: object dot property.

Setting
myAwesomeObject.bunnies = [[NSBunnies alloc]initWithMoreBunnies: 5];

And through the accessor methods:

Getting
NSBunnies *myBunnies = [myAwesomeObject bunnies]; // the brackets mean a method call on an object. [anObject aMethodInIt]

Setting
[myAwesomeObject setBunnies: [[NSBunnies alloc]initWithMoreBunnies: 5]];

Hope that helps (a little)
And with that done, back to the everlasting joy that is the appearance manager.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: SmartList
      • From: Chris Page <email@hidden>
    • Re: SmartList
      • From: Shane Stanley <email@hidden>
References: 
 >SmartList (From: Shane Stanley <email@hidden>)
 >Re: SmartList (From: Chris Page <email@hidden>)

  • Prev by Date: Re: SmartList
  • Next by Date: Re: SmartList
  • Previous by thread: Re: SmartList
  • Next by thread: Re: SmartList
  • Index(es):
    • Date
    • Thread