[swift-evolution] Proposal seed: gathering data to fix the NSUInteger inconsistency
freakshow42 at mac.com
Wed Feb 1 23:07:21 CST 2017
I have a framework I wrote that maps Objective C objects to sqlite records - deriving sqlite schema definitions from property definitions. You simply derive model classes from my base class Model and the base class will introspect the properties and handle all the sql for you. A little like CoreData but the property definitions are used for the meta model instead of an external model file and it is a lot leaner and natural feeling.
I picked NSUInteger for the auto incremented primary key because, after all, it would never go negative.
However, when I tried to import this framework into Swift and use Model as a base class for a Swift class, I found it nearly impossible to satisfy the compiler about mixed mode comparisons and ultimately changed the type to NSInteger.
I was not happy about it and if I wasn't the framework author I would have thought harder about changing it.
> On Feb 1, 2017, at 17:29, Jordan Rose via swift-evolution <swift-evolution at swift.org> wrote:
> find out how Objective-C projects are using NSUInteger in their headers:
> - Do they have no NSUIntegers at all?
> - Are they using NSUInteger because they’re overriding something that used NSUInteger, or implementing a protocol method that used NSUInteger?
> - Are they using NSUInteger as an opaque value, where comparisons and arithmetic are uninteresting?
> - Are they using NSUInteger as an index or count of something held in memory?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution