ios - Evaluation (NSIntegers) inside if-statement Objective-C -


i in doubt, why work correctly:

nsinteger row = indexpath.row; nsinteger preloadtrigger = self.nodes.count - 20; if (row >= preloadtrigger) {     [self.loader loadnextposts]; } 

and not (just skips if-statement):

if (indexpath.row >= self.nodes.count - 20) {     [self.loader loadnextposts]; } 

when value of self.nodes.count - 20 negative.

however, when value of expression positive, works fine always.

a strange behavior, cannot see semantic difference in 2 expressions.

update: so, decided test it:

(lldb) po self.nodes.count - 20 18446744073709551601  (lldb) po preloadtrigger -15 

according apple docs, count property nsuintegerin objective-c.

when write :

 nsinteger preloadtrigger = self.nodes.count - 20; 

in fact casting count nsinteger object, , can have negative value if count isn't greater 20.

but when write :

(indexpath.row >= self.nodes.count - 20) 

count nsuinteger object, , subtract 20 lead positive number (a huge 1 way).


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -