Share

engineering

4min read

Top 5 Polidea's Pods

Top 5 Polidea's Pods

At Polidea, we are not only using external libraries and frameworks. We contribute to the open-source community too. Here is our recent top 5 iOS libraries project tested and ready to use. Please help yourself!

PLXImageManager

This is a highly performant image manager for iOS. It offers downloading, caching, cancelling in a very flexible and easy-to-use manner. You can read more about it in our dedicated article.

How to use it? Firstly, you need to create necessary objects:

PLXURLImageProvider *provider = [PLXURLImageProvider new];

PLXImageManager *manager = [[PLXImageManager alloc] initWithProvider:provider];

Then, simply get the image you want:

PLXImageManagerRequestToken *token = nil;
// get token

token = [manager imageForIdentifier:@"http://placehold.it/350/00aa00/ffffff"
	placeholder:[UIImage imageNamed:@"placeholder"
	callback:^(UIImage *image, BOOL isPlaceholder) {

		// consume the image here

	}];
// cancel the download
[token cancel];

Read more on GitHub here.

PLXObservers

This tiny library solves in an elegant way the problem of having many observers for the same protocol (a sort of multi delegate pattern).

One-liner setup:

PLXObservers <ObserverProtocol> *observers = (PLXObservers <ObserverProtocol> *)[[PLXObservers alloc] initWithObserverProtocol:@protocol(ObserverProtocol)];


From now on, when any amount of observers is registered, like this: [observers addObserver:myObserver1] It is possible to call a protocol method on observers instance just like if it was a single delegate object, and PLXObservers will pass the invocation to all registered observers.

Simple, elegant and IDE friendly. Read more on GitHub here.

PLXColors

It was created to solve one problem: instantiating UIColor object with hex coded color given in string or integer (eg. #e3e3e3 or 0xe3e3e3).

Full API working on both iOS and OS X:

+ (PLColor *)colorWithHexString:(NSString *)hexString;
+ (PLColor *)colorWithHexStringWithAlpha:(NSString *)hexString;
+ (PLColor *)colorWithHexInteger:(NSUInteger)value;
+ (PLColor *)colorWithHexIntegerWithAlpha:(NSUInteger)value;

Read more on GitHub here.

PLXVisualAttributeConstraints

The main goal of this pod is to make writing AutoLayout visual constraints format easier and more talkative. Thanks to this pod, the following method will not longer be necessary: +constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:

The below example shows how cool and useful it can be:

NSArray *constraints = [NSLayoutConstraint attributeConstraintsWithVisualFormatsArray:@[

		@"secondView.left <= firstView.left - 10",

		@"secondView.right >= firstView.right + 10",

		@"secondView.top == firstView.bottom * 2.5 + 5",

	] views:views];


All constraints are easy to read, grouped in one place, clearly related to each other. There is much more to read on GitHub here.

PLXFrameLayout

This is a declarative approach to writing layout while using frames, but without a single CGRect needed. It is not support for AutoLayout. All related code has to be put in layoutSubviews method.

Why would anyone like to use it? There are three good reasons: 1. If you are tired of AutoLayout bugs 2. If you have the need to increase performance (which AutoLayout lacks cruelly) 3. If you use AutoLayout, you might want to layout some views without using it or add additional layouting code.

Simple example:

- (void)layoutSubviews {
	[super layoutSubviews];
	[self plx_sizeToFitSubviews];

	[self.titleLabel plx_centerInSuperView];
	[self.captionLabel plx_placeUnderAligningToLeft:self.titleLabel withMargin:10.f];
	[self.otherView plx_placeOnRightOf:self.titleLabel withMargin:10.f];
	[self.otherView plx_expandToSuperViewEdge:NSLayoutAttributeRight withInset:10.f];
	[self.otherView plx_alignToAttribute:NSLayoutAttributeCenterY ofView:self.titleLabel offset:0];
}

This API is very rich. It allows to direct access and setting all view’s properties, event like: minY or maxX, or operating with groups of subviews.

For more info, take a look at GitHub here.

I hope you will find a good use of our pods. Don’t forget to let us know what you think about them, we can always improve our libraries. Long live open-source!

Share

Maciej

CTO

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!