I am in doubt, why this work correctly:
NSInteger row = indexPath.row;
NSInteger preloadTrigger = self.nodes.count - 20;
if (row >= preloadTrigger) {
[self.loader loadNextposts];
}
And this does not (just skips the if-statement):
if (indexPath.row >= self.nodes.count - 20) {
[self.loader loadNextposts];
}
when the value of self.nodes.count - 20 is negative.
However, when the value of the expression is positive, it works fine always.
A very strange behavior, as I cannot see semantic difference in two expressions.
Update: So, I decided to test it:
(lldb) po self.nodes.count - 20
18446744073709551601
(lldb) po preloadTrigger
-15
According to Apple Docs, count property is a
NSUIntegerin objective-C.When you write :
In fact you are casting
countto aNSIntegerobject, and can have a negative value ifcountisn't greater than 20.But when you write :
countis aNSUIntegerobject, and subtract 20 from it will always lead to a positive number (a huge one by the way).