Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

weird swift error after upgrading from 1.1 to 1.2

My project prior to the update was working fine with swift 1.1 and Xcode 6.1.1. i just upgraded to swift 1.2 and get a weird error in my AppDelegate

 func application(application:UIApplication, didReceiveRemoteNotification userInfo:NSDictionary)

and also in a class derived from UITextFieldDelegate

func textFieldDidBeginEditing(textField: UITextField!) -> Bool // called textfield for locationField clicked

saying something along the lines

Objective-C method 'application:didReceiveRemoteNotification:' provided by method 'application(:didReceiveRemoteNotification:)' conflicts with optional requirement method 'application(:didReceiveRemoteNotification:)' in protocol 'UIApplicationDelegate'

the error for the textFieldDidBeginEditing is the same:

Objective-C method 'textFieldDidBeginEditing:' provided by method 'textFieldDidBeginEditing' conflicts with optional requirement method 'textFieldDidBeginEditing' in protocol 'UITextFieldDelegate'

What is the issue?

like image 462
Alex Avatar asked Jan 29 '26 03:01

Alex


2 Answers

Just rewrite the method's name (should fix itself), and copy/paste the code in the methods. This should work.

like image 78
Dejan Skledar Avatar answered Jan 30 '26 19:01

Dejan Skledar


This worked for me:

Before:

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool

After:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool!
like image 26
tStriss Avatar answered Jan 30 '26 18:01

tStriss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!