I am using ARC and want to create a method that passes in an indexPath by reference so I can change its value:
-(void)configureIndexPaths:(__bridge NSIndexPath**)indexPath anotherIndexPath:(__bridge NSIndexPath**)anotherIndexPath
{
indexPath = [NSIndexPath indexPathForRow:*indexPath.row + 1 inSection:0];
anotherIndexPath = [NSIndexPath indexPathForRow:*anotherIndexPath.row + 1 inSection:0];
}
But this gives me a property row not found error. How can I address this.
And another conceptual question: if my my goal is just to change the value of indexPath that was passed in to the method, couldn’t passing by pointer also do that? Why would I choose to pass by reference rather than pass by pointer?
This is how you would do this:
You should use
__autoreleasing, so that the objects are properly autoreleased when they are created, as well as checking for aNULLpointer being passed in. If you want a truepass-by-reference, look into objc++ and aNSIndexPath *&.