i'm trying to understand this in objective-c :
in this example, indexPath is a pointer but we use it "as is" in the function : indexPath.section
, instead of (for example) *indexPath.section
(with a *
) :
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
return (indexPath.section == 0) ? nil : indexPath;
}
so, in objective-c, we don't need to add a *
to get the content of the variable where the pointer points to...?
but i found this function, where they use a *
on the pointer inside the function (on reverse
) :
NSInteger lastNameFirstNameSort(id person1, id person2, void *reverse)
{
NSString *name1 = [person1 valueForKey:LAST];
//...
if (*(BOOL *)reverse == YES) {
return 0 - comparison;
}
and for the id
variables, they are using the variable name as is : for example here : person1
So, could someone explain me the differences between those 2 examples :
why on the first example, we don't add a *
on indexPath,
why we don't add this *
on the id
variables, and we use it with *reverse
in the second example?
Thanks