MyAnimals* animal = ... <- bad
MyAnimal *animal = ... <- good
[_animalsArray objectAtIndex:indexPath.row] <- bad
self.animalsArray[indexPath.row] <- good
[[_animalsArray objectAtIndex:indexPath.row] photo] != NULL ? ... : ... <- bad
self.animalsArray[indexPath.row].photo != nil ? ... : .... <- good
self.animalsArray[indexPath.row].photo ? ... : .... <- better
Избыточно:
cell.textLabel.text = [[_animalsArray objectAtIndex:indexPath.row] name];
cell.textLabel.text = [NSString stringWithFormat:@"%@",animal.name];
Достаточно:
cell.textLabel.text = animal.name;
Где-то у вас:
@property (nonatomic) NSArray *animalsArray; <- bad
@property (nonatomic) NSArray *animals; <- good
@property (nonatomic) NSArray<MyAnimal *> *animals; <- better
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
cell.selectionStyle = indexPath.row == 1 ? .default : .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard indexPath.row == 1 else { return }
let vc = UIViewController()
navigationController?.pushViewController(vc, animated: true)
}
func handleSearch() {
navigationController?.pushViewController(AlfavitController(with: Magic), animated: true)
}
struct Row {
let title: String
let generator: (Parameters) -> UIViewController
}
let section: [Row] = [
Row(title: "first", generator: { (parameters) -> UIViewController in
return FirstViewController()
}),
Row(title: "second", generator: { (parameters) -> UIViewController in
return SecondViewController()
})
]
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let row = section[indexPath.row]
let vc = row.generator(Parameters)
navigationController?.pushViewController(vc, animated: true)
}
если
_counter = [[_myArray count] intValue];
то bad receiver type nsuinteger aka int
self.counter = (int)[self.myArray count];
@property (nonatomic) NSUInteger counter;
let vc = MyViewController()
let vc = MyViewController(dependency1: Dependency1, dependency2: Dependency2, ...)
let settings = MyViewController.Settings(<here init>)
let vc = MyViewController(with: settings)