discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSInteger vs. NSUInteger


From: Sebastian Reitenbach
Subject: NSInteger vs. NSUInteger
Date: Sat, 09 Feb 2013 19:11:42 +0100
User-agent: SOGoMail 2.0.4b

Hi,

when I see something like this for example in ProjectCenter:

- (NSInteger)numberOfRowsInTableView: (NSTableView *)aTableView
{
  return [docTypesItems count];
}

where docTypesItems is a NSMutableArray. I see many of the GUI elements
use NSInteger. But for example NSArray, or NSDictionary count return
NSUInteger.

When I see above statement, how is best way to proceed to not for
example return a too large NSUInteger, which would convert into
a negative NSInteger?

Since most of the time I see contents of tables, browsers and whatnot
stored in NSArrays or NSDictionaries, nearly everywhere I came across
I see this potential trouble with the signed vs. unsigned 
discrepancies when setting it up in the GUI.

Also often I see some of those results then compared, actually comparing
a NSUInteger against a NSInteger. When one is too large, or the other
negative, funny things may happen.

Is there some best practices, how to handle that? Or is there something in
the runtime, I am not aware of, that takes care about it?

Sebastian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]