07-18-2023, 03:54 PM
I am new to iOS development and have started directly with Swift.
When I want to add a new file to a project, the IDE presents me with two files which seem to be used interchangeably in the tutorials that I have seen so far.
They are "Cocoa Touch Class" and "Swift Class".
When I create a new Cocoa Touch Class, this is what I get(depending on the class inherited)
import UIKit
class CtTest: NSObject {
}
and when I create a new Swift file, I get this:-
import Foundation
The extension for both of these classes is .swift
If I add the class definition to the Swift file and modify it as follows:-
import UIKit
import Foundation
class SwTest:NSObject
{
}
is there any difference that remains between the two files.
If so, which classes are preferred in what scenarios eg. View Controllers, Models etc.
Thank You
When I want to add a new file to a project, the IDE presents me with two files which seem to be used interchangeably in the tutorials that I have seen so far.
They are "Cocoa Touch Class" and "Swift Class".
When I create a new Cocoa Touch Class, this is what I get(depending on the class inherited)
import UIKit
class CtTest: NSObject {
}
and when I create a new Swift file, I get this:-
import Foundation
The extension for both of these classes is .swift
If I add the class definition to the Swift file and modify it as follows:-
import UIKit
import Foundation
class SwTest:NSObject
{
}
is there any difference that remains between the two files.
If so, which classes are preferred in what scenarios eg. View Controllers, Models etc.
Thank You