I had a piece of code that was working on Swift 2.X version, but, after update the code and syntax to Swift 3.0 it is working on a strange way.
I have the following structure wrote on Objective-C:
Class A:
@interface A : NSObject
{
// some properties
}
Class Expense:
@interface Expense : A {
@property (strong, nonatomic) NSString* Description;
}
On Swift 2.X I had the following code:
if let expense = DataManager.sharedDataManager().expenseForExpenseId(id) {
var description = expense.Description
}
When I updated to Swift 3.0 the code was changed to:
if let expense = DataManager.shared().expense(forExpenseId: id) {
// expense is a variable from the Expense class
var description = expense.description
}
The problem that I am facing is that when I use expense.description
I'm getting the value for the description (lowerCamelCase) property from the NSObject class (parent of parent class) instead of the value for the Description (UpperCamelCase) property from the Expense Class. I had to change the expenseType.Description to expenseType.description because of the new syntax on Swift 3.0
I have a workaround to fix it, create a get method on the Expense Class and call it from Swift 3.0:
@interface Expense : A {
@property (strong, nonatomic) NSString* Description;
-(NSString*) getDescription(){
return Description;
}
}
Is this a known problem? Do you know a better solution for this problem?