• 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: Rounak Jain <email@hidden>
  • Date: Thu, 29 Jul 2010 09:56:56 +0530





On Jul 29, 2010, at 4:17 AM, Ken Thomases wrote:

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

(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


Thanks Ken.
Ok, i see that the method signature above is one with multiple parameters like this one in the ObjC documentation:
[myRectangle setOriginX: 30.0 y: 50.0];


Now that I have understood this, I feel that the following statements are unnecessary when I am having only one column in my application:

NSString *identifier = [aTableColumn identifier];

  // Set the value for the attribute named identifier
[newVar setValue:anObject forKey:identifier];

Merely,

[toDoList objectAtIndex:rowIndex];

is enough for my needs.

But I don't understand what

[toDoList objectAtIndex:rowIndex];

means.

(toDoList is my array containing strings)



And does it have anything to do with:
- (id)tableView:(NSTableView *) tv
objectValueForTableColumn:(NSTableColumn *)tableColumn
			row:(int)row
{
    NSString *v = [toDoList objectAtIndex:row];
    return v;
}

_______________________________________________

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: help with methods
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Storing help pages on Remote Server
  • Next by Date: Re: redraw problem
  • Previous by thread: Re: help with methods
  • Next by thread: Re: help with methods
  • Index(es):
    • Date
    • Thread