Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Protocol Definition of TimelineViewDelegate #7

@Obbut

Description

@Obbut

The protocol definition of TimelineViewDelegate currently looks like this:

@protocol TimelineViewDelegate <NSObject>
...
@end

Because TimelineView inherits from UIScrollView, and UIScrollView already has a property 'delegate', you require every class that is a TimelineViewDelegate to also explicitly be a UIScrollViewDelegate:

@interface TimelineView : UIScrollView
...
@property (weak, nonatomic) IBOutlet id<TimelineViewDelegate,UIScrollViewDelegate>delegate;
...
@end

However, if you would let the TimelineViewDelegate protocol inherit from UIScrollViewDelegate, you could overcome this 'issue', and thus requiring less unneccessary code.

If we change the protocol definition to this:

@protocol TimelineViewDelegate <NSObject, UIScrollViewDelegate>

And make this change in TimelineView.h:

@property (weak, nonatomic) IBOutlet id<TimelineViewDelegate,UIScrollViewDelegate>delegate;

In your sample code, the delegate and dataSource are set via interface builder, which is why no warning is given when compiling the sample project -- even though ViewController does not conform to the UIScrollViewDelegate protocol. When setting the data source and/or the delegate programmatically, however, a compile warning is given.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions