• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UIKit and Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UIKit and Swift


  • Subject: Re: UIKit and Swift
  • From: Greg Parker <email@hidden>
  • Date: Wed, 11 Jun 2014 13:14:05 -0700

On Jun 11, 2014, at 7:29 AM, Jim Geist <email@hidden> wrote:
> On Jun 10, 2014, at 11:50 PM, Roland King <email@hidden> wrote:
>> On 11 Jun, 2014, at 2:12 pm, Kyle Sluder <email@hidden> wrote:
>>> On Jun 10, 2014, at 10:57 PM, Jim Geist <email@hidden> wrote:
>>>> Anyone know off the top of their head how to import an Obj-C extension into Swift? Specifically, I need the NSString extensions from UIKit.
>>>
>>> `import UIKit` doesn’t work? Of course, that will only work on platforms where UIKit exists (iOS device/simulator), so you can’t expect it to work in a REPL or Playground.
>>>
>>> --Kyle Sluder
>>>
>>
>> Works fine in an iOS playground. import UIKit imports UIKit and the extensions too. This code doesn't actually DO anything but it compiles and runs
>>
>> import UIKit
>>
>> var t:NSString = "bcd"
>>
>> t.sizeWithAttributes([:])
>> t.drawAtPoint( CGPoint( x:100,y:200 ), withAttributes: [:] )
>>
>> I have no idea what to put in the attributes parameter to have attributes, must be an enum or something but I have no idea what it is and the documentation isn't being helpful
>
> Ah ok, figured it out; your code gave me a hint. If you have a String, the methods that are in NSString just work on it. If you want the extensions, you have to be explicit about NSString:

Please file a bug report. NSString's methods are supposed to work on String as well.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >UIKit and Swift (From: Jim Geist <email@hidden>)
 >Re: UIKit and Swift (From: Kyle Sluder <email@hidden>)
 >Re: UIKit and Swift (From: Roland King <email@hidden>)
 >Re: UIKit and Swift (From: Jim Geist <email@hidden>)

  • Prev by Date: Re: Another app's UTI can break your app
  • Next by Date: Re: Another app's UTI can break your app
  • Previous by thread: Re: UIKit and Swift
  • Next by thread: Re: UIKit and Swift
  • Index(es):
    • Date
    • Thread