path / FastImageCache

iOS library for quickly displaying images while scrolling
MIT License
8.11k stars 935 forks source link

Objective-C provided getter does not match requirement's selector #143

Open santanu4ver opened 7 years ago

santanu4ver commented 7 years ago

I'm having trouble converting my old source to Swift 3.0 in following area. I've this following usage which was working prior to the version 3.

    extension NewManPhoto: FICEntity
    {
        internal var UUID: String!
        {
            if _UUID == nil
            {
                // MD5 hashing is expensive enough that we only want to do it once
                let imageName: String = sourceImageURL.lastPathComponent
                let UUIDBytes: CFUUIDBytes = FICUUIDBytesFromMD5HashOfString(imageName)
                _UUID = FICStringWithUUIDBytes(UUIDBytes)
            }

            return _UUID;
        }
    }

New XCode starts giving me following error: 'UUID' has been renamed to 'uuid'

But when I looked inside the FICEntity file I noticed it had 'UUID' only: *@property (nonatomic, copy, readonly) NSString UUID;**

Anyway, after accepting Xcode's auto-fix suggestion it became small-case, but pops another error: Objective-C method 'uuid' provided by getter for 'uuid' does not match the requirement's selector ('UUID')

The code became something like this:

    internal var uuid: String!
        @objc(UUID) {

But beside it fixed, XCode erupt same error again to the line Objective-C method 'uuid' provided by getter for 'uuid' does not match the requirement's selector ('UUID') and the problem continues until the source became looks ugly and non-fixable.

Can you help how to resolve this situation?

santanu4ver commented 7 years ago

I'm not sure if this the right way to overcome the said problem, but following syntax seems accepted by XCode; can you give your suggestion if this should work (I yet to fix other errors so unable to run the app at this moment to test):

@objc(UUID) internal var uuid: String!
    {
        if _UUID == nil
        {
            // MD5 hashing is expensive enough that we only want to do it once
            let imageName: String = sourceImageURL.lastPathComponent
            let UUIDBytes: CFUUIDBytes = FICUUIDBytesFromMD5HashOfString(imageName)
            _UUID = FICStringWithUUIDBytes(UUIDBytes)
        }

        return _UUID;
    }