My question is: How to set NSIndexPath programmatically.
For example I add method:
- (void)setDefaultValue{
tempIndexPath = [NSIndexPath indexPathForRow:0 inSection:1];
}
In tableView delegate -cellForRowAtIndexPath I want to compare two indexPath
if([indexPath isEqual:tempIndexPath]) ...
But in this case my tempIndexPath = null (i think - because this is autorelease object)
How to set NSIndexPath in this case?
Thanks, All!
Add retain
- (void)setDefaultValue{
tempIndexPath = [[NSIndexPath indexPathForRow:0 inSection:1] retain];
}
But you have to be aware of release temIndexPath in the future.
EDIT:I deleted bad option.
Simply call retain
after you instantiated it:
[tempIndexPath retain];
This will make you the owner of the object, so remember to release
it when you have done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With