I am converting mine whole project from Objective-C to Swift... while converting i am getting this issue as "Cannot convert value of type 'Facility' to expected argument type "Facility!"
The Error is in the last converted file code i have mentioned, that is mentioned in comment.
"Cannot convert “Facility” to expected argument type “Facility!"
The code is:
TheFacility.h File:
#import <Foundation/Foundation.h>
@interface FacilityDataModel : NSObject
- (BOOL)save:(Facility *)facility;
@end
TheFacility.m File:
#import "FacilityDataModel.h"
@implementation Facility
… // many other methods...
- (void)save
{
FacilityDataModel *facilityDataModel = [[FacilityDataModel alloc] init];
[facilityDataModel save:self];
}
… // many other methods...
@end
TheFacilityDataModel.m File is having method:
-(BOOL) save: (Facility *) facility
{
if ([facility m_ID] == nil)
{
NSLog(@“Saving Facility Code”);
return true;
}
return false;
}
Now the Converted "Facility.swift" file to swift is:
import Foundation
class Facility: NSObject {
…
func save() {
let facilityDataModel = FacilityDataModel()
facilityDataModel.save(self) ///Its showing dialog “Cannot convert “Facility” to expected argument type “Facility!”
}
…
}
Note: Please reply with a solution that will not force me to change Objective-C code as i want to have both swift and Objective-C code work together in mine project and cant change that Objective-C code.
I am not converting the DataModel classes to swift as for now... so i have to use this existing Objective-C DataModel class in swift... and that is imported in header file as well... rest all settings are also taken care of and are fine... no other issues except this...