vicpenap / PrettyKit

PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization. You will be able to change their background color, add gradients, shadows, etc.
http://vicpenap.github.com/PrettyKit
Other
1.22k stars 155 forks source link

Prefix category methods to avoid potential namespace collisions #36

Closed nikmacintosh closed 5 years ago

nikmacintosh commented 11 years ago

Using PrettyKit alongside SSToolkit results in a naming collision between publicly visible categories on UIColor. [UIColor colorWithHex:] in PrettyKit expects an int as a parameter, whereas SSToolkit expects an NSString. Since both PrettyKit and SSToolkit are popular, it's reasonable to assume more will encounter this incompatibility. This pull request prefixes category methods in PrettyKit with pretty_, avoiding future namespace collisions.

vicpenap commented 11 years ago

Thanks @knickmack. However I cannot merge the changes like they are, as they break the API compatibility.

I don't know how we can solve that, actually. The idea would be making new methods with that prefix in the signature, but leaving the old ones there as well deprecating them. So the change wouldn't fix the collision with SSToolkit in the next release; it only would make developers to update their code for a future release without those methods.

nikmacintosh commented 11 years ago

I've added in deprecation warnings and documentation, if you'd like to pull that in.

dakotahp commented 11 years ago

+1 I'd like to cast my vote to look into finding a reasonable solution since I ran into this issue too. I can hack it in the meantime with @knickmack's commits but that's not a long-term solution.

vincenthawk commented 11 years ago

Hi, Is it possible that using the PrettyKit to display images? Is there any sample code? Screenshot_2013-01-11-18-21-32 iOS Simulator Screen shot 2013 1 14 6 39 00

nikmacintosh commented 11 years ago

One very hacky solution to, at least, the API incompatibility between SSToolkit and PrettyKit, is to cast a hex string passed to [UIColor colorWithHex:] as an int, seemingly satisfying both APIs, and having the intended result.

Example: _viewController.view.backgroundColor = [UIColor colorWithHex:(int)@"0x0000FF"];

The above will not crash, and show the intended blue.