• 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: Passing a swift function to objective-c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing a swift function to objective-c


  • Subject: Re: Passing a swift function to objective-c
  • From: Kevin Meaney <email@hidden>
  • Date: Sat, 18 Oct 2014 18:18:10 +0100

Hi Roland,

Thanks for the followup. I've created a proper git rep on github rather than just a gist. Most of my github reps seem to be this kind of mini demonstration project and I was trying to avoid yet another one.

https://github.com/SheffieldKevin/swift-objectivec

> What version of Xcode are you using by the way, Swift is so flux-y at the moment it probably makes a difference.

I'm now running release Yosemite and release Xcode 6.1. That appears to me to make no difference.

I still can't assign to the optional property of my protocol.

You can ignore the ImageProvider2 class, I've just included it for completeness. It doesn't have a protocol and just declares the property itself.

So with my protocol I've done something similar to what you did if I've interpreted your discussion correctly. I've got two properties, one that is required and one that is optional.

Everything works fine for the required property. But I still can't get the optional one to work.

In ImageProvider.m you'll see that the MakeImageProvider function assigns a block to the optional property and in SupplyCreateImage.swift I've commented out the assignment. I've provided the example this way so that it can be seen that it works when done using objective-c. But if you comment out the assignment to the optional property of the block, and uncomment the line in the swift file you'll see that the command line tool no longer compiles.

Like you I've tried the use of the optional and playing around with casting but I've not actually got the code to compile this way.

Kevin


_______________________________________________

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


  • Follow-Ups:
    • Re: Passing a swift function to objective-c
      • From: Kevin Meaney <email@hidden>
References: 
 >Passing a swift function to objective-c (From: Kevin Meaney <email@hidden>)
 >Re: Passing a swift function to objective-c (From: Roland King <email@hidden>)
 >Re: Passing a swift function to objective-c (From: Kevin Meaney <email@hidden>)
 >Re: Passing a swift function to objective-c (From: Roland King <email@hidden>)

  • Prev by Date: Re: Document style programming
  • Next by Date: Re: Document style programming
  • Previous by thread: Re: Passing a swift function to objective-c
  • Next by thread: Re: Passing a swift function to objective-c
  • Index(es):
    • Date
    • Thread