<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 <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSUInteger</span> in Objective-C APIs as <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, <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSUInteger</span> is imported simply as <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">UInt</span>. Is there some way to get those as <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span> in Swift for my Objective-C code, too? Maybe some macro in the spirit of <span style="color: rgb(120, 73, 42); font-family: Menlo; font-size: 11px;" class="">NS_REFINED_FOR_SWIFT</span>, <span style="color: rgb(120, 73, 42); font-family: Menlo; font-size: 11px;" class="">NS_SWIFT_NAME</span>, and <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 <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSSegmentedCell</span> 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>) -> <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 <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">UInt</span> instead of <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 <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSSegmentedCell</span> methods use <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 <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">UInt</span> and <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 <span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">NSUInteger</span> 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>