nathantannar4 / InputBarAccessoryView

A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments
MIT License
1.14k stars 228 forks source link

Why AttachmentManager extensions methods are 'finals'? #258

Open Coriolan-Bataille opened 3 months ago

Coriolan-Bataille commented 3 months ago

Was running version '5.4.0' via cocoapods, so could edit cellForItemAt to 'open' instead of 'final' Now running '6.3.0' via SPM and can't to this edit anymore.

I'm overriding cellForItemAt, but can't anymore. I would like to understand the reason behind it.

import UIKit
import InputBarAccessoryView

class CustomAttachmentManager: AttachmentManager {

    override var tintColor : UIColor {
        return .black
    }

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        if indexPath.row == attachments.count && showAddAttachmentCell {
            return createCustomAttachmentCell(in: collectionView, at: indexPath)
        }
        //[...]
    }

   //[...]
}

Xcode error:

Instance method overrides a 'final' instance method
Overriding non-open instance method outside of its defining module

I believe in older versions of InputBarAccessoryView, AttachmentManager extension were not in final if my memory is correct.

Thank you for the time spend reading my questions, and thx for sharing with us that great project. Best Regards Cory.

Kaspik commented 3 months ago

This has been done more than 6 years ago, so it's not a recent change - https://github.com/nathantannar4/InputBarAccessoryView/commit/23e65c2834c899ba670400c5218c1ce73b38691c

I believe you have to conform to the delegate methods itself, not just override the conformance from superclass. Try adding extension CustomAttachmentManager: UICollectionViewDelegateFlowLayout { to your code and handling all the code in collection view by yourself?

Coriolan-Bataille commented 3 months ago

That was a lighting fast answer. Thank you for the suggestion. I will explore that direction. (And yes using it since a very long time haha so I was a bit outdated) 🤭