• Register
Log In
0 votes

Problem :

I am trying to present the view controller as the pop over if the user successfully resets their password. Basically, if all is ok with emailing the password reset instruction email then the below code will run. But I am facing below error

Implicit user of 'self' in closure; use '.self' to make capture semantics explicit

On the very first line as shown below:

let MYVC = storyboard?.instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as! ResetPasswordSuccessPopOverViewController

MYVC.preferredContentSize = CGSize(width: UIScreen.mainScreen().bounds.width, height: 100)

let mynavController = UINavigationController(rootViewController: MYVC)

mynavController.modalPresentationStyle = UIModalPresentationStyle.Popover

let mypopover = mynavController.popoverPresentationController

popover?.delegate = self

self.presentViewController(mynavController, animated: true, completion: nil)

7.5k points

1 Answer

0 votes

Solution :

I have read your problem. I have understood your problem completely as I had also faced similar problem in recent past. I had done research on it and found out solution on it.

To resolve your problem please try below solutions :

let myviewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as ResetPasswordSuccessPopOverViewController


 let myviewController = self.storyboard!.instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as ResetPasswordSuccessPopOverViewController


In Swift the semantics of the self reference being captured are not allowed to be explicit, So  referring to any member of the object inside the closure requires you to show the full commitment to the capturing with self. being explicitly added to the referenced identifiers.

let MYVC = self.storyboard?.instantiateViewControllerWithIdentifier("ResetPasswordSuccessPopOver") as! ResetPasswordSuccessPopOverViewController

Please Note self. before storyboard?..

36.1k points

Related questions

0 votes
1 answer 319 views
Problem : Facing following Swift issue must register a nib or a class for the identifier or connect a prototype cell in a storyboard
asked Nov 15, 2019 peterlaw 6.9k points
1 vote
1 answer 31 views
Problem : I am very new to Swift. Now I have started learning Swift. Recently I have written very simple class as shown below for your reference: public class SwiftUser {     let userid: Int     let userfirstName: String     let userlastName: String     ... Return from initializer without initializing all stored properties . Now I am very confused. Please help me in resolving above Swift error.
asked May 12 Martin K 6.6k points
0 votes
1 answer 284 views
Problem : I got an error on Xcode saying that there was no information about the view controller as follows: Could not insert new outlet connection: Could not find any information for the class named Why am I getting this error?
asked Nov 28, 2019 alecxe 7.5k points
0 votes
1 answer 44 views
Problem : I am getting bellow error if we're in the real pre-commit handler we can't actually add any new fences due to ca restriction
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
2 answers 215 views
Problem : I am trying to do some practice on the broom package in R. I ran the below code : kclusts <- data.frame(k=1:9) %>% group_by(k) %>% do(fit=kmeans(data.frame, .$k)) But I have received the below error: Error in as.vector(x, mode) : ... type 'any' I wanted to know whether I am missing something in my above string. Does anyone have the solution on this issue which I am facing currently?
asked Dec 21, 2019 alecxe 7.5k points