• Register
0 votes
532 views

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)

6 5 3
7,540 points

Please log in or register to answer this question.

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

OR

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

OR

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?..

9 7 4
38,600 points

Related questions

0 votes
1 answer 701 views
701 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
0 votes
1 answer 166 views
166 views
Problem: I am trying to archive my project but facing very unexpected error as shown below: Showing Recent Messages:-1: mkdir -p /Users/spritzindia/Library/Developer/Xcode/DerivedData/Contigo-atftiouzrdopcmcpprphpilawwzm/Build/Products/Debug-iphonesimulator/Contigo.app/Frameworks Showing ... : pod 'IQKeyboardManagerSwift'  pod 'SDWebImage', '~> 4.0'  pod 'KRPullLoader'  pod 'Paytm-Payments'
asked Aug 25, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 398 views
398 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, 2020 Martin K 6.6k points
0 votes
1 answer 644 views
644 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 17 views
17 views asked Oct 2, 2020 SapperIt 1.2k points
1 vote
1 answer 83 views
83 views
Problem : I am using Swift from some time. It was very useful for beginner like me to get a substring from String with the use of the characters property but now I came to know that it has been deprecated and now Xcode suggests to use the substring. I have already tried ... error from couple of days and in this process I have already wasted a lot of time. Now I need expert help to fix the issue.
asked Apr 10, 2020 morrisBson 3.2k points
0 votes
1 answer 13 views
13 views asked Oct 2, 2020 SapperIt 1.2k points
0 votes
1 answer 16 views
0 votes
1 answer 10 views
10 views
I do my best to get the concept of why struct vs. class doesn’t bring up the same results. Why is the result the same here but different on structs: import UIKit class Message { var internalText: String = "This is some text" } // create new instance var ... a new object from the old object? Then I would have to declare secondMessage = Message() to make it a new instance. Thanks in advance.
asked Sep 15, 2020 Marivoke 530 points
0 votes
1 answer 12 views