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

Re: help with methods


  • Subject: Re: help with methods
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 28 Jul 2010 17:47:54 -0500

On Jul 28, 2010, at 1:27 PM, Rounak Jain wrote:

> I am comfortable with understanding method declarations like
> - (void) someName: (NSString *) variableName;
> where
> void is return type
> someName is name of the method

Close.  "someName:" _with the colon_ is the name of the method.  There's a difference between "someName" and "someName:".

> (NSString *) is the type of the variableName and variableName is the variable
>
> However, I feel helpless when I see something like this:
>
> - (void)tableView:(NSTableView *)aTableView
>   setObjectValue:(id)anObject
>   forTableColumn:(NSTableColumn *)aTableColumn
>              row:(int)rowIndex {
>
> 	NSString *identifier = [aTableColumn identifier];
>    data *newVar = [toDoList objectAtIndex:rowIndex];
>
>    // Set the value for the attribute named identifier
> [newVar setValue:anObject forKey:identifier];
> }
>
> All I know is that this method lets me put the content of array toDoList into the TableView. Please give me a detailed breakdown of what this is.

Objective-C method signatures have the name broken up in pieces with the parameters between them.  They're like fill-in-the-blank sentences.

The method name here is tableView:setObjectValue:forTableColumn:row:.  Each colon is a blank in the sentence to be filled in by the invoker.  It has a void return.  Its parameters are: aTableView of type NSTableView*; anObject of type id; aTableColumn of type NSTableColumn*; and rowIndex of type int.

Does that help?  Have you read Apple's introductory documentation about Objective-C and Cocoa?

Regards,
Ken

_______________________________________________

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

References: 
 >help with methods (From: Rounak Jain <email@hidden>)

  • Prev by Date: Equivalent of NSManagedObjectContextWillSaveNotification in 10.5?
  • Next by Date: Re: Sample code for "simple" sharing using Bonjour?
  • Previous by thread: help with methods
  • Next by thread: Re: help with methods
  • Index(es):
    • Date
    • Thread