ayushn21 / AvatarImageView

DEPRECATED!!! --- Use https://github.com/neone/NDAvatarApp
MIT License
255 stars 37 forks source link

EXC_BAD_Access #13

Closed QuentinDela closed 8 years ago

QuentinDela commented 8 years ago

Hi, Thanks a lot for pod! I am trying to implement it into my app but I am running into an issue. I'm trying to add it in a cell of my table view controller. I am using swift 2.2 and the pod "AvatarImageView", '1.1.1'

Here is my table_cell file

`import UIKit import AvatarImageView

struct TableAvatarImageConfig: AvatarImageViewConfiguration { static let shape: Shape? = .Circle }

class ContactPageTableViewCell: UITableViewCell {

// - // MARK: - When Cell Loads
override func awakeFromNib() {
    super.awakeFromNib()
}

override func setSelected(selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

@IBOutlet weak var ContactPageImageView: AvatarImageView! {
    didSet {
        ContactPageImageView.configuration = TableAvatarImageConfig()
    }
}

@IBOutlet weak var ContactPageNameLabel: UILabel!
@IBOutlet weak var ContactPageNicknameLabel: UILabel!
@IBOutlet weak var ContactPagePhoneNumberLabel: UILabel!

} I have an error or the line ContactPageImageView.configuration = TableAvatarImageConfig()` EXC_BAD_ACESS (code=2, adress=0x7f9f74d3d1b0)

Any ideas of what I'm doing wrong?

Thanks

ayushn21 commented 8 years ago

Hi @QuentinDela,

Thanks for the detailed issue.

Unfortunately I haven't been able to reproduce the issue you're having. The code seems pretty similar to what I have in my example project. Is it at all possible for you to extract your Table View Controller and related code into a separate Xcode project and attach that here so I can debug it?

On a side note, Swift naming convention states that your property names should start with a lower case letter. Only classes/structs and other types should start with a capital letter. It might be confusing for other Swift developers when they look at your code.

Also your TableAvatarImageConfig should be as follows:

struct TableAvatarImageConfig: AvatarImageViewConfiguration {
    let shape: Shape = .Circle
}

A static member does not meet the requirements of the protocol so the shape will still be square.

Neither of these things is causing the issue you're having though which is why I'd appreciate if you could extract your code into a sample project!

Cheers, Ayush

QuentinDela commented 8 years ago

Hello Ayush,

Thanks for your quick reply. I am not sure how to extract my code into a sample project. Here is a gist with the TableViewCell and the TableViewController. https://gist.github.com/QuentinDela/5fc069aec9b7289107017e77fb9286d0

Thanks a lot for your help.

ayushn21 commented 8 years ago

Thanks for the gist. I've copied your code (minus the Realm stuff) into an example project and it works just fine for me. Please see the attached project.

The exception you are getting is memory related. It happens when you try to call a method on something that has already bee deallocated. Unfortunately without being able to reproduce and debug this issue, I won't be able to help much :(. Could you please try and reproduce the issue in the sample project I have just attached? If you are able to do it, please re-attach your version in another comment and I will debug and investigate what is going wrong.

TestProject.zip

ayushn21 commented 8 years ago

Closing due to inactivity ...

dannysood commented 7 years ago

@QuentinDela @ayushn21 Old issue but I was facing the same thing. Turns out the fix was pretty simple. I had only set the UIImage class to AvatarImageView and not the module to the same. By default it sets itself to no module when the class is set to AvatarImageView. I hope this helps someone in future.

Amazing library though.