Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Improve interoperability between CKRefreshControl and UIRefreshControl classes #9

Merged
merged 18 commits into from Jan 28, 2013

Conversation

johnhaitas
Copy link
Contributor

CKRefreshControl and UIRefreshControl can now be used interchangeably throughout the app.

Adds support for UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; in iOS5.

@johnhaitas
Copy link
Contributor Author

@bjhomer
Copy link
Contributor

bjhomer commented Jan 27, 2013

This looks awesome. I really wish I understood better what the inline asm is doing, but if @0xced says it works I'm inclined to believe him.

Does this provide complete support for using UIRefreshControl everywhere instead of CKRefreshControl? If there's no reason to use CKRefreshControl anymore, then maybe we should just recommend using UIRefreshControl always, and say "This is magic; just link against this library and UIRefreshControl will work on iOS 5!". We wouldn't even need to export any headers, if this is the case.

@johnhaitas
Copy link
Contributor Author

I think we should recommend people use UIRefreshControl rather than CKRefreshControl - I am going to be doing that myself. That way no refresh control code needs to be changed when iOS 5 support is dropped from an app.

{
*UIRefreshControlClassRef = objc_allocateClassPair(self, "UIRefreshControl", 0);
objc_registerClassPair(*UIRefreshControlClassRef);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For full compatibility, I think you should use objc_duplicateClass(self, "UIRefreshControl", 0); instead of objc_allocateClassPair + objc_registerClassPair since this will add an intermediate CKRefreshControl class in the hierarchy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately took this approach rather than objc_duplicateClass so we can later test if UIRefreshControl is a subclass of CKRefreshControl. This was particularly useful with the +appearance proxy.

I used objc_duplicateClass for CKParagraphStyle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I borrowed the subclassing idea from @steipete's PSTCollectionView

@bjhomer would it be ok to acknowledge @0xced and @steipete in the README.md file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no problem with that

bjhomer added a commit that referenced this pull request Jan 28, 2013
Improve interoperability between CKRefreshControl and UIRefreshControl classes
@bjhomer bjhomer merged commit ff03996 into instructure:master Jan 28, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants