• 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: Stuck in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stuck in Swift


  • Subject: Re: Stuck in Swift
  • From: Muhammad Hussein Nasrollahpour <email@hidden>
  • Date: Thu, 14 Aug 2014 00:45:08 -0700

The problem is with your calling convention in specified line. Notice that when you call a method which is part of a class you should write the parameter name and then value.

class AppDelegate: NSObject
{
	var statusString : String?

	// 1. let someThing = SomeClass(myStatusHandler)
	let someThing = SomeClass(statusHandler: myStatusHandler)

	func myStatusHandler(s: String)
	{
		statusString = s
	}
}

class SomeClass
{
	var statusHandler:  (String) -> Void

	init( statusHandler: (String) -> Void)
	{
		self.statusHandler = statusHandler
	}
}

Now it does compile.

— Muhammad

_______________________________________________

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: Stuck in Swift
      • From: "Gerriet M. Denkmann" <email@hidden>
  • Prev by Date: Abandoning NSDocument for an app
  • Next by Date: Re: Stuck in Swift
  • Previous by thread: Re: Stuck in Swift
  • Next by thread: Re: Stuck in Swift
  • Index(es):
    • Date
    • Thread