Reputation: 81
I just have a Objective-C project and I want to use AppDelegate to access to my xcdatamodel, but when I add AppDelegate.swift
to my project it show me a compile problem, it is error because it doesn't know what AppDelegate use and what is the main. Then I tried to delete AppDelegate.h
and AppDelegate.m
and add AppDelegate.swift
, but it also doesn't work and still has compile errors.
How I can add AppDelegate.swift
to it?
Upvotes: 5
Views: 3172
Reputation: 63
Teo is correct. To solve the main.m file compile problem add @UIApplicationMain above the class declaration
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
Upvotes: 2
Reputation: 3442
If you want to use AppDelegate.swift
instead of AppDelegate.h
/ AppDelegate.m
, you should add the Swift file to your project and delete the .h
and .m
files (don't forget to click yes when asked about the bridging header). In addition, you should also delete main.m
since it is not needed anymore and will cause a linker error.
Upvotes: 5
Reputation: 9586
I recommend you to create a new Xcode project with Swift as default and check out the AppDelegate code in that one and copy/adapt it over to your project.
Upvotes: 1