<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Swift imports&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSUInteger</span>&nbsp;in Objective-C APIs as&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span>, but only for Frameworks like Foundation and AppKit. For other code,&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSUInteger</span>&nbsp;is imported simply as&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">UInt</span>. Is there some way to get those as&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span>&nbsp;in Swift for my Objective-C code, too? Maybe some macro in the spirit of&nbsp;<span style="color: rgb(120, 73, 42); font-family: Menlo; font-size: 11px;" class="">NS_REFINED_FOR_SWIFT</span>,&nbsp;<span style="color: rgb(120, 73, 42); font-family: Menlo; font-size: 11px;" class="">NS_SWIFT_NAME</span>, and&nbsp;<span style="color: rgb(120, 73, 42); font-family: Menlo; font-size: 11px;" class="">NS_SWIFT_NOTHROW</span>? Or probably rather something that gets applied to each parameter or return type? I didn’t find anything like that.<div class=""><div class=""><div class=""><br class=""></div><div class="">For example, I have an&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSSegmentedCell</span>&nbsp;subclass that has the following methods:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class="">- (<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">void</span>)setRepresentedObject:(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nullable</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">id</span>)anObject forSegment:(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSUInteger</span>)segment;</div><div style="margin: 0px; line-height: normal;" class="">- (<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nullable</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">id</span>)representedObjectForSegment:(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSUInteger</span>)segment;</div></div></div><div class=""><br class=""></div><div class="">… which come through to Swift as:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> setRepresentedObject(anObject: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>?, forSegment segment: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UInt</span>)</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> representedObjectForSegment(segment: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UInt</span>) -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">AnyObject</span>?</div></div></div><div class=""><br class=""></div><div class="">Note the&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">UInt</span>&nbsp;instead of&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span>. This isn’t very nice because all of the&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSSegmentedCell</span>&nbsp;methods use&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span>. Also, writing code involving these methods and indices extracted from an Array isn’t nice because it requires constant conversions between&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">UInt</span>&nbsp;and&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span>.</div></div></div><div class=""><br class=""></div><div class="">A nice solution would be to have something that allows selectively annotating these parameter and return types to tell the Clang Importer how to import types like&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSUInteger</span>&nbsp;to Swift. I guess Frameworks like Foundation and AppKit use something like that internally to opt-in or opt-out of this conversion.</div><div class="">Is there something like that I can use? Am I missing something?</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Marco</div></body></html>