iswiftapp / iswift

Objective-C to Swift Converter
30 stars 3 forks source link

self. [Attribute] #30

Closed jermowatson closed 9 years ago

jermowatson commented 9 years ago

I'm not even sure how to classify this however, I'll just provide the details and you can update the title to reflect accordingly as I honestly don't know.

When converting a TableView Function numberOfRowsInSection there seems to be an issue when assigning or configuring self attributes among array count function.

Please test with the following code.

Expected results: (PLEASE NOTE THIS IS ONLY WHAT I THOUGHT IT SHOULD BE AND MAY NOT BE CORRECT) func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { self.tabBarController.delegate = self if platesArray != nil || platesArray.count() != 0 { var selectedVC: UIViewController = self.tabBarController.viewControllers.objectAtIndex(self.tabBarController.selectedIndex) var selectedItemTag: String = selectedVC.tabBarItem.title NSLog("%@", selectedItemTag) if selectedItemTag.isEqualToString("Approach") { return approachArray.count } if selectedItemTag.isEqualToString("Airport") { return airportArray.count } if selectedItemTag.isEqualToString("Arrivals") { return arrivalArray.count } if selectedItemTag.isEqualToString("Departures") { return departureArray.count } else { return platesArray.count } } else { return 0 } }

Actual Results: func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { .delegate=self if platesArray!=nil||platesArray.count()!=0 { var selectedVC: UIViewController = .viewControllers.objectAtIndex(.selectedIndex) var selectedItemTag: String = .title NSLog("%@",selectedItemTag) if selectedItemTag.isEqualToString("Approach") { return .count;

        }
        if selectedItemTag.isEqualToString("Airport") {
            return .count;

        }
        if selectedItemTag.isEqualToString("Arrivals") {
            return .count;

        }
        if selectedItemTag.isEqualToString("Departures") {
            return .count;

        } else {
            return .count;

        }

    } else {
        return 0;

    }

}
drkameleon commented 9 years ago

Well, took me a few minutes to figure this one too - with the self being omitted. But it's a simple typo. My typo.

It has already been fixed. Tomorrow that 1.4 will be released, you'll see a fix for that included as well. :)

jermowatson commented 9 years ago

Nice! I'm slowly going through each function of mine to work out the issues. All good though.